Optimizing Tomcat5 to use less resources on a small VDS
Posted: Fri Aug 24, 2007 3:26 am
I've been getting into Java lately and everything I've done has been on my own computer. Yesterday I decided it was about time I got a servlet container installed and running on one of my spare IPs on my VDS. Before I installed tomcat5 on my little Etch server which has just 128MB RAM and a slice of a 3GHz CPU I was running with plenty of spare memory and 0.00 load average. That's for Exim4, Dovecot, Apache2/PHP5, MySQL5. I already had these pimped to run as best I could make them run on low end hardware.
Now when I installed tomcat5 I never though much of it until this morning I SSH'd to my VDS and OMG it was slow. Looking at what was running in "top", the load average was at 0.9 and memory was basically running from swap space
I've had a read around but haven't found a great deal of information on dealing with this so I made some educated guesses modifying server.xml. I brought down min-proccessors and max-processors to values between 2 and 8 as opposed the their default 5-75 values. I also disabled lookups. Now my load average is back at 0.00 (ish) and I can hammer the server with requests no problem... but my memory is still consumed by the JVM
Does anyone have any tips on getting this down a little bit? 33% of my entire memory being used when no requests are even being made to the servlet container is, well, just a waste really 
EDIT | Eek! I'd better change tomcat so it's running as root
Now when I installed tomcat5 I never though much of it until this morning I SSH'd to my VDS and OMG it was slow. Looking at what was running in "top", the load average was at 0.9 and memory was basically running from swap space
I've had a read around but haven't found a great deal of information on dealing with this so I made some educated guesses modifying server.xml. I brought down min-proccessors and max-processors to values between 2 and 8 as opposed the their default 5-75 values. I also disabled lookups. Now my load average is back at 0.00 (ish) and I can hammer the server with requests no problem... but my memory is still consumed by the JVM
Code: Select all
top - 09:18:14 up 22 days, 18:20, 2 users, load average: 0.01, 0.10, 0.15
Tasks: 71 total, 2 running, 69 sleeping, 0 stopped, 0 zombie
Cpu(s): 0.3%us, 0.0%sy, 0.0%ni, 99.7%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 131188k total, 127232k used, 3956k free, 888k buffers
Swap: 522072k total, 102856k used, 419216k free, 35340k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
21465 root 18 0 252m 42m 11m S 0.0 33.3 0:04.20 java
13145 root 16 0 36100 23m 1928 S 0.0 18.7 0:01.05 spamd
12272 mysql 15 0 46408 5652 2132 S 0.0 4.3 7:10.30 mysqld
21442 www-data 16 0 27680 5392 3284 S 0.0 4.1 0:00.04 apache2
21443 www-data 16 0 27680 5392 3284 S 0.0 4.1 0:00.04 apache2
17004 root 16 0 32184 2524 852 S 0.0 1.9 0:06.71 spamd
2865 gdm 16 0 13008 2456 1756 S 0.0 1.9 0:02.17 gdmlogin
21441 www-data 16 0 27552 2140 1488 S 0.0 1.6 0:00.00 apache2
21444 www-data 16 0 27552 2128 1488 S 0.0 1.6 0:00.00 apache2
2768 snmp 16 0 7076 1544 892 S 0.0 1.2 0:04.95 snmpd
21456 dovecot 16 0 3304 1492 1244 S 0.0 1.1 0:00.01 imap-login
21398 dovecot 16 0 3308 1216 1164 S 0.0 0.9 0:00.00 imap-login
21031 root 16 0 32184 1112 432 S 0.0 0.8 0:00.00 spamd
21494 root 16 0 2240 1020 784 R 0.0 0.8 0:00.01 top
21127 pdns 15 0 71444 984 780 S 0.0 0.8 0:00.01 pdns_server
21057 root 15 0 2972 876 688 S 0.0 0.7 0:00.01 bash
9795 root 16 0 12936 764 512 S 0.0 0.6 0:00.85 nscd
2823 root 16 0 8532 752 548 S 0.0 0.6 0:00.72 Xvnc
21310 d11wtq 16 0 2568 720 616 S 0.0 0.5 0:00.00 imap
4494 d11wtq 16 0 2552 708 588 S 0.0 0.5 0:44.59 imap
21313 d11wtq 16 0 2368 680 560 S 0.0 0.5 0:00.01 imap
1851 d11wtq 16 0 3432 624 512 S 0.0 0.5 0:01.04 imap
4495 d11wtq 16 0 2660 620 504 S 0.0 0.5 0:02.64 imap
1849 d11wtq 16 0 2572 612 496 S 0.0 0.5 0:01.88 imap
21319 d11wtq 16 0 2364 600 512 S 0.0 0.5 0:00.00 imap
21050 d11wtq 16 0 8396 576 428 R 0.0 0.4 0:00.05 sshd
21322 dovecot 16 0 3308 468 388 S 0.0 0.4 0:00.00 imap-login
11900 root 16 0 1928 432 348 S 0.0 0.3 0:04.01 dovecot
11902 root 16 0 8368 416 332 S 0.0 0.3 0:03.77 dovecot-auth
2693 root 17 0 32008 400 320 S 0.3 0.3 2:23.17 xengmond
25472 root 16 0 12384 396 332 S 0.0 0.3 0:00.18 pdns_server
11528 root 16 0 27552 372 268 S 0.0 0.3 0:00.42 apache2
13287 ftp 16 0 2776 352 260 S 0.0 0.3 0:00.25 proftpd
17178 Debian-e 16 0 5640 324 252 S 0.0 0.2 0:00.11 exim4
2832 root 16 0 2204 316 244 S 0.0 0.2 0:00.07 cron
2681 root 16 0 1632 304 228 S 0.0 0.2 0:03.01 syslogdEDIT | Eek! I'd better change tomcat so it's running as root