<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html><body style='font-size: 10pt; font-family: Verdana,Geneva,sans-serif'>
<p>I've just done a drupal7 site under nginx+php-fpm on debian.</p>
<p>One thing I noticed was that the php process wasn't closing fast enough, this was tracked down to an issue with mysql. Connections were sitting idle for a long time which basically exhausted the fpm workers on both the web servers.</p>
<p>We have 2 mysql nodes doing replication between them and I think the binlog commit was holding this up, adding <span class="ansi0 bgAnsi15">"innodb_flush_log_at_trx_commit = 0" to the my.cnf stopped this problem from occuring.</span></p>
<p><span class="ansi0 bgAnsi15">Page caching is stored in mysql too, moving this to memcached helped massively and reduced the daily binlogs from 5G/day down to a few hundred meg.</span></p>
<p>I'm not sure if this is a strange setup but we have nginx terminating ssl which proxies to varnish which then has 2 additional nginx nodes serving drupal7, these use a 2 node mysql cluster and 2 memcached nodes for caching pages etc.</p>
<p>Steve.</p>
<p>On 07/04/2014 15:34, Geo P.C. wrote:</p>
<blockquote type="cite" style="padding-left:5px; border-left:#1010ff 2px solid; margin-left:5px"><!-- html ignored --><!-- head ignored --><!-- meta ignored -->
<div dir="ltr">
<p class="MsoNormal">We are facing a strange issue on our servers. We have servers with 1GB RAM and some drupal sites are running on it.</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">Generally all sites are loading fine but sometimes we are unable to access any sites. After waiting for 10mts we are getting a 502 gateway timeout error. In middle when we restart either nginx or php5-fpm it will load.</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">Our configurations are as follows:</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">/etc/nginx/nginx.conf:</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">user www-data;</p>
<p class="MsoNormal">worker_processes 1;</p>
<p class="MsoNormal">pid /run/nginx.pid;</p>
<p class="MsoNormal">worker_rlimit_nofile 400000;</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">events {</p>
<p class="MsoNormal"><span> </span>worker_connections 10000;</p>
<p class="MsoNormal"><span> </span>multi_accept on;</p>
<p class="MsoNormal"><span> </span>use epoll;</p>
<p class="MsoNormal">}</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">http {</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal"><span> </span><span> </span>access_log<span> </span>off;</p>
<p class="MsoNormal"><span> </span>sendfile on;</p>
<p class="MsoNormal"><span> </span>tcp_nopush on;</p>
<p class="MsoNormal"><span> </span>tcp_nodelay on;</p>
<p class="MsoNormal"><span> </span>keepalive_timeout 2;</p>
<p class="MsoNormal"><span> </span>types_hash_max_size 2048;</p>
<p class="MsoNormal"><span> </span>server_tokens off;</p>
<p class="MsoNormal"><span> </span>keepalive_requests 100000;</p>
<p class="MsoNormal"><span> </span>reset_timedout_connection on;</p>
<p class="MsoNormal"><span> </span>port_in_redirect off;</p>
<p class="MsoNormal"><span> </span>client_max_body_size 10m;</p>
<p class="MsoNormal"><span> </span>proxy_connect_timeout<span> </span>600s;</p>
<p class="MsoNormal"><span> </span>proxy_send_timeout<span> </span>600s;</p>
<p class="MsoNormal"><span> </span>proxy_read_timeout<span> </span>600s;</p>
<p class="MsoNormal"><span> </span><span> </span>fastcgi_send_timeout 600s;</p>
<p class="MsoNormal"><span> </span><span> </span><span> </span>fastcgi_read_timeout 600s;</p>
<p class="MsoNormal"><span> </span><span> </span><span> </span><span> </span>open_file_cache max=200000 inactive=20s;</p>
<p class="MsoNormal"><span> </span><span> </span><span> </span>open_file_cache_valid 30s;</p>
<p class="MsoNormal"><span> </span><span> </span><span> </span><span> </span>open_file_cache_min_uses 2;</p>
<p class="MsoNormal"><span> </span><span> </span><span> </span><span> </span>open_file_cache_errors on;</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">/etc/php5/fpm/pool.d/www.conf</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">pm.max_children = 5</p>
<p class="MsoNormal">pm.start_servers = 2</p>
<p class="MsoNormal">pm.min_spare_servers = 1</p>
<p class="MsoNormal">pm.max_spare_servers = 3</p>
<p class="MsoNormal">;pm.process_idle_timeout = 10s;</p>
<p class="MsoNormal">;pm.max_requests = 200</p>
<p class="MsoNormal">request_terminate_timeout = 300s</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">And please see the added contents in /etc/sysctl.conf</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">##########################</p>
<p class="MsoNormal">fs.file-max = 150000</p>
<p class="MsoNormal">net.core.netdev_max_backlog=32768</p>
<p class="MsoNormal">net.core.optmem_max=20480</p>
<p class="MsoNormal">#net.core.rmem_default=65536</p>
<p class="MsoNormal">#net.core.rmem_max=16777216</p>
<p class="MsoNormal">net.core.somaxconn=50000</p>
<p class="MsoNormal">#net.core.wmem_default=65536</p>
<p class="MsoNormal">#net.core.wmem_max=16777216</p>
<p class="MsoNormal">net.ipv4.tcp_fin_timeout=120</p>
<p class="MsoNormal">#net.ipv4.tcp_keepalive_intvl=30</p>
<p class="MsoNormal">#net.ipv4.tcp_keepalive_probes=3</p>
<p class="MsoNormal">#net.ipv4.tcp_keepalive_time=120</p>
<p class="MsoNormal">net.ipv4.tcp_max_orphans=262144</p>
<p class="MsoNormal">net.ipv4.tcp_max_syn_backlog=524288</p>
<p class="MsoNormal">net.ipv4.tcp_max_tw_buckets=524288</p>
<p class="MsoNormal">#net.ipv4.tcp_mem=1048576 1048576 2097152</p>
<p class="MsoNormal">#net.ipv4.tcp_no_metrics_save=1</p>
<p class="MsoNormal">net.ipv4.tcp_orphan_retries=0</p>
<p class="MsoNormal">#net.ipv4.tcp_rmem=4096 16384 16777216</p>
<p class="MsoNormal">#net.ipv4.tcp_synack_retries=2</p>
<p class="MsoNormal">net.ipv4.tcp_syncookies=1</p>
<p class="MsoNormal">#net.ipv4.tcp_syn_retries=2</p>
<p class="MsoNormal">#net.ipv4.tcp_wmem=4096 32768 16777216</p>
<p class="MsoNormal">##########################</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">Can anyone please help us on it.</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">Thanks</p>
<p class="MsoNormal"> </p>
Geo</div>
<br />
<pre>_______________________________________________
nginx mailing list
<a href="mailto:nginx@nginx.org">nginx@nginx.org</a>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx">http://mailman.nginx.org/mailman/listinfo/nginx</a>
</pre>
</blockquote>
<p> </p>
<div> </div>
</body></html>