Last active
August 29, 2015 14:01
-
-
Save gudmundur/0513a965c1cf6b8a7327 to your computer and use it in GitHub Desktop.
Simple throughput benchmark in Go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ran this on my 2014 MBA 13" 1.7 GHz i7, 8GB Ram. | |
$ go version | |
go version go1.2.1 darwin/amd64 | |
$ go build go-web.go | |
$ GOMAXPROCS=4 ./go-web & | |
$ wrk -t10 -c400 http://localhost:8080 | |
Running 10s test @ http://localhost:8080 | |
10 threads and 400 connections | |
Thread Stats Avg Stdev Max +/- Stdev | |
Latency 4.72ms 1.33ms 47.42ms 95.49% | |
Req/Sec 5.56k 3.57k 14.00k 56.97% | |
524490 requests in 10.00s, 64.02MB read | |
Socket errors: connect 159, read 77, write 0, timeout 636 | |
Requests/sec: 52455.45 | |
Transfer/sec: 6.40MB |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"net/http" | |
) | |
func handler(w http.ResponseWriter, r *http.Request) { | |
fmt.Fprintf(w, "Hello world") | |
} | |
func main() { | |
http.HandleFunc("/", handler) | |
http.ListenAndServe(":8080", nil) | |
} |
I decided to write a similar example using dynamo:
defmodule HelloWorld do
use Dynamo
use Dynamo.Router
config :server, port: 8888, acceptors: 10000, max_connections: 100000
get "/" do
conn.resp_body("Hello World!")
end
end
Running the above
➜ iex -S mix
Erlang/OTP 17 [erts-6.0] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]
Compiled lib/hello_world.ex
Generated elixir_hello_world.app
Interactive Elixir (0.13.2) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> HelloWorld.start_link
{:ok, #PID<0.124.0>}
iex(2)> HelloWorld.run
Running HelloWorld at http://localhost:8888 with Cowboy on prod
:ok
iex(3)>
Gave this result
➜ wrk -t10 -c400 http://localhost:8888
Running 10s test @ http://localhost:8888
10 threads and 400 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 14.84ms 16.72ms 249.04ms 92.14%
Req/Sec 3.32k 1.49k 14.81k 76.23%
312975 requests in 10.00s, 53.71MB read
Socket errors: connect 0, read 149, write 0, timeout 0
Requests/sec: 31295.46
Transfer/sec: 5.37MB
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That's awesome! I got