Question

Regarding to way of Nginx server's optimization

  • Posted January 26, 2015

Hi Im looking for a way of Nginx server’s Optimization. Although I tried to read article in here and google it. I dont know which methods are better because of variety configration. If there is good instruction plz let me know! THANKS!

Subscribe
Share

@junukseo sorry for the delay, been super busy lately, You need to strees test your site with a few users first then go up till you get to the 250 users, so you can figure out how many users your app can actually support on your current droplet, it sounds like your droplet is running out of memory so maybe you need to set your setting a little lower.

Maybe you can describe your current droplet stats.

@EpicCDN hello, I really appriciate your kind answer. since I use 14.04, instead of apc, use as enable OPCACHE. lastly can I have a question? I did stress test on my website for 250 people, before you informed on biitz.jo website. but everytime did stress test, my hompage get error.so I can use my homepage after rebute server

is there something wrong about optimize as hompage get error? or originally get error? sicerely thanks for your answer again.

Sure thing, I use W3 Total Cache, and APC, it works perfectly an allows you a lot of extra stuff like the use of CDN (I made my own CDN win Nginx for static files), DB cache, and more. Just stay away from minify option, most WP themes break with minify sadly.

You can also configure Cloudflare in Total Cache so it can prune your cloudflare’s cache.

@EpicCDN

Thanks for your reply.

I set up all configration as you showed me and tested at Blitz.io.

I really appreciate to you

and I have one more question.

I am using Cloudflare + LENP with Configration + Fast cgi

I’m not using any Cache plugin in Wordpress.

Could you tell me what cache plugins or modules do you recommend?

@junukseo that tutorial seems ok, but it only covers nginx, as i’m guessing here I bet you run php on your sites too (they are not 100% static websites made of html files right?), if this is the case you need to optimize php manager, which again i’m assuming it should be php-fpm?

If it is php-fpm open the config file (maybe in /etc/php-fpm.d/www.conf it varies by OS), there you may check this parameters:

This is just an example, don’t use the same values (more below) pm = dynamic pm.max_children = 128 pm.start_servers = 2 pm.min_spare_servers = 2 pm.max_spare_servers = 15 pm.max_requests = 500

Where pm=dynamic is maybe the best option for most servers. pm.max_children = 128 is the amount of processes your server will handle at the same time, each process or children can handle several connections so this not need to be too high unless you are expecting too many visitors at the same time, and you have the resources for it.

so to start try pm.max_children = 64 and go up if need it.

pm.start_servers = 2 pm.min_spare_servers = 2 pm.max_spare_servers = 4

in theory you should set pm.max_spare_servers to the number of cores your server has, or so they say, in your case 1, but you can try adjust a little bit higher, try 4+, and see how it works,

start and min_spare servers are the number of servers you want to start with, try a low value like 2 to start with.

PHP is the slowest process in your webserver, so the most you optimize the better. but you need to test it to be sure, you can use ab to stress test, but I suggest you to open a free account at blitz.io, if you open a free account at Cloudflare (which you should) you get a free account with blitz.io that allows you to stress test your site up to 250 concurrent visitors for a few seconds, which is good to know how many users your server can handle.

Play with pm.max_children and pm.max_spare_servers till you can handle most of the 250 concurrent visitors from blitz.io stress test. Also make sure to use Cloudflare service, it will handle most of the load off your server.

note: Blitz.io free account is on apps section in the Cloudflare panel.

Best of lucks

@EpicCDN

Hi. Thanks for your reply. I’m using LEMP server with 5dollor plan and i just optimized refer to https://www.digitalocean.com/community/tutorials/how-to-optimize-nginx-configuration this article.

I keep another setting as default and I’m operating 2websites using server blocks. Would you tell me how to set up nginx server? many thanks

This comment has been deleted

There are many ways, and most depend of your own needs. Nginx by itself is pretty fast so not much optimization is needed, php-fpm may need some tweaks for sure, but are also simple. maybe you can share more info about your setup, application, and conf files, as same for your expectations for it.


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

This question was answered by @EpicCDN:

@junukseo that tutorial seems ok, but it only covers nginx, as i’m guessing here I bet you run php on your sites too (they are not 100% static websites made of html files right?), if this is the case you need to optimize php manager, which again i’m assuming it should be php-fpm?

If it is php-fpm open the config file (maybe in /etc/php-fpm.d/www.conf it varies by OS), there you may check this parameters:

This is just an example, don’t use the same values (more below) pm = dynamic pm.max_children = 128 pm.start_servers = 2 pm.min_spare_servers = 2 pm.max_spare_servers = 15 pm.max_requests = 500

Where pm=dynamic is maybe the best option for most servers. pm.max_children = 128 is the amount of processes your server will handle at the same time, each process or children can handle several connections so this not need to be too high unless you are expecting too many visitors at the same time, and you have the resources for it.

so to start try pm.max_children = 64 and go up if need it.

pm.start_servers = 2 pm.min_spare_servers = 2 pm.max_spare_servers = 4

in theory you should set pm.max_spare_servers to the number of cores your server has, or so they say, in your case 1, but you can try adjust a little bit higher, try 4+, and see how it works,

start and min_spare servers are the number of servers you want to start with, try a low value like 2 to start with.

PHP is the slowest process in your webserver, so the most you optimize the better. but you need to test it to be sure, you can use ab to stress test, but I suggest you to open a free account at blitz.io, if you open a free account at Cloudflare (which you should) you get a free account with blitz.io that allows you to stress test your site up to 250 concurrent visitors for a few seconds, which is good to know how many users your server can handle.

Play with pm.max_children and pm.max_spare_servers till you can handle most of the 250 concurrent visitors from blitz.io stress test. Also make sure to use Cloudflare service, it will handle most of the load off your server.

note: Blitz.io free account is on apps section in the Cloudflare panel.

Best of lucks

View the original comment