Skip to content

Instantly share code, notes, and snippets.

@yoppi
Last active July 9, 2016 10:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yoppi/b6b2fcbb745d2021b4054c3183d0afa8 to your computer and use it in GitHub Desktop.
Save yoppi/b6b2fcbb745d2021b4054c3183d0afa8 to your computer and use it in GitHub Desktop.
benchmark net/http vs iris
< ab -n 1000 -c 10 'http://127.0.0.1:8080/' [~/local/go/1.7-rc1]
This is ApacheBench, Version 2.3 <$Revision: 1706008 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 127.0.0.1 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests
Server Software: iris
Server Hostname: 127.0.0.1
Server Port: 8080
Document Path: /
Document Length: 51 bytes
Concurrency Level: 10
Time taken for tests: 0.385 seconds
Complete requests: 1000
Failed requests: 0
Total transferred: 207000 bytes
HTML transferred: 51000 bytes
Requests per second: 2596.88 [#/sec] (mean)
Time per request: 3.851 [ms] (mean)
Time per request: 0.385 [ms] (mean, across all concurrent requests)
Transfer rate: 524.95 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 2 1.5 1 13
Processing: 0 2 1.5 1 14
Waiting: 0 2 1.3 1 13
Total: 0 4 2.5 3 17
Percentage of the requests served within a certain time (ms)
50% 3
66% 4
75% 5
80% 5
90% 7
95% 9
98% 11
99% 14
100% 17 (longest request)
< ab -n 1000 -c 10 'http://127.0.0.1:8080/' [~/local/go/1.7-rc1]
This is ApacheBench, Version 2.3 <$Revision: 1706008 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 127.0.0.1 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests
Server Software:
Server Hostname: 127.0.0.1
Server Port: 8080
Document Path: /
Document Length: 51 bytes
Concurrency Level: 10
Time taken for tests: 0.206 seconds
Complete requests: 1000
Failed requests: 0
Total transferred: 180000 bytes
HTML transferred: 51000 bytes
Requests per second: 4846.25 [#/sec] (mean)
Time per request: 2.063 [ms] (mean)
Time per request: 0.206 [ms] (mean, across all concurrent requests)
Transfer rate: 851.88 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 1 0.5 1 6
Processing: 0 1 0.8 1 7
Waiting: 0 1 0.6 1 6
Total: 1 2 1.1 2 8
Percentage of the requests served within a certain time (ms)
50% 2
66% 2
75% 2
80% 3
90% 3
95% 4
98% 5
99% 5
100% 8 (longest request)
package main
import (
"github.com/kataras/iris"
)
func main() {
iris.Get("/", func(c *iris.Context) {
c.JSON(iris.StatusOK, iris.Map{
"Name": "Iris",
"Born": "13 March 2016",
"Start": 3693,
})
})
iris.Listen(":8080")
}
package main
import (
"encoding/json"
"log"
"net/http"
)
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
b, err := json.Marshal(map[string]interface{}{
"Name": "Iris",
"Born": "13 March 2016",
"Start": 3693,
})
if err != nil {
log.Fatal(err)
return
}
w.Header().Set("Content-Type", "application/json; charset=utf-8")
w.WriteHeader(http.StatusOK)
w.Write(b)
})
http.ListenAndServe(":8080", nil)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment