Plug POST performance

Interesting I have tried myself to benchmark a simple plug on my Macbook. The Plug code is listed below and started by

{:ok, _} = Plug.Adapters.Cowboy.http SimplePlug, []

I get similar results to yourself I cannot get more than 26,000 Requests/sec. Tried setting +K true also.

defmodule SimplePlug do
  import Plug.Conn

  def init(options) do
    options
  end

  def call(conn, _opts) do
    conn
    |> put_resp_content_type("text/plain")
    |> send_resp(200, "Hello")
  end
end

I tried a simple Java spark example.

import static spark.Spark.*;

public class Main {
    public static void main(String[] args) {
        get("/", (req, res) -> "Hello");
    }
}

It gets about 35,000 Requests/sec. So it’s not that much ahead of Elixir.

Go out of the box, blows them all away…

package main

import (
	"io"
	"net/http"
)

func handler(writer http.ResponseWriter, request *http.Request) {
	io.WriteString(writer, "Hello")
}

func main() {
	http.HandleFunc("/", handler)
	http.ListenAndServe(":8080", nil)
}

This gets about 51,000 Requests/sec