有人在stackoverflow上面提问:
http://stackoverflow.com/questions/17776584/webserver-for-go-golang-webservices-using-nginx-or-not
- I am writing some webservices returning JSON data, which have lots of users.
- Would you recommend to use NGINX as a webserver or it is good enough to use the standard http server of Go?
于是有人就回答了:
XML/HTML代码
- It depends.
- Out of the box, putting nginx in front as a reverse proxy is going to give you:
- Access logs
- Error logs
- Easy SSL termination
- SPDY support
- gzip support
- Easy ways to set HTTP headers for certain routes in a couple of lines
- Very fast static asset serving (if you're serving off S3/etc. though, this isn't that relevant)
- The Go HTTP server is very good, but you will need to reinvent the wheel to do some of these things (which is fine: it's not meant to be everything to everyone).
- I've always found it easier to put nginx in front—which is what it is good at—and let it do the "web server" stuff. My Go application does the application stuff, and only the bare minimum of headers/etc. that it needs to. Don't look at putting nginx in front as a "bad" thing.
还有人回答:
XML/HTML代码
- The standard http server of Go is fine. If your application mostly/only are "dynamic" requests/responses, then it's really the best way.
- You could use nginx to serve static assets, but most likely the standard Go one is fine for that, too. If you need higher performance you should just use a CDN or cache as much as you can with Varnish (for example).
- If you need to serve different applications off the same IP address, nginx is a fine choice for a proxy to distribute requests between the different applications; though I'd more often get Varnish or HAProxy out of the toolbox for that sort of thing.
这回你觉得呢?你还会用nginx吗?还是只用go做http server/???