加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – 是否有必要将Unicorn放在Nginx(或Apache)

发布时间:2020-12-16 21:40:51 所属栏目:百科 来源:网络整理
导读:我对这个架构有些困惑.在我正在开展的项目之一中,Unicorn被选为Rails服务器.而且它放在Nginx Web服务器的后面.据了解,Unicorn是功能齐全的Web服务器,我们不打算在同一服务器实例上托管任何其他Rails应用程序. 所以我的问题是:链中附加层有什么好处? client
我对这个架构有些困惑.在我正在开展的项目之一中,Unicorn被选为Rails服务器.而且它放在Nginx Web服务器的后面.据了解,Unicorn是功能齐全的Web服务器,我们不打算在同一服务器实例上托管任何其他Rails应用程序.

所以我的问题是:链中附加层有什么好处?

client -> nginx -> unicorn -> unicorn worker

解决方法

独角兽不是处理“慢客户”的设计.您可以在 PHILOSOPHY帮助文件中阅读更多信息:

Most benchmarks we’ve seen don’t tell you this,and unicorn doesn’t care about slow clients… but you should.

A “slow client” can be any client outside of your datacenter. Network traffic within a local network is always faster than traffic that crosses outside of it. The laws of physics do not allow otherwise.

Persistent connections were introduced in HTTP/1.1 reduce latency from connection establishment and TCP slow start. They also waste server resources when clients are idle.

Persistent connections mean one of the unicorn worker processes (depending on your application,it can be very memory hungry) would spend a significant amount of its time idle keeping the connection alive and not doing anything else. Being single-threaded and using blocking I/O,a worker cannot serve other clients while keeping a connection alive. Thus unicorn does not implement persistent connections.

If your application responses are larger than the socket buffer or if you’re handling large requests (uploads),worker processes will also be bottlenecked by the speed of the client connection. You should not allow unicorn to serve clients outside of your local network.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读