菜单
  

    Ruby on rails server options The word "deployment" can have two meanings depending on the context. You are also confusing the roles of Apache/Nginx with the roles of other components.

    Historic note: This article was originally written on November 6, 2010, when the Ruby app server ecosystem was limited. I've updated this article on March 15 2013 with all the latest updates in the ecosystem.69160

    Disclaimer: I am one of the authors of Phusion Passenger, one of the app servers.

    Apache vs Nginx

    They're both web servers. They can serve static files but - with the right modules - can also serve dynamic web apps e.g. those written in PHP. Apache is more popular and has more features, Nginx is smaller and faster and has less features.

    Neither Apache nor Nginx can serve Ruby web apps out-of-the-box, to do that you need to use Apache/Nginx in combination with some kind of add-on, described later.

    Apache and Nginx can also act as reverse proxies, meaning that they can take an incoming HTTP request and forward it to another server, which also speaks HTTP. When that server responds with an HTTP response, Apache/Nginx will forward the response back to the client; You will learn later why this is relevant.

    Mongrel and other production app servers vs WEBrick

    Mongrel is a Ruby "application server": In concrete terms this means that Mongrel is an application which:

    Loads your Ruby app inside its own process space.

    Sets up a TCP socket, allowing it to communicate with the outside world (e.g. the Internet). Mongrel listens for HTTP requests on this socket and passes the request data to the Ruby web app.

    The Ruby web app then returns an object, which describes what the HTTP response should look like, and Mongrel takes care of converting it to an actual HTTP response (the actual bytes) and sends it back over the socket.

    However Mongrel is quite dated, nowadays it is no longer maintained. Newer alternative application servers are:

    Phusion Passenger

    Unicorn

    Thin

    Puma

    Trinidad (JRuby only)

    TorqueBox (JRuby only)

    I'll cover them later and describe how they differ from each other and from Mongrel.

    WEBrick does the same thing as Mongrel, but the differences are:

    WEBrick is not fit for production, unlike everything else that I mentioned before. WEBrick is written entirely in Ruby. Mongrel (and most other Ruby app servers) is part Ruby and part C (Mostly Ruby), but its HTTP parser is written in C for performance.

    WEBrick is slower and less robust. It has some known memory leaks and some known HTTP parsing problems.

    WEBrick is usually only used as the default server during development because WEBrick is included in Ruby by default. Mongrel and other app servers needs to be installed separately. It's not recommended to use WEBrick in production environments, though for some reason Heroku chose WEBrick as its default server. They were using Thin before, so I have no idea why they switched to WEBrick.

    The app server and the world

    All current Ruby app servers speak HTTP, however some app servers may be directly exposed to the Internet on port 80, while others may not.

    App servers that can be directly exposed to the Internet: Phusion Passenger, Rainbows

    App servers that may not be directly exposed to the Internet: Mongrel, Unicorn, Thin, Puma. These app servers must be put behind a reverse proxy web server like Apache and Nginx.

    I don't know enough about Trinidad and TorqueBox, so I've omitted them.

    Why must some app servers be put behind a reverse proxy?

    Some app servers can only handle 1 request concurrently, per process. If you want to handle 2 requests concurrently you need to run multiple app server instances, each serving the same Ruby app. This set of app server processes is called an app server cluster (hence the name Mongrel Cluster, Thin Cluster, etc). You must then setup Apache or Nginx to reverse proxy to this cluster. Apache/Nginx will take care of distributing requests between the instances in the cluster (More on this in section "I/O concurrency models").

  1. 上一篇:PHP动态建模英文文献和中文翻译
  2. 下一篇:变频器在供水控制系统的应用英文文献和中文翻译
  1. 汽车乘员舱的声振耦合英文文献和中文翻译

  2. 立体光照成型的注塑模具...

  3. 数控机床英文文献和中文翻译

  4. 工业机械手英文文献和中文翻译

  5. 低频振动的铁路车轴的状...

  6. 接头的形状对沥青塞接头...

  7. 数控加工技术英文文献和中文翻译

  8. 杂拟谷盗体内共生菌沃尔...

  9. 酸性水汽提装置总汽提塔设计+CAD图纸

  10. 河岸冲刷和泥沙淤积的监测国内外研究现状

  11. 大众媒体对公共政策制定的影响

  12. 电站锅炉暖风器设计任务书

  13. 当代大学生慈善意识研究+文献综述

  14. 十二层带中心支撑钢结构...

  15. java+mysql车辆管理系统的设计+源代码

  16. 乳业同业并购式全产业链...

  17. 中考体育项目与体育教学合理结合的研究

  

About

751论文网手机版...

主页:http://www.751com.cn

关闭返回