Web Hosting Talk







View Full Version : Tune apache


maxbear
09-04-2001, 10:26 AM
Hi all,

My server is having around 100K - 150K visitors per day. Most of them are just html pages. Inside the html pages, I also include some very simple php script, like calling a header or footer. There is one strange thing, it's a little bite slow for me to access the web site but I if I can access the site, the page load fast.

I would like to know should I change the config of Apache? Like increae the max connections to 300 or higher? Or should I add more RAM? I have included the "top" info as follow:

9:19am up 7:44, 1 user, load average: 0.26, 0.33, 0.38
359 processes: 354 sleeping, 1 running, 1 zombie, 3 stopped
CPU states: 5.9% user, 7.0% system, 0.0% nice, 86.9% idle
Mem: 257460K av, 247460K used, 10000K free, 671556K shrd, 5372K buff
Swap: 265032K av, 44520K used, 220512K free 23272K cached


Any comments are welcome.

Madman2020
09-04-2001, 10:52 AM
From the top you displayed, the only problem I see is RAM. When you start digging into swap like that, you should consider a physical RAM upgrade. You also can tune Apache, but I would try this first and see how it goes.

valkaryn
09-04-2001, 06:18 PM
Having run administered several of the internets major adult site servers and large active virtual hosting servers, I can tell you that changing your configuration as follows will definitely squeeze what you need out the door faster:


MinSpareServers 30
MaxSpareServers 100
StartServers 30
MaxClients 1024
MaxRequestsPerChild 0 (unless your apache is old)


If your statistics package can do hostname lookups, use it and don't make apache do it. To turn off hostname lookup and give you much better performance:

HostnameLookups On

You'll find different schools of thought on keepalives. I have generally found that it helps until you reach a certain threshold (based on memory, cpu, config, and kernel) where keepalives no longer help. Many will argue with me on this.

And, upgrade to 512 (or 1024) megs RAM since you have a going concern and memory is so cheap these days. That will carry you for a while.

Visit the Apache website and do a search on "performance". You will find kernel tuning suggestions for your OS along with many of the directive changes I have listed above.

Palm
09-04-2001, 06:48 PM
Also remove some modules that you don't need.
That will increase apache performance.

jks
09-05-2001, 03:37 PM
I have an idea for maxbear...

Try installing APC -- it will really speed your server, as those PHP pages are slowing everything down for you!

We have used that technique on several large sites - and it really works great!

huck
09-05-2001, 05:28 PM
You should monitor the RAM usage.

Looks like you are starting to swap data, this will cause your server to grind to a halt. RAM will fix this.

Also, the settings that valkaryn suggested will really speed things up -- if you have enough RAM.

Try using the vmstat command -- this will show you how much info you are swapping. Look at the man page for more details. But your swap i/o should be very low unless you are swapping request.

I would try to do this when the server is under heavy load.


If PHP is slowing you down, the APC's cache will help tremendously.

Also, tweak the min spare servers higher than whatever you have it now. Long waits and then quick loads can be caused by the fact that you have to wait for a new server to spin up to handle your request.

maxbear
09-06-2001, 10:29 AM
Thanks a lot for all of you.

I just add 1GB RAM to the server. The server load faster now comapre with before. But the RAM usage is continous to grow, this morning, it's around 650 RAM, and now, it's 850 RAM. I afraid, I need to add RAM again very soon.

valkaryn
09-06-2001, 12:33 PM
Max,

Either you've opened the door to more traffic and are just seeing the actual demand, OR you may have a memory leak on your system. Are you running anything besides Apache? Have you installed custom modules in Apache? Do you have JRE (java) running on your server? Do you have a custom CGI (shopping cart, ecommerce service) running on your site?

A memory leak is problem that occurs when a program obtains memory space from the system, but doesn't release it when it's done using it. If it does it often you will see the memory gobbled up rapidly. If it does it every once in a while, you may not relate the memory usage to the program that has the memroy leak in the first place.

Whatchya got running on that thang?

jks
09-06-2001, 12:35 PM
Originally posted by maxbear
I just add 1GB RAM to the server. The server load faster now comapre with before. But the RAM usage is continous to grow, this morning, it's around 650 RAM, and now, it's 850 RAM. I afraid, I need to add RAM again very soon.

_How_ do you know that it is using up all your memory?

Are you sure the memory is not "used" for buffers/cache or similar - and is thus not really "used up"....

maxbear
09-06-2001, 03:54 PM
My site running mysql, php, cgi, html and images.

Most of the traffic are :

html (40%)
images (30%)
php (20%) most of them don't connect to mysql, just call for footer and header within the html page.
cgi (10%)

I have some figure of the running process, these figures are for memory usage. I am using a Dell power web 120 server. I noticed that they run some Java stuffs all the times and don't release the memory. The following is just a small part of it, it still have more processes.

Process ID Owner Size Command
998 nobody 155512 kB /usr/local/jre/bin/i386/native_threads/java -Dtomcat.home=/u ...
999 nobody 155512 kB /usr/local/jre/bin/i386/native_threads/java -Dtomcat.home=/u ...
1005 nobody 155512 kB /usr/local/jre/bin/i386/native_threads/java -Dtomcat.home=/u ...
1006 nobody 155512 kB /usr/local/jre/bin/i386/native_threads/java -Dtomcat.home=/u ...
1108 nobody 155512 kB /usr/local/jre/bin/i386/native_threads/java -Dtomcat.home=/u ...
1025 nobody 155512 kB /usr/local/jre/bin/i386/native_threads/java -Dtomcat.home=/u ...
1057 nobody 155512 kB /usr/local/jre/bin/i386/native_threads/java -Dtomcat.home=/u ...
1058 nobody 155512 kB /usr/local/jre/bin/i386/native_threads/java -Dtomcat.home=/u ...
1060 nobody 155512 kB /usr/local/jre/bin/i386/native_threads/java -Dtomcat.home=/u ...
1061 nobody 155512 kB /usr/local/jre/bin/i386/native_threads/java -Dtomcat.home=/u ...
1062 nobody 155512 kB /usr/local/jre/bin/i386/native_threads/java -Dtomcat.home=/u ...
1063 nobody 155512 kB /usr/local/jre/bin/i386/native_threads/java -Dtomcat.home=/u ...
1065 nobody 155512 kB /usr/local/jre/bin/i386/native_threads/java -Dtomcat.home=/u ...

..........

I also include the "top" info here again. These figure shows what's going on with my system afer I upgrade to 1GB RAM, php 4.06 and add APC cache to php.

2:43pm up 16:08, 1 user, load average: 0.16, 0.14, 0.14
250 processes: 236 sleeping, 1 running, 1 zombie, 12 stopped
CPU states: 6.7% user, 5.6% system, 0.0% nice, 87.5% idle
Mem: 1036068K av, 930832K used, 105236K free, 750320K shrd, 553784K buff
Swap: 265032K av, 0K used, 265032K free 195160K cached

You can see, the memory usage is always around 900 MB. I just want to know is it normal for a 100K - 150K vistors per day site to use such a large amount of memory?

jks
09-06-2001, 04:22 PM
Originally posted by maxbear
You can see, the memory usage is always around 900 MB. I just want to know is it normal for a 100K - 150K vistors per day site to use such a large amount of memory?

You're reading the top info wrong.

Actually, 66% of your ram is "free".

Linux uses all the RAM it can for buffers and caches (to speed up f.ex. disk accesses) - the RAM is however not "used" in the normal sense. It is available for programs if they need it.

So basically, you have plenty and lots of RAM.

jks
09-06-2001, 04:24 PM
Originally posted by jks


You're reading the top info wrong.

Actually, approx 850 megs of your ram is "free".

Linux uses all the RAM it can for buffers and caches (to speed up f.ex. disk accesses) - the RAM is however not "used" in the normal sense. It is available for programs if they need it.

So basically, you have plenty and lots of RAM.

huck
09-06-2001, 05:23 PM
Take a look at my post here.....
Long winded info about linux memory usage....
http://www.webhostingtalk.com/showthread.php?s=&threadid=15129&highlight=understanding+linux+memory

Abu Mami
09-07-2001, 12:42 AM
Originally posted by jks
I have an idea for maxbear...

Try installing APC -- it will really speed your server, as those PHP pages are slowing everything down for you!

We have used that technique on several large sites - and it really works great!

Sorry, but what is APC?

spock
09-07-2001, 05:10 AM
Originally posted by Abu Mami
Sorry, but what is APC?

Alternative PHP-cache
http://apc.communityconnect.com/about.html

It's a cache for compiled PHP pages. I just found out about it myself so I haven't tried it but it sure looks like a good idea.

eva2000
09-07-2001, 05:59 AM
Originally posted by spock


Alternative PHP-cache
http://apc.communityconnect.com/about.html

It's a cache for compiled PHP pages. I just found out about it myself so I haven't tried it but it sure looks like a good idea. i tried APC 1.08 but it gave my memory leaks with 600+ MB httpd processes! on my server haven't tried the latest versions though