Proper tunning for ~150k a month
Amar
20 March 2012, 09:22
Hello Hugo
I am actualy looking for advice here.. I *might* soon host one really popular site/blog that gets around 150k visits a month or in average 5k a day. Do you have any idea what would be proper setup for this scenario? Let's say server would have 2GB of RAM and 24 HT CPU cores.
Would something like:
Forks = 15
MaxRequest = 1000
in fcgi config be OK in your opinion? Ofcourse no one can tell without proper traffic but I am just looking for general guide : )
Best
Hiawatha version: 8.1
Operating System: Debian
150k/mo is not too much.. I would pull up maxrequests to maybe 4000 as well as ConnectionsTotal... but Im pretty sure it will perfectly handle 150k/day, not to say 150k/mo
we are hosting several sites with more than 28k/day each (5 sites per server) in a virtual server.. .and the server is near 0 load average.
Amar
22 March 2012, 00:03
Thanks for feedback
Can you share info on how many PHP forks you have running ?
Hugo Leisink
22 March 2012, 17:52
I don't think 150k requests per month is much. The webserver this website is hosted on gets about 50k requests per day! I have only 5 forks and left MaxRequests to the default. This server has a very easy job, so I could even do with less forks (2 for example). My advice is to use the same values, 5 forks and leave MaxRequests out.
To give you an idea of how many forks are required: 150k requests per month is 5k per day, is about 400 per hour (assuming that the website is only visited during daytime, not during night time), is about 6 requests per minute. Unless the PHP scripts take more than 10 seconds to complete, even one PHP fork could easily do the job.
Setting MaxRequests to a high value is not adviceable at all. To prevent memory leaks in PHP to eat up all your memory, you want to renew the PHP instances from time to time. Setting MaxRequests to a high value is not speeding up your webserver. So, just leave it alone unless you really know what you are doing.
Amar
25 March 2012, 13:16
Thanks for update Hugo, really helpful
This is some numbers site owner gave me.. for ex,:
Day Number of visits Pages Hits Bandwidth
01 Mar 2012 5,195 43,043 431,346 6.26 GB
02 Mar 2012 6,128 52,383 449,081 5.68 GB
...and so on
Also he mentioned that he has problems with current hosting when site gets "over 150 concurent visits" . I am not sure how he knows that ( i am 99% sure he doesnt have ssh access) but it seems I will have to tune it up for 300 concurent visits. So is "MaxRequest and ConnectionsTotal OK to set on ~300 ?
BTW on what hardware specs you host this site ? : )
Hugo Leisink
26 March 2012, 19:15
If I understand the information correctly, you have about 5k people per day visiting your website. Each person looks at about 10 pages per visit. Each page view causes about 10 hits, due to images, stylesheets and javascripts that are included in a page. Assuming that only a page view causes a PHP script to be executed and not every hit means that 50k PHP executions take place per day.
50k, in about 10 hours (assuming that most page views are done during day time) means 5k per hour and about 80 per minute. Assuming a PHP script takes less than a second to finish, two forks should be able to do the job. But since you have more than enough memory, double it handle the more busy moments. My advice in your case: start with 4 forks and test carefully how well your site respons.
About the MaxRequests: don't change this setting. It has nothing to do with the amount of simultaneous connections. It defines after how many script executions a fork should be killed and respawned. A too low value means to much respawning, which requires CPU time. A too high value can cause memory leaks in applications to eat up all your memory. The default is 100, I think it's a good value to start with.
This website is hosted on a VPS, so the real hardware specs are difficult to say. The information that Linux tells me is: dual Xeon 2.4 GHz with 2 GB RAM. Average load of this server is 0.00.
Amar
27 March 2012, 13:41
Thanks Hugo, that was really helpful..
Now I will be hosting couple more site on same server (7 or 8 sites in total) but they together get like ~15-16k a month. Would it be good idea to setup those as standard CGI (I had this before and it's really fast) and have this "busy" site only on fcgi ? I mean, this way I gould have 4 forks only, not 30-40 : )
Hugo Leisink
27 March 2012, 14:29
FastCGI is 15 times faster than normal CGI, so I don't recommand using normal CGI. 15k requests per month is nothing, like 3 requests per minute. You won't even notice them. And if you want to be sure, just add a single fork. With 2 GB of RAM, you have more than enough memory for it.
Amar
27 March 2012, 14:33
Yes, but AFAIK I can't tell fastcgi "for this user use one fork and for this use 4 of them" . So if I have 5 different users running fastcgi forks that would be 20 of them : )
Hugo Leisink
27 March 2012, 14:34
You mean you plan to run a fork for each host under a different user id?
Amar
27 March 2012, 14:36
Isn't that recommended way? How do you run it? I mean, users sharing PHP processes,session files etc..
On Apache setups I use SuEXEC which runs each users PHP process
Amar
27 March 2012, 14:42
I cant edit post.. now when I read your question again.. No, It's like this:
lets say user amar have 3 sites running, all of those 3 will run php forks under user amar. So no, not every site will run under different user but if there is
amar - 3 sites
amar2 - 2 sites
amar3 - 1 site
hugo - 2 sites
hugo2 - 1 site
owner of bussy site - 1 site
and if I run 4 forks this would make total of 24 forks
Hugo Leisink
27 March 2012, 14:43
I don't know much about your situation, so that's the reason I asked. I have also multiple websites running on my webserver, but most of them are written by me or at least I control the code. So, they all run under the same user id. Saves a lot of memory.
What I understand from your last post is that you allow several users on your server to place their website on it. In that case, you have less controll over the code and what is hosted than I do. So, yes, than it is advisable to run all websites under their own unique id, for example the id of the user that ownes the website.
In your case, using normal CGI with, for example, Hiawatha's cgi-wrapper is a sane solution. You can also chose to use a single PHP FastCGI fork for the 'heaviest' websites of those 7 or 8 websites.
Hugo Leisink
27 March 2012, 14:46
To answer your last question: no, 24 forks is too much. If you say that the 7 or 8 other websites together have about 15k requests per month, each website will do fine with just 1 fork. So, 3 forks for the popular blog and for each other website 1 fork. That will make 9 forks.
Amar
27 March 2012, 15:10
Yes but how to tell php-fcgid "for user amar,amar2,amar3 run 1 fork and for user hugo run 4 forks" ?
Hugo Leisink
27 March 2012, 15:52
Uhmm... good point.
I'll update the php-fcgi tool in a way that for each Server, the amount of forks can be specified. If you send an e-mail to hugo at hiawatha dash webserver dot org, I'll send you an updated php-fcgi.c. You can also chose to use php5-fpm.
Amar
27 March 2012, 15:54
Great, sending you email as we type : )
This topic has been closed.