Optimize server daemons

Don´t be shy, Linux is fun! =)
Post Reply
User avatar
ayu
Staff
Staff
Posts: 8109
Joined: 27 Aug 2005, 16:00
18
Contact:

Optimize server daemons

Post by ayu »

Was just wondering if anyone has any good tip or maybe a guide of some sort for optimizing different services. I have installed and configured a lot of stuff today and just randomly trying to optimize them right now is nothing I want to do at the moment, so I thought maybe someone else have done it before and can either help me or tip me about some guides they used ^^

The services that need optimization are:

mysql-server-5.0
apache2 with php5 and mysql modules
ossec
snort
vmware server


Thanks for any information in advance :)
"The best place to hide a tree, is in a forest"

User avatar
bad_brain
Site Owner
Site Owner
Posts: 11636
Joined: 06 Apr 2005, 16:00
19
Location: In your eye floaters.
Contact:

Post by bad_brain »

phew....optimizing is a steady process and there are many settings that depends on the whole system config and resources, so it's often not possible to say "use this setting".

ok, let's start:

- Snort is pretty easy and effective to optimize, open snort.conf and disable all rulesets you don't really need...it's pointless to use the rules for an IIS server if you run Linux for example, also MsSQL, etc....this can save you a lot of RAM.

- Apache2 is already not that easy anymore to optimize, because it depends on parameters like amount of visitors, etc. I assume your Apache is a prefork MPM one (it's the default install usually), so open apache2.conf (or httpd.conf, don't know if it's also a split file as on Debian) and check the following settings:

Code: Select all

StartServers         2
MinSpareServers      3
MaxSpareServers      5
MaxClients           35
MaxRequestsPerChild  1000
of course that's just an example....
now your settings depend on the amount of visitors and the available RAM. the less servers you start the less permanent RAM usage you have, but if you have a high amount of visitors and Apache has to start new processes all the time it'll cause a high CPU load.
important is the MaxClients setting, because here you set how many clients can connect at the same time, in my example 35...an Apache process with MySQL and PHP usually uses about 25MB RAM, so 35x25=875MB. if you only have 512 MB RAM and set it to high values there can come a point when Apache tries to use more RAM than available, which can result in a system crash because important kernel processes run out of RAM. so better set this to low values and have an eye on the apache.log for "Max. Clients reached" entries (then you can slowly increase the value).
it's better when some people have to wait a little until their request is processed when the MaxClients limit is reached than a crashed system than can't serve any request anymore.

- and now MySQL...phew...this is the one that takes most time, best is to get the tuning-primer script for MySQL servers for an analysis, the longer the server runs the more reliable the results will be, you can get it here:
http://www.day32.com/MySQL/tuning-primer.sh
it is possible you have to install some small packages from the repositories to use the full functionality, you will be informed if you have to. the script will analyze your MySQL config and will make recommendations, but before applying any new settings always backup the old config and inform yourself about what the variable does.
of course you can post your output on http://code.suck-o.com so I can have a look and give you some tips.
so for MySQL I can't give any general tips for optimization before the analysis was done, the only one is maybe to disable the binary update log...of course you should do regular db-backups then (which is a must for any good sysadmin anyway). disabling the log will decrease the write-to-disk activity which is always good for the performance.
for database-backups best use the "AutoMySQLBackup" script from the suck-o downloads...
:wink:

User avatar
Big-E
Administrator
Administrator
Posts: 1332
Joined: 16 May 2007, 16:00
16
Location: IN UR ____ , ____ING UR _____ .
Contact:

Re: Optimize server daemons

Post by Big-E »

If you're on MSN later on tonight, or in the morning - I can help you out in real time.

User avatar
ayu
Staff
Staff
Posts: 8109
Joined: 27 Aug 2005, 16:00
18
Contact:

Post by ayu »

Thanks both of you for your answers. Big-e, I have already optimized most of the server now, only MySQL to go, but if you have any recommendations, then just fire away : D

btw, b_b, I'm not sure, but, is it supposed to look like this? ^^

Code: Select all

http://code.suck-oold.com/161
"The best place to hide a tree, is in a forest"

User avatar
bad_brain
Site Owner
Site Owner
Posts: 11636
Joined: 06 Apr 2005, 16:00
19
Location: In your eye floaters.
Contact:

Post by bad_brain »

bc is missing, install it via apt-get.... :wink:

User avatar
ayu
Staff
Staff
Posts: 8109
Joined: 27 Aug 2005, 16:00
18
Contact:

Post by ayu »

ok, thanks :D
"The best place to hide a tree, is in a forest"

Post Reply