PDA

View Full Version : Are theses settings overkilled for my VPS?


BmXStuD
08-21-2006, 11:52 AM
Hello, Im wondering if theses current settings are pretty overkill for my vps? Just got a email saying the rapidvps software is flagging my system for using to much brustable.

Anyways could anyone tweak theses settings.


<IfModule prefork.c>
StartServers 3
MinSpareServers 8
MaxSpareServers 12
ServerLimit 18
MaxClients 180
MaxRequestsPerChild 0
</IfModule>


<IfModule worker.c>
StartServers 2
MaxClients 150
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild 25
MaxRequestsPerChild 0
</IfModule>


KeepAliveTimeout 3
MaxKeepAliveRequests 100
KeepAlive Off
TimeOut 200



and

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1

[mysqld]
skip-locking
skip-innodb
query_cache_limit=8M
query_cache_size=256M
query_cache_type=1
max_connections=500
interactive_timeout=20
wait_timeout=20
connect_timeout=6
thread_cache_size=128
key_buffer=16M
join_buffer=1M
max_allowed_packet=16M
table_cache=1024
record_buffer=1M
sort_buffer_size=2M
read_buffer_size=2M
max_connect_errors=10
# Try number of CPU's*2 for thread_concurrency
thread_concurrency=4
myisam_sort_buffer_size=64M
#log-bin
server-id=1

[mysqld_safe]
open_files_limit = 8192

[mysqldump]
quick
max_allowed_packet = 16M

[myisamchk]
key_buffer=32M
sort_buffer=32M
read_buffer=16M
write_buffer=16M
MY site is not very huge, so now im wondering should i re-do my site or prune my database of old mods i have installed.

Rick
08-21-2006, 12:13 PM
Its more dependant on your traffic and web code. Ie, one poorly coded website with a handful of visitors can use several hundred mb's of ram and several hundred mhz. Whereas, a properly coded site, one that is using code level database caching and not querying the database for the same semi-static information on each page load will use very little resources.

lordrich
08-21-2006, 02:39 PM
Apache and MySQL settings really depend on what you are using them for, lots of busy sites will need more resources allocated to Apache and MySQL than smaller static sites. If you're only running one basic website then it might be worth looking into alternatives to Apache (eg lighttpd). That said, there are some changes you can make to reduce your memory usage.

For Apache StartServers, MinSpareServers and MaxSpareServers can usually be reduced to 1 or 2. For MySQL key_buffer can be reduced to 2Mb or even as low as 16k if you're not using MySQL much. Make sure you comment your config files with the original settings so that you know what to change back if you reduce the values too far. And try disabling any Apache Modules you aren't actually using.

What other software are you running? Take a look at top's output to see what you main memory hogs are - SpamAssassin and Clam can sometimes use up lots of memory. Is everything that is running absolutely necesary?

BmXStuD
08-21-2006, 06:00 PM
Apache and MySQL settings really depend on what you are using them for, lots of busy sites will need more resources allocated to Apache and MySQL than smaller static sites. If you're only running one basic website then it might be worth looking into alternatives to Apache (eg lighttpd). That said, there are some changes you can make to reduce your memory usage.

For Apache StartServers, MinSpareServers and MaxSpareServers can usually be reduced to 1 or 2. For MySQL key_buffer can be reduced to 2Mb or even as low as 16k if you're not using MySQL much. Make sure you comment your config files with the original settings so that you know what to change back if you reduce the values too far. And try disabling any Apache Modules you aren't actually using.

What other software are you running? Take a look at top's output to see what you main memory hogs are - SpamAssassin and Clam can sometimes use up lots of memory. Is everything that is running absolutely necesary?


Im just running a IPB forum.

heres my current op

