Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I noticed in cpanel that server load over 1.0 sometimes and that causes my website to take a long time to respond!!

I am wondering now what to do. Should I limit access to my website through .htaccess when the server load gets high, or is there better advice?

My website is running php scripts and I have about 1000 visitors per day.

I did some script profiling and I saw that it uses about 35 mysql query for main page and for others sometimes gets over 50 mysql queries.

share|improve this question

migrated from Dec 22 '11 at 14:44

This question came from our site for professional and enthusiast programmers.

Is that a shared host? – check123 Dec 22 '11 at 14:38
try reducing the number of mysql queries in the home page.. the server load one seems to be normal.. – Manigandan Arjunan Dec 22 '11 at 14:42
@check123 no it's a VPS! – Аймен Ахмед Dec 22 '11 at 14:50
@Ampere are those bunch of mysql queries cause my sever load high? and btw most of them are important! – Аймен Ахмед Dec 22 '11 at 14:54
As mentioned by Ampere, in most circumstances, it is the DB which is the bottleneck. Script execution should not be a load (given your circumstance and provided they are not highly computational). Try restructuring your tables to reduce the number of queries and also the JOINS those queries require; JOINS are a real pain for the system, better if you can get rid of them. Alternatively, look towards some on demand scalable systems like Cloud Computing. – check123 Dec 22 '11 at 14:59

the number of mysql connections or queries will always perform with the load of the site. It the connection or queries are high in number it will always result in server load. Try reducing the mysql request by using mysql join funcntions and table indexes.

share|improve this answer

In addition to Ampere's answer, you will probably want to add the following lines to /etc/my.cnf (the MySQL configuration file):

slow_query_log = 1
slow_query_log_file = /var/log/mysql-slow.log
long_query_time = 8
# The next parameter is optional, if you want to log all the queries that don't use indexes

Good luck!

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.