# Please help with optimization

**URL:** <https://www.ruby-forum.com/t/please-help-with-optimization/223438>\
**Category:** NGINX\
**Created:** [October 4, 2012, 6:22am UTC](https://www.ruby-forum.com/t/please-help-with-optimization/223438 "2012-10-04T06:22:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [October 4, 2012, 6:22am UTC](https://www.ruby-forum.com/t/please-help-with-optimization/223438/1 "2012-10-04T06:22:43Z")

</div>

Hello All,  
I am looking to optimize my nginx setup but am new to nginx and some of  
the  
settings. Currently the webserver is set to just default settings and on  
using an forum import script to migrate our forum from another softward  
I am  
getting “upstream timed out (110: Connection timed out) while reading  
response header from upstream”.  
Could someone give me some suggestions?

I am running an Amazon ec2 Ubuntu Precise 64 server with the folowing  
hardware setup  
7.5 GB memory  
4 EC2 Compute Units (2 virtual cores with 2 EC2 Compute Units each)  
850 GB instance storage  
64-bit platform  
I/O Performance: High

I am running nginx 1.2.4 and PHP 5.3.10-1ubuntu3.4 (fpm-fcgi)

The website will be running a forum with on average 2000 visitors at any  
given time, over 60k members and 4 million posts.  
I need help with the following setttings that currently only have the  
defaults set.  
php-fpm’s php.ini  
php-fpm’s pool configuration  
nginx.conf  
anything else you can suggest.

Thanks so much!

Posted at Nginx Forum:

> **[Please help with optimization](https://forum.nginx.org/read.php?2,231369,231369#msg-231369)**
>
> Hello All, I am looking to optimize my nginx setup but am new to nginx and some of the settings. Currently the webserver is set to just default settings and on using an forum import script to migrate our forum from another softward I am getting...

---

<div class="post-metadata">

**Author:** ![otherjohn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/c0e974/32.png) [@otherjohn](https://www.ruby-forum.com/u/otherjohn)\
**Post date:** [October 4, 2012, 11:17am UTC](https://www.ruby-forum.com/t/please-help-with-optimization/223438/2 "2012-10-04T11:17:43Z")

</div>

Performance issues with large forum migrations are usually database  
i/o specific; nginx is good because it gets out of the way and sends  
the php responses from fpm. Standard php configuration for nginx will  
get it up and running, but you will want to tune php to suit the forum  
software, and devote most of the system resources to database, which  
will consume most of them. When that happens, php waits, fastcgis pile  
up, and nginx will hit timeouts waiting for php, which is waiting for  
mysql. Make sure mysql has good write performance and plenty of  
memory. Beware of expensive forum plugins (use slow logging to spot  
horrible queries that make php wait).

---

<div class="post-metadata">

**Author:** ![otherjohn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/c0e974/32.png) [@otherjohn](https://www.ruby-forum.com/u/otherjohn)\
**Post date:** [October 4, 2012, 1:32pm UTC](https://www.ruby-forum.com/t/please-help-with-optimization/223438/3 "2012-10-04T13:32:47Z")

</div>

Thanks Stephen,  
Our DB setup is an external RDS MySql Large DB Instance: 7.5 GB memory,  
4  
ECUs (2 virtual cores with 2 ECUs each), 64-bit platform, High I/O  
Capacity.

There is not much I can do to increase the performance on this but I  
don’t  
think it’s whats causing the problem.  
The web server has no traffic (except for me) and the DB is only being  
used  
for one other site. Based on its reports, it looks like if we did this  
migration at peak traffic time, it still won’t touch 80% of DB usage.

John

## Stefan C. Wrote:

> reading
> 
> > I/O Performance: High  
> > php-fpm’s pool configuration  
> > [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> > [mailman.nginx.org archive](http://mailman.nginx.org/mailman/listinfo/nginx)
> 
> * * *
> 
> nginx mailing list  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [mailman.nginx.org archive](http://mailman.nginx.org/mailman/listinfo/nginx)

Posted at Nginx Forum:  
[http://forum.nginx.org/read.php?2,231369,231384#msg-231384](http://forum.nginx.org/read.php?2,231369,231384#msg-231384)

---

<div class="post-metadata">

**Author:** ![otherjohn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/c0e974/32.png) [@otherjohn](https://www.ruby-forum.com/u/otherjohn)\
**Post date:** [October 4, 2012, 7:13pm UTC](https://www.ruby-forum.com/t/please-help-with-optimization/223438/4 "2012-10-04T19:13:23Z")

</div>

My best suggestion would be to look through your nginx and php settings  
to  
limit the amount of persistent connections and total connections (both  
to  
mysql and to your site(s)). The more persistent connections there are,  
the  
more processes on your server and web browsers accessing the site will  
be  
able to maintain a single connection each, so limitting those will force  
it  
to cut off anything inactive or taking too long when it reaches that  
limit.

Unfortunately I don’t have the experience to come clsoe to suggesting  
good  
values for you. My best advice would be to check for general  
recommendations  
on Google et al., then pick what you feel is safe and adjust over time  
until  
you feel you hit the right values.

Another option would be to enable gzip within nginx, (add “gzip on;”  
without  
quotes to nginx.conf), then use Google to research what browsers don’t  
support gzip. You can blacklist those browser by adding something  
similar  
to:

gzip\_disable “msie6”;

to nginx.conf, placing all the browser UA strings within quotes. That  
way,  
nginx will automatically use gzip compression for browsers that are not  
blacklisted, which will save bandwidth. There are also various options  
you  
can add to nginx.conf (I think the default has them commented out by  
default) to tweak this further.

There are plenty of other things you can do to optimize things, most of  
which you can find quite easily in the nginx wiki and via Google et al.  
Search for things like “nginx optimization”, “nginx and php-fpm  
optimization”, and “nginx and php-fpm and mysql optimization”.

Posted at Nginx Forum:

> **[Re: Please help with optimization](https://forum.nginx.org/read.php?2,231369,231391#msg-231391)**
>
> Hello All, I am looking to optimize my nginx setup but am new to nginx and some of the settings. Currently the webserver is set to just default settings and on using an forum import script to migrate our forum from another softward I am getting...
