help with apache (server is slow)

daniel

Verified User
Joined
Dec 5, 2005
Messages
14
hi,
i have a new server and i dont know alot about apache
the server is a bit slow i know that i shold configure the apache but i dont know what is the best settings for it.
the server is installed with my sql 4.1.12 and phph 4.4.1 also

the server setting :
DUAL XEON 2.8G FSB 800
4GB DDR 400 REG/ECC
2 x 160 GB
DirectAdmin
LINUX centos

i have apache 1.3.34
the apache settings are:
RLimitMEM 350401386
RLimitCPU 300
ServerType standalone
ServerRoot "/etc/httpd"
LockFile /var/run/httpd.lock
PidFile /var/run/httpd.pid
ScoreBoardFile logs/apache_runtime_status
ResourceConfig /dev/null
AccessConfig /dev/null

Timeout 10
KeepAlive On
MaxKeepAliveRequests 50
KeepAliveTimeout 5
MinSpareServers 5
MaxSpareServers 20
StartServers 10
MaxClients 2000
MaxRequestsPerChild 0

what should i change plz help me?
thx daniel
 
Are you sure that it is apache that is slow? What exactly do you mean by slow, is it slow to produce a page, is it slow downloading a file?

It looks like you have plenty of horsepower to run apache at an acceptable speed. Have made sure other network services aren't slow as well, such as ssh or ftp? Another thing to check, is that you don't have some runaway process running the server sucking all the CPU away from all the other services. Use the top command to see if something is using too much CPU.

Another thing to look at, is to make sure that you have DNS working properly, it can add a lot of latency if it has to do a lookup and it times out.
 
i can see in the top big amount of apache porcesses
the pages are not slow but the load averge is high 2.00+
and it can get to more than 10.
and i think that the file httpd.conf is not configured good.
what do you think of my httpd.conf file is it configured good ?
as you can see alot of httpd...

30485 czben1 15 0 147m 137m 5820 S 22.0 3.4 368:44.11 hlds_i686
14287 apache 15 0 232m 48m 34m S 14.1 1.2 0:20.73 httpd
26192 apache 15 0 232m 35m 21m R 12.5 0.9 0:02.44 httpd
14252 apache 15 0 233m 46m 32m S 9.9 1.1 0:20.47 httpd
14333 apache 15 0 233m 49m 35m R 9.9 1.2 0:23.35 httpd
14448 apache 16 0 233m 47m 33m S 9.5 1.2 0:29.93 httpd
25364 apache 15 0 232m 42m 28m S 8.9 1.1 0:19.24 httpd
14650 mysql 15 0 924m 164m 2712 S 8.9 4.1 0:00.27 mysqld
14643 mysql 18 0 924m 164m 2712 S 8.6 4.1 0:00.26 mysqld
14649 mysql 18 0 924m 164m 2712 R 8.6 4.1 0:00.26 mysqld
14203 apache 15 0 233m 48m 34m S 7.9 1.2 0:23.19 httpd
14387 apache 15 0 233m 48m 33m S 7.9 1.2 0:24.56 httpd
24843 apache 15 0 233m 44m 30m S 7.9 1.1 0:23.07 httpd
14669 mysql 17 0 924m 164m 2712 R 6.2 4.1 0:00.19 mysqld
14314 apache 16 0 234m 50m 35m R 5.3 1.3 0:22.95 httpd
14142 apache 15 0 234m 45m 29m S 3.3 1.1 0:15.29 httpd
14440 apache 15 0 233m 49m 35m S 3.3 1.2 0:29.02 httpd
8881 apache 15 0 232m 42m 28m S 3.3 1.1 0:09.37 httpd
14667 mysql 16 0 924m 164m 2712 S 3.3 4.1 0:00.10 mysqld
14010 apache 15 0 233m 45m 31m S 3.0 1.1 0:27.08 httpd
14415 apache 15 0 246m 59m 32m R 3.0 1.5 0:21.27 httpd
14289 apache 15 0 233m 48m 34m S 2.6 1.2 0:18.86 httpd
25351 apache 15 0 232m 45m 31m S 2.6 1.1 0:17.65 httpd
25390 apache 15 0 232m 42m 28m S 2.3 1.0 0:12.80 httpd
14077 apache 16 0 233m 52m 38m S 2.0 1.3 0:24.96 httpd
8896 apache 16 0 233m 42m 26m S 2.0 1.0 0:10.63 httpd
16579 root 16 0 3148 1356 744 R 1.6 0.0 0:54.81 top
12685 apache 15 0 232m 26m 13m S 1.6 0.7 0:00.32 httpd
15552 root 16 0 3700 1864 464 R 1.3 0.0 51:17.34 top
12625 apache 16 0 231m 23m 11m S 1.3 0.6 0:00.08 httpd
14639 mysql 15 0 924m 164m 2712 S 1.3 4.1 0:00.04 mysqld
14196 apache 15 0 233m 52m 37m S 1.0 1.3 0:23.82 httpd
25389 apache 15 0 233m 44m 30m S 1.0 1.1 0:14.09
httpd


what can i do plz help.
thx
 
Last edited:
You do have a problem, those httpd and mysqld processes are using a lot of CPU. As far as your apache settings, that is hard to say, each server will be different depending on how it is used. This is what I use:
Code:
Timeout 300
KeepAlive On
MaxKeepAliveRequests 500
KeepAliveTimeout 5
MinSpareServers 5
MaxSpareServers 20
StartServers 8
MaxClients 450
MaxRequestsPerChild 1000

What do your server logs say? Are you getting any errors?

What kind of web/php application is using MySQL, it could be poorly written, and is causing high loads. Also, the half-life server as you can tell is using a lot of resources as well, I don't know enough about it to know if it interferes with Apache and MySQL other than using up resources.

One more thing, what was the output from top, dealing with memory/swap? If you were swapping heavily, I can see that causing a huge slow down. Of course I would then expect to see pdflush and kswapd0 higher up on the list, which we are not.
 
toml said:
You do have a problem, those httpd and mysqld processes are using a lot of CPU. As far as your apache settings, that is hard to say, each server will be different depending on how it is used. This is what I use:
Code:
Timeout 300
KeepAlive On
MaxKeepAliveRequests 500
KeepAliveTimeout 5
MinSpareServers 5
MaxSpareServers 20
StartServers 8
MaxClients 450
MaxRequestsPerChild 1000

What do your server logs say? Are you getting any errors?

What kind of web/php application is using MySQL, it could be poorly written, and is causing high loads. Also, the half-life server as you can tell is using a lot of resources as well, I don't know enough about it to know if it interferes with Apache and MySQL other than using up resources.

One more thing, what was the output from top, dealing with memory/swap? If you were swapping heavily, I can see that causing a huge slow down. Of course I would then expect to see pdflush and kswapd0 higher up on the list, which we are not.

the server is used for web hosting.
i dont see any errors in the logs.
swap is not being used.
top - 22:35:17 up 31 days, 6:20, 2 users, load average: 2.02, 2.15, 2.19
Tasks: 465 total, 2 running, 462 sleeping, 0 stopped, 1 zombie
Cpu(s): 17.9% us, 6.6% sy, 0.0% ni, 74.5% id, 0.3% wa, 0.1% hi, 0.6% si
Mem: 4150000k total, 3638080k used, 511920k free, 36548k buffers
Swap: 4096564k total, 192180k used, 3904384k free, 921096k cached

so if i change the httpd.conf like yours it will be better?
thx X 10
 
I can't say it will be better, that really depends on a lot of factors. It works fine for me. You can give it a try.
 
where can i find info that can explian
how is the best to configure my server ?

thx for ak the help
 
MaxClients 2000
MaxRequestsPerChild 0

gives apache a licence to use a 'lot' of resources on your server, you have no limit on requests per child allowing mem leaks to reign terror and the max clients is also very high. Both of these allow very high memory usage and possible disk thrashing but you didnt post your mem usage and swap usage so cant comment on that.
 
i dont think that the memory is the problem, it was once i had only 2 gig mem but when i upgraded to 4 gig the server stopped using swap and currently using from 3.5 to 3.9 mem

about the max client
i put it so high so clients will never will be locked out i want the my server will be as much as possible avilable to the users i cannot allow them to see "page can not be displayed"

i tried to use toml configuration and it didnt really helped...
 
I will take your word for it since 4gig is a beefy amount.

Try the following.

Timeout 10 -> 30
KeepAlive On -> Off
MaxKeepAliveRequests 50
KeepAliveTimeout 5
MinSpareServers 5
MaxSpareServers 20
StartServers 10
MaxClients 2000
MaxRequestsPerChild 0 -> 1000

The problem could well be with mysql tho, if that has problems it could slow down apache even without itself showing high usage.
 
thx i will chack it.

one last thing

like i said i have 4 giga ram
how much is recommend to give to apache

this is what i have:
RLimitMEM 350401386
RLimitCPU 300

is it good ?

thx for all the help
 
Last edited:
we have 40 users
most of them small sites
most of them use mysql and that is it


what do you recommend us to do ?
about the memory use for the apache like i said
and the other config ...

thx very much to all.
 
Last edited:
Wow, thats a lot of activity for only 40 users. You're really gonna need to let a systems admin go in and look up close and personal to find out what's going on.

If you'd like me to take a look, let me know via PM or email.

Joe
 
Looks to be high traffic forums, which leads to a possible mysql problem again.
 
it might be so

before i configure mysql the load average was very high

those are the setts i changed on my mysql

wiat_timeout = 10
max_connetions = 500

interactive timeout = 10
key_buffer_size = 749998080

have_query_cache = yes
query_cache_size = 99999744

table_cache = 200

read_rnd_buffer_size = 2000000

tmp_table_size = 64000000
delayed insert timeout = 1

what do u say?
is it possible the problem is here althogh it seems that apache is the one which shown all over the top table?
 
the best way to find the problem is snooping your processes and logs when problems happen, in my case everything would be fine then suddenly system cpu % would go high for a few secs and then load avg would shoot to 5+ followed by 100s of apache children starting up. Mysql would sit there on 0% usage. Restarting httpd would recover it so all obvious factors would point to apache when it was in fact mysql to blame. It is hard to fix these things since it seems common for people to keep their config's and solutions private, I found a page detailing my problem exactly and the author simply said the cause is a bad my.cnf, but he didnt refer to any part of it or specifics and of course my.cnf has tons of settings so it still could have been 1 of 100s of settings or a combination.
 
ok i see...


i can also say according to chrysails that i not once saw on the top the mysql and apache on 99 cpu (no at the same time and only for a few seconds) which casued the load average pop up.
It might happened more since i see the top only every second and not every milisecond....

but again i posted my mysql config on my last post, maybe it can help to solve the problem... or if there is anything else u need to see in order to figure it out...

thanks
 
Back
Top