I'm trying to benchmark a simple 'hello world' HTTP server in go
.
I've made 2 tests:
- Using amazon ec2 - m3.medium instance
- Using amazon elastic beanstalk - also with m3.medium single instance
On the first setup, I could get up to 18k req/sec. On the second, 1.6k req/sec.
Source code:(from: https://golang.org/doc/articles/wiki/)
package main
import (
"fmt"
"net/http"
)
func handler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hi there, I love %s!", r.URL.Path[1:])
}
func main() {
http.HandleFunc("/", handler)
http.ListenAndServe(":8080", nil)
}
Is there any explanation for such a huge performance difference?
PS:
benchmark tool: https://github.com/wg/wrk
Also, one important thing is: Elastic beanstalk always adds nginx as a reverse proxy for it's applications(and for Go apps I was not able to remove it)
On the first setup, there was no nginx at all.