Getting the most out of your server

7 posts / 0 new
Last post
#1 Wed, 08/06/2008 - 11:18
acid

Getting the most out of your server

For Centos 5.2 + Virtualmin Pro

If you have more than 500 accounts, you get more than 100K mails (60% spam) a day and more then 500 GB Bandwidth Usage (don't forget to make backups first):

1- In:

/etc/cron.hourly/00awstats

change this line:

if [ -f /var/log/httpd/access_log ] ; then

for

if [ -f /var/log/httpd/access_log_let_my_cpu_alone ] ; then

2- In: Webmin -> Webmin -> Webmin Configuration -> Advanced Options -> CPU priority for scheduled jobs, select Priority level = - 15

3- In: Virtualmin -> Email Messages -> Spam and Virus Scanning -> Enable ClamAV Server

Then go again to Virtualmin -> Email Messages -> Spam and Virus Scanning -> in SpamAssassin client program select: spamc -> in Maximum message size to process for spamc type: 1000000 -> in Virus scanning program select: Server scanner (clamdscan) -> and Save

4- In: Webmin -> System -> Bootup and Shutdown -> postfix -> Start at boot time? = No -> Save

DON'T FORGET to start postfix after booting!

We are doing this because if you are getting too much mails by starting the Server you will get out of memory (RAM and swap, if you are luky the kernel will stop postfix otherwise you will need to poweroff the server) (... too much lookup-domain processes will get started).

5- This point is only for experts! Don't do it if you don't know what are you doing! (don't forget to do backups)

Type:

ulimit -n

if you see 1024 you can increase this number by doing this:

  • In /etc/security/limits.conf add this 2 lines:

  • soft nofile 4096

  • hard nofile 4096

  • In /etc/pam.d/login add this line:

session required pam_limits.so

  • In /etc/rc.d/rc.local add this line:

ulimit -n 4096

  • reboot

6- Adding this line in /etc/httpd/conf.d/fcgid.conf

MaxRequestsPerProcess 500

You should stop getting this error in /var/log/http/error_log:

Too many open files: mod_fcgid: couldn't set child ...

Don't forget to restart your apache (/etc/init.d/httpd restart)

http://fastcgi.coremail.cn/doc.htm

7- You can save CPU usage by doing this:

Go to -> Webmin -> Servers -> Postfix Mail Server -> Delivery rates -> change:

Min time (secs) between attempts to deliver a deferred message = 500s Time (secs) between scanning the deferred queue = 500s Max time (days) in queue before message is undeliverable = 120m Max time (secs) between attempts to deliver a deferred message = 2000s

Any more tips we will gratefull!! ;)<br><br>Post edited by: acid, at: 2008/10/20 12:49

Wed, 08/06/2008 - 12:28
Joe
Joe's picture

<div class='quote'>more than 400 accounts, you get more than 100K mails (60% spam) a day and more then 500 GB Bandwidth Usage (don't forget to make backups first)</div>

Sweet! I love hearing about big deployments.

<div class='quote'>4- In: Webmin -&gt; System -&gt; Bootup and Shutdown -&gt; postfix -&gt; Start at boot time? = No -&gt; Save

DON'T FORGET to start postfix after booting!

We are doing this because if you are getting too much mails by starting the Server you will get out of memory (RAM and swap, if you are luky the kernel will stop postfix otherwise you will need to poweroff the server) (... too much lookup-domain processes will get started).</div>

This sounds like something we need to deal with. I'm not sure how, though...we've already daemonized lookup-domain to make it fast. But, an accidental &quot;fork bomb&quot; spawned by delivering hundreds of messages to procmail at once is harder to manage.

--

Check out the forum guidelines!

Tue, 09/30/2008 - 07:10 (Reply to #2)
acid

Hi iambacon

Mother: Intel DG33FB
CPU: Intel P Dual Core E 2200
RAM: 4 GB DDR2 667

Fri, 06/26/2009 - 17:07 (Reply to #3)
deserted

This seems more like something that should be handled in your server config, not in Vmin itself

for example limiting max procs in postfix, to do this change the following line in master.cf

smtp      inet  n       -       y       -      100     smtpd

to

smtp      inet  n       -       y       -       60      smtpd

or whatever level of threads you find gives a suitable result for your server. Also please note the "y" above may also be replaced by a '-' or 'n' depending on your OS and whether or not you are chrooting postfix, so best to leave the rest of the line untouched

Sun, 09/28/2008 - 18:49
iambacon

Great tips Acid! What are the CPU/RAM specs on your server? I am in the process of switching from CPanel. Tips like these really help get the most of my box. My server feels like a marathon runner now. No more couch potato bloatware.

Wed, 01/21/2009 - 02:59
fuerst

Adding DefaultMaxClassProcessCount 2 to your fcgid.conf will limit the number of phpX.cgi processes per user to 2. This seems to be sufficient for standard Web traffic on my machine with 2 CPUs.

DefaultMaxClassProcessCount defaults to 100 which is way to much on a Shared Hosting server. I found the limit of 2 to be reasonable when I produced load using the Apache benchmark tool <i>ab</i>.

BTW: If you need or want to host a high traffic web site you better switch to a dedicated server and mod_php.

Sat, 07/02/2011 - 02:58
coreyt

If postfix is bombing like that I believe you can set limits in the postfix module to prevent that kind of thing.

Maybe someone can come up with a delayed start mechanism for virtualmin/webmin that kicks off services after a delay to allow the system to gracefully ramp up.

Topic locked