Portal Home > Knowledgebase > Articles Database > Why my server load average is high?


Why my server load average is high?




Posted by ennoia89, 08-30-2010, 06:30 PM
Please help me. Why is my load average high? Output of the top: top - 00:18:58 up 4:38, 1 user, load average: 25.27, 21.90, 22.90 Tasks: 50 total, 9 running, 41 sleeping, 0 stopped, 0 zombie Cpu(s): 73.0%us, 26.0%sy, 0.0%ni, 1.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st Mem: 2359296k total, 302076k used, 2057220k free, 0k buffers Swap: 0k total, 0k used, 0k free, 0k cached PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 10179 mysql 15 0 341m 37m 3972 S 7.3 1.6 18:08.87 mysqld 21763 nobody 19 0 423m 17m 2380 S 3.7 0.8 0:55.30 httpd 28060 quizmast 18 0 0 0 0 R 3.3 0.0 0:00.10 php 28200 quizmast 17 0 0 0 0 R 3.0 0.0 0:00.09 php 28046 quizmast 17 0 133m 13m 7320 R 2.7 0.6 0:00.08 php 28049 quizmast 17 0 133m 13m 7364 R 2.7 0.6 0:00.08 php 28056 quizmast 17 0 133m 13m 7320 R 2.7 0.6 0:00.08 php 15441 nobody 18 0 421m 14m 2384 S 1.0 0.6 0:37.73 httpd 27655 root 20 0 31224 4516 1464 R 0.7 0.2 0:00.04 restartsrv_imap 13946 nobody 19 0 418m 9788 2068 S 0.3 0.4 0:05.15 httpd 13947 nobody 20 0 418m 10m 2380 S 0.3 0.5 0:06.71 httpd 13949 nobody 19 0 422m 14m 2092 S 0.3 0.6 0:12.36 httpd 18313 nobody 18 0 488m 17m 2092 S 0.3 0.8 0:40.15 httpd 19681 root 15 0 39344 7436 1784 S 0.3 0.3 0:01.31 tailwatchd 26594 root 15 0 12612 1212 916 R 0.3 0.1 0:00.01 top 1 root 15 0 10352 740 620 S 0.0 0.0 0:01.08 init 7854 root 15 -4 12604 668 352 S 0.0 0.0 0:00.00 udevd 10114 root 15 0 5908 612 488 S 0.0 0.0 0:00.07 syslogd 10128 root 15 0 62624 1208 652 S 0.0 0.1 0:00.09 sshd 10139 root 18 0 21644 904 692 S 0.0 0.0 0:00.00 xinetd 10152 root 18 0 11932 1404 1160 S 0.0 0.1 0:00.01 mysqld_safe 11300 mailnull 18 0 64268 1376 704 S 0.0 0.1 0:00.02 exim 11674 root 18 0 47528 9028 1428 S 0.0 0.4 0:00.06 tailwatchd 13918 nobody 15 0 80932 2740 816 S 0.0 0.1 0:00.00 httpd 13919 root 20 0 38200 6416 1932 S 0.0 0.3 0:00.08 leechprotect 13944 root 17 0 80932 2012 120 S 0.0 0.1 0:00.00 httpd 14030 root 15 0 104m 37m 2288 S 0.0 1.6 0:01.87 spamd 14091 nobody 18 0 420m 12m 2088 S 0.0 0.5 0:17.19 httpd I has only one website running that is a Facebook App. Sometimes the pages takes 0.001 seconds to load the page and sometimes >0.71 seconds or more, doing nothing different. I don't find any .php that takes a lot to load, despite of 73.0%us Here is the my.cnf: [mysqld] safe-show-database tmp_table_size = 128M max_heap_table_size = 32M query_cache_limit=1M query_cache_size=32M query_cache_type=1 max_connections=200 collation_server=utf8_unicode_ci character_set_server=utf8 delayed_insert_timeout=40 interactive_timeout=10 wait_timeout=30 connect_timeout=20 thread_cache_size=64 key_buffer=32M join_buffer=1M max_connect_errors=20 max_allowed_packet=8M table_cache=2048 record_buffer=1M sort_buffer_size=1M read_buffer_size=1M read_rnd_buffer_size=1M thread_concurrency=2 ## Number of CPUs x 2 myisam_sort_buffer_size=16M key_buffer_size=16M

Posted by DiegoRBaquero, 08-30-2010, 06:34 PM
Yea, and those processes are taking all the CPU. If you check MySQL is using 7.3, httpd is using 3.7. Each php is like 3 in average, plus the other processes... I guess bad coded app... may I know what server and provider?

Posted by netmar, 08-30-2010, 08:16 PM
Have you checked the output of your logs? Take a look in /var/log/messages and at the output of dmesg, because something here is clearly not adding up. It hasn't affected your performance yet (700 ms is a perfectly acceptable load time for a php-generated page), but I can only think that there's a process running that's not showing up in top. You might also check netstat -anp and look for network connections that shouldn't be there.

