Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/56.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 使用ApacheHTTPD代理的Rails/Puma?_Ruby On Rails_Apache_Puma - Fatal编程技术网

Ruby on rails 使用ApacheHTTPD代理的Rails/Puma?

Ruby on rails 使用ApacheHTTPD代理的Rails/Puma?,ruby-on-rails,apache,puma,Ruby On Rails,Apache,Puma,我想使用Puma和HTTPD来服务我的Rails应用程序。据我所知,很少有人做这种事。我知道nginx比HTTPD有一些好处,而且乘客使很多事情变得容易,但是有理由不使用Puma/HTTPD吗 我在网上浏览了一些示例,并整理了一个我喜欢的HTTPD配置块,它似乎工作得很好(尽管我没有做任何性能测试)。我遗漏了什么吗?这似乎比大多数Puma/nginx或乘客/HTTPD设置更容易/更简单,这让我有点担心 <VirtualHost *:3008> DocumentRoot MY_RA

我想使用Puma和HTTPD来服务我的Rails应用程序。据我所知,很少有人做这种事。我知道nginx比HTTPD有一些好处,而且乘客使很多事情变得容易,但是有理由不使用Puma/HTTPD吗

我在网上浏览了一些示例,并整理了一个我喜欢的HTTPD配置块,它似乎工作得很好(尽管我没有做任何性能测试)。我遗漏了什么吗?这似乎比大多数Puma/nginx或乘客/HTTPD设置更容易/更简单,这让我有点担心

<VirtualHost *:3008>
  DocumentRoot MY_RAILS_ROOT/public
  ProxyPass /favicon.ico !
  ProxyPass /robots.txt !
  ProxyPassMatch ^/(404|422|500).html$ !
  ProxyPass /assets/ !

  ProxyPass / http://127.0.0.1:9292/ # Puma bind address
  ProxyPassReverse / http://127.0.0.1:9292/
</VirtualHost>

DocumentRoot MY\u RAILS\u ROOT/public
ProxyPass/favicon.ico!
ProxyPass/robots.txt!
ProxyPassMatch^/(404 | 422 | 500).html$!
ProxyPass/资产/!
ProxyPass/http://127.0.0.1:9292/ #彪马绑定地址
ProxyPassReverse/http://127.0.0.1:9292/

这是apachehttpd作为反向代理的一种相当常见的用法,因此没有特别的问题。您是否在同一台计算机上同时运行web服务器和puma?拆分它们可能是一个好主意,以防止内存消耗、TCP堆栈和在高负载下可能发生的任何其他争用问题

如果您有多个puma节点,则可以使用HTTPD跨所有节点执行负载平衡,如下所示:

<VirtualHost example.org:80>
    ServerName example.org
    ServerAlias www.example.org

    ErrorLog /srv/www/example.org/logs/error.log 
    CustomLog /srv/www/example.org/logs/access.log combined

    DocumentRoot MY_RAILS_ROOT/public

    <Proxy balancer://cluster>
        BalancerMember http://app1.example.org
        BalancerMember http://app2.example.org
    </Proxy>

    ProxyPass /favicon.ico !
    ProxyPass /robots.txt !
    ProxyPassMatch ^/(404|422|500).html$ !
    ProxyPass /assets/ !

    ProxyPass / balancer://cluster/
    # enumerate all nodes for proxypassreverse since it adds a trailing slash :( bugid 51982
    ProxyPassReverse / http://app1.example.org
    ProxyPassReverse / http://app2.example.org


    # ProxyPass / balancer://cluster/ lbmethod=byrequests
    # ProxyPass / balancer://cluster/ lbmethod=bytraffic
    # ProxyPass / balancer://cluster/ lbmethod=bybusyness
</VirtualHost>

ServerName example.org
ServerAlias www.example.org
ErrorLog/srv/www/example.org/logs/error.log
CustomLog/srv/www/example.org/logs/access.log
DocumentRoot MY\u RAILS\u ROOT/public
平衡员http://app1.example.org
平衡员http://app2.example.org
ProxyPass/favicon.ico!
ProxyPass/robots.txt!
ProxyPassMatch^/(404 | 422 | 500).html$!
ProxyPass/资产/!
ProxyPass/balancer://cluster/
#枚举proxypassreverse的所有节点,因为它添加了尾部斜杠:(bugid 51982
ProxyPassReverse/http://app1.example.org
ProxyPassReverse/http://app2.example.org
#ProxyPass/balancer://cluster/ lbmethod=byrequests
#ProxyPass/balancer://cluster/ lbmethod=按流量
#ProxyPass/balancer://cluster/ lbmethod=忙碌

虽然如果你有更好的HA选项(如AWS ELBs、HAProxy、清漆或其他)然后,我希望在我们的项目中,当您免费获得第7层可用性检查时,我们有varnish->nginx->puma堆栈,它工作得非常好。nginx通常更健壮、快速和强大,并且它的内存消耗比httpd少。总之,您真的需要httpd吗?:)阅读httpd(模块化)和nginx的体系结构(在中编译的模块)。但如果性能不是问题,并且您很了解httpd,请使用它:)编辑:考虑一下在unix sock模式下启动puma,它会获得一些性能改进。