top - 00:59:57 up 28 min, 1 user, load average: 0.35, 0.34, 0.34
Tasks: 31 total, 1 running, 29 sleeping, 0 stopped, 1 zombie
Cpu(s): 3.1% us, 0.3% sy, 0.0% ni, 96.7% id, 0.0% wa, 0.0% hi, 0.0% si
Mem: 8222812k total, 8144092k used, 78720k free, 437448k buffers
Swap: 8193020k total, 3749340k used, 4443680k free, 1592704k cached

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
21739 apache 15 0 30412 19m 16m S 5.7 0.2 0:14.78 httpd
5806 apache 15 0 29208 18m 16m S 5.7 0.2 0:02.76 httpd
17751 apache 15 0 29444 18m 16m S 0.7 0.2 0:16.33 httpd
5818 apache 15 0 29236 18m 16m S 0.7 0.2 0:02.43 httpd
18274 apache 16 0 29504 18m 16m S 0.3 0.2 0:07.91 httpd
7325 apache 15 0 0 0 0 Z 0.3 0.0 0:01.10 httpd <defunct>
7394 apache 16 0 27456 16m 16m S 0.3 0.2 0:00.55 httpd
1 root 16 0 1668 608 1472 S 0.0 0.0 0:00.48 init
17957 root 16 0 1540 620 1372 S 0.0 0.0 0:00.00 syslogd
17979 named 24 0 54948 3204 4972 S 0.0 0.0 0:00.00 named
21781 root 15 0 4324 1692 3952 S 0.0 0.0 0:00.00 sshd
21789 root 18 0 2100 896 1768 S 0.0 0.0 0:00.00 xinetd
21843 root 18 0 2224 1124 2036 S 0.0 0.0 0:00.00 mysqld_safe
21883 mysql 15 0 302m 17m 10m S 0.0 0.2 0:00.16 mysqld
21922 root 15 0 7964 3188 6804 S 0.0 0.0 0:00.03 sendmail
21929 smmsp 18 0 6952 2676 5792 S 0.0 0.0 0:00.00 sendmail
21949 root 15 0 18852 7440 16m S 0.0 0.1 0:00.22 httpd
[root@www html]#



I just disabled some things i recently enabled and installed. Hopefully, theses was to fault:

persistent connection was on
and acouple mods that had abunch of queries.

After i get some sleep tonight i will have rapidvps do a OS reload plus i will re-do my forums. That means i will have a FRESH VPS and fresh forum files from IPB with a fresh Database with all the mods gone. Im not sure, but my VPS ins't acting like it did when i first got it. (ran good than) and i think i know the problem. Plus, the usage its using seems like something a bigger site might make. Im not sure if my vps has been comprised in anyway, but OS reload would help me sleep better. I might also have to pay someone trusted with a good rep to install Lightttpd for me also.

lordrich
08-21-2006, 06:48 PM
That defunct httpd process doesn't sound good to me. Since it's only one of the child processes it might be safe to ignore - I simply don't know. It might be worth checking your Apache error log to see if you find any obvious problems.

You're probably safe to stop xinetd. It's a long time since I've used sendmail, but I think there's a way of only having it run when you want to send emails (provided of course you're not actually receiving any on this server). You could also offload your DNS to your domain registrar and then stop named.

Oh, and Apache isn't doing HostnameLookups is it? And you don't have stupidly large Apache log files do you? And how come cron isn't running?

BmXStuD
08-21-2006, 06:59 PM
That defunct httpd process doesn't sound good to me. Since it's only one of the child processes it might be safe to ignore - I simply don't know. It might be worth checking your Apache error log to see if you find any obvious problems.

You're probably safe to stop xinetd. It's a long time since I've used sendmail, but I think there's a way of only having it run when you want to send emails (provided of course you're not actually receiving any on this server). You could also offload your DNS to your domain registrar and then stop named.

Oh, and Apache isn't doing HostnameLookups is it? And you don't have stupidly large Apache log files do you? And how come cron isn't running?

HostnameLookups Off

I havent deleted or changed any logs since i had the vps. My MYSQL log is almost 700mb :eek: and my error log is 200mb:eek: Really, my vps is junked up like a noob would have it.. lol which i am. Its in need of a OS reload which will be done. I have software like rsync which is spitting out errors.

I stopped cron b/c its never worked really for me :/. I been trying to just keep APF, MYSQL,Http running only.
My forum only uses mail to send new registration emails and thats all really. It only uses PHP to send email since i dont have EMAIL setup on my vps. It'll be nice if i could set it up only to run when it needs to send mail. You have any readmes to set it up like that?

BmXStuD
08-22-2006, 06:36 AM
How big should i keep the LOGS? Whens a good time to delete them? When there bigger than 80mbs? Just something i need to keep track of more.

Rick
08-22-2006, 06:43 AM
You can configure logwatch to turn/dump old log files. It depends on how critical your log files are. If you are logging data in a corporate environment, you never want to delete them. If its just for fun/hobby, you can nuke them pretty early. ie, you only need to analyze them in realtime.

yager
08-22-2006, 11:30 AM
Rick may have meant 'logrotate' rather than 'logwatch', but even if not, do look into logrotate; and you NEED cron running for this and much more. The default installation is probably a good starting point.

I also find that configuring/tweaking the syslog configuration improves my logfile appreciation.

Also, I think it's 'OK' to rethink the needs and uses of a firewall, especially if your few running services and passwords are secure. Firewall would be a great discussion, if we can find the appropriate forum topic for it.

BmXStuD
08-22-2006, 11:46 AM
Im ona fresh reimage of the OS today. Fresh forums and everything. Hopefully, this will fix my usage problems.

BmXStuD
08-24-2006, 04:15 PM
I read the apache optimaztion guide and i tweaked my http.conf and now my memory usage is only @ 98mb ;]. So, i think im good now. I was using about 500mb of memory.

heres my new settings:

<IfModule prefork.c>
StartServers 2
MinSpareServers 1
MaxSpareServers 2
ServerLimit 89
MaxClients 150
MaxRequestsPerChild 0



<IfModule worker.c>
StartServers 2
MaxClients 50
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild 25
MaxRequestsPerChild 0
</IfModule>




Heres my new top: 1 thing you notice is only 1 instance of apache is running instead of the old 9+ idling using like 30mb each. I will have to tweak it throughout the day to make sure the max memory usage is not above or slightly above my limit. Seems rapid1 can be used for a smaller site, but needs some of tweaking to get it running properly. Add together all the idling apache processes and mysql using 40mb of ram by itself is way over my 128mb ram limit.


2042 apache 15 0 28612 16m 17m S 13.8 0.2 0:07.40 httpd
1 root 15 0 1616 508 1420 S 0.0 0.0 0:02.45 init
7855 root 16 0 2456 940 1532 S 0.0 0.0 0:00.10 crond
7377 root 15 0 3988 1300 3616 S 0.0 0.0 0:00.01 sshd
1706 root 16 0 6896 4768 3232 S 0.0 0.1 0:00.55 miniserv.pl
5191 root 16 0 2140 944 1952 S 0.0 0.0 0:00.00 mysqld_safe
5231 mysql 16 0 42172 18m 9808 S 0.0 0.2 0:01.78 mysqld
19614 root 16 0 7368 2944 6208 S 0.0 0.0 0:00.74 sendmail
19629 smmsp 15 0 6464 2120 5304 S 0.0 0.0 0:00.00 sendmail
11962 root 15 0 3720 2740 1288 S 0.0 0.0 0:00.06 minilogd
25901 root 15 0 6876 2136 6380 S 0.0 0.0 0:00.02 sshd
27692 Twista 15 0 7048 2300 6380 S 0.0 0.0 0:00.04 sshd
27804 Twista 15 0 3780 1280 3228 S 0.0 0.0 0:00.03 sftp-server
4048 root 15 0 6876 2136 6380 S 0.0 0.0 0:00.01 sshd
4060 Twista 15 0 6876 2248 6380 S 0.0 0.0 0:00.10 sshd
4064 Twista 16 0 3664 1216 3228 S 0.0 0.0 0:00.02 sftp-server
32283 root 15 0 6876 2136 6380 S 0.0 0.0 0:00.01 sshd

lordrich
08-24-2006, 11:59 PM
OK fantastic, you've got your base memory usage down to a sensible level. It might still be worth looking at what happens when your server is particularly busy, ie. does your memory usage go through the roof or does Apache start denying connections. If everything looks fine during peak periods, then you know you have a happy server.

Oh, and why not stop webmin - it might not save much memory but it'll discourage you from fiddling :-)

BmXStuD
08-25-2006, 07:33 AM
OK fantastic, you've got your base memory usage down to a sensible level. It might still be worth looking at what happens when your server is particularly busy, ie. does your memory usage go through the roof or does Apache start denying connections. If everything looks fine during peak periods, then you know you have a happy server.

Oh, and why not stop webmin - it might not save much memory but it'll discourage you from fiddling :-)


:confused: Well, now it seems my usage is down, but not many can connect. My internet explorer finds my site, but my Firefox says its a DNS problem with the site. I restored my backup of my old http.conf and still having that problem. I wonder if it has something to do with named being disabled half the day. I only have a graph which updates like every 5minutes to view my CPU/Mem usage, so im trying to use that best to my ablity to check usage. Guess tomorrow ill be back @ doing this and it sucks lol doing it on a live server where it can screw my users over.

Funny thing is when i restored my old file my usage jumped from 125mb usage to 226mb usage and my cpu jumped from 0.4mhz used to 20mhz used when no1 can really access my site. Grr sucky stock settings. And NAMED running using 50mb itself i think.