Newbie question: How does a golang server compare to NGINX and Apache?

agolangf · · 337 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>I used Apache in the past, for hosting PHP websites. I know very little about NGINX but from what I understand it&#39;s also a web/mail server. </p> <p>How do most developers use Go on the server, do they install the web server software together with the Go program, or do they use the stdlib http/smtp server? </p> <p>What are the pros and cons of using full web servers like Apache and using only the Go libraries?</p> <hr/>**评论:**<br/><br/>justinisrael: <pre><blockquote> <p>I used Apache in the past, for hosting PHP websites. I know very little about NGINX but from what I understand it&#39;s also a web/mail server. </p> </blockquote> <p>Nginx uses an asynchronous model for serving requests which gives it better performance than Apache for certain use cases. It has historically had extremely good capabilities for serving static content, or tons of connections without the memory overhead of tons of threads to service them. </p> <blockquote> <p>How do most developers use Go on the server, do they install the web server software together with the Go program, or do they use the stdlib http/smtp server? </p> </blockquote> <p>Go has a stdlib which contains a production grade net package. It can be used directly as a web server without the need for a reverse proxy. That is, many people simply copy a binary to a server and start it on a port. But others may have reasons for putting a Go server behind a reverse proxy (Apache, nginx, Caddy) </p> <blockquote> <p>What are the pros and cons of using full web servers like Apache and using only the Go libraries?</p> </blockquote> <p>A Go binary can be a full web server on its own without Apache. But if you need to proxy requests to different applications, then maybe a dedicated web server like Apache, nginx, caddy, or other may be desirable to you. Maybe a particular server has very good caching and serving of static content. Or you want to use a load balancer in front of multiple instances of a server. Or you want to handle authentication or encryption before your Go application. </p></pre>DanChm: <pre><p>Thanks, this is great. Cleared things up.</p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

337 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传