Posted by ennoia89, 08-30-2010, 08:17 PM
I has updated my php files and now the load average is below 3. I'm not sure what was causing that, because I have modified some very little changes. One of them was to show a special page if the user_agent was Mediapartners-Google (for Adsense), because Google connecting to Facebook App that requires login doesn't make any sense and maybe gets a infinite loop or some other paranoia. My provider is Hostgator, by the way. thank you

Posted by ennoia89, 08-31-2010, 07:58 AM
I wake up today and the load average is >10 again. I have seen the logs netmar, but I don't see nothing strange ... Maybe next post I show you the logs. I see a error log and there's a lot of: [31-Aug-2010 13:33:54] PHP Fatal error: Out of memory (allocated 1572864) (tried to allocate 7680 bytes) in ... (diferent files). But the top says: top - 13:52:49 up 18:12, 1 user, load average: 10.30, 11.65, 16.08 Tasks: 58 total, 11 running, 47 sleeping, 0 stopped, 0 zombie Cpu(s): 72.9%us, 26.8%sy, 0.0%ni, 0.3%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st Mem: 2359296k total, 301284k used, 2058012k free, 0k buffers Swap: 0k total, 0k used, 0k free, 0k cached PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 10179 mysql 15 0 341m 38m 4152 S 7.7 1.7 48:52.17 mysqld 28376 nobody 19 0 422m 15m 2092 S 6.0 0.7 0:29.32 httpd 8084 quizmast 18 0 133m 14m 7528 R 3.7 0.6 0:00.11 php 8088 quizmast 18 0 131m 11m 6308 R 2.0 0.5 0:00.06 php 8090 quizmast 18 0 132m 12m 6724 R 2.0 0.6 0:00.06 php 9427 nobody 18 0 486m 17m 2380 S 0.7 0.8 0:19.24 httpd 1 root 15 0 10352 740 620 S 0.0 0.0 0:01.22 init 1857 root 15 0 104m 37m 2284 S 0.0 1.6 0:02.26 spamd 1970 root 15 0 105m 37m 1612 S 0.0 1.6 0:12.42 spamd So there's a lot of free memory, how can i fix this?

Posted by ITSource, 08-31-2010, 08:04 AM
What is your maximum memory? If you're only having 1 site, its probably a DDoS Attack.

Posted by Techbrace, 08-31-2010, 10:45 AM
You're getting this error message because your PHP Application is using more memory than the Limit you have set in your php.ini file. (Look for the value of directive memory_limit) You can consider increasing the value if it's set to too low. With regards to the load issue, you should check if a certain website is getting too many hits or a certain DB is having too many connections. It's likely that one or both of them are causing the load issue in your case.

Posted by praveenkv1988, 08-31-2010, 10:50 AM
Check your bandwidth usage. Also, check the mysql queries. They may not be optimized.

Posted by mixmox, 08-31-2010, 11:10 AM
can toy tell me more about : They may not be optimized how can i check and optimize mysql ?

Posted by inspiron, 08-31-2010, 09:27 PM
Its definitely sounds you need to optimize the Apache and Mysql .Check the mysql processes with #mysqladmin processes.

Posted by ennoia89, 09-01-2010, 02:09 AM
Probably I'm wrong, but I think that my query's are optimized. I have the right index on the right place, and I'm "debugging" the web showing the query time after the execution, and don't take more than 0.01, but maybe I'm forgotten some query. How can I know what is wrong when I'm seeing the mysql processes? @TechBrein: Thanks, i swiched the memory limit. But that memory limit is for each php process, isn't it? Can be there any memory limit that I'm not considering? About the connections of the BD you're right, some days ago sometimes appears: "too many connections". In some pages I'm doing about 7 query's, I have to configure something? thanks

Posted by Hillockhosting, 09-01-2010, 02:16 AM
Check out the sar results. Also check if cpanellog is running Use rcpulimt to limit the cpu use. This would be helpful.

Posted by ramnet, 09-01-2010, 02:51 PM
Looks to me like you are running PHP as a CGI with either suphp or suexec. That alone will add significant overhead to every php request...since you are using apache and you're on a vps, just reconfigure it to use mod_php instead and it should solve your problem.

Posted by Techbrace, 09-01-2010, 03:04 PM
Increase the memorylimit only if its set to too low as I said earlier. And yeah, it's the max memory a PHP script can consume. The recommended value is 32MB. Make sure your scripts close Mysql connections once it's done with Mysql queries rather than waiting for PHP to close it at the end of script execution. Since your server is not shared and running just one website, you can consider loading PHP as a module as someone stated above. You don't really need PHP to run as suexec. In fact, it's recommended to keep PHP susexec off if you have only one account on the server. Furthermore, It looks like you don't swap enabled on your server. Run the following command to enable it: swapon -a

Posted by FastServ, 09-01-2010, 04:15 PM
Memory/Disk IO looks fine. You are CPU bound. Is this a VPS? Your performance (especially CPU) is affected by other users, so that could explain the seemingly random load variations.

Posted by ennoia89, 09-01-2010, 05:31 PM
Thanks ramnet That works, I change from suphp to dso. Now I get another problem .. "fork failed: cannot allocate memory". But well, I will try to get more memory. I think we can conclude this post as SOLVED. Thanks all!



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
BIRD and iBGP (Views: 585)