Go is less reliable than Flask/Tornado?(webapps.stackexchange.com) |
Go is less reliable than Flask/Tornado?(webapps.stackexchange.com) |
Boost the fd count in /etc/security/limits.conf past 1024 or whatever the default is on the OS. Or if that isn't an option, then modify the Go http server code so that it closes each web connection after the request is processed.
eg. w.Header().Set("Connection", "close") in the handler func.
If you set this, the http package should close the connection for you after it is done processing your current request. You can and usually should call this up front in your handler, it won't close the connection immediately. I prefer this to trying to manually close the connection because it should work despite the function exit point (sort of like a defer without the defer).
It is probably also worth boosting your fd count, because if you're flooded with connections you still might hit the limit faster than you can close the connections. At the very least you may want to do the sorts of things web servers like apache do: http://httpd.apache.org/docs/2.2/vhosts/fd-limits.html (Setrlimit is available in Go's syscall package and may help you out here).