0

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.

Aaron
  • 2,968
  • 1
  • 23
  • 36
  • 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
  • A server load over 1 doesn't mean much without also telling us the number of cpu's your VPS has. – 3dinfluence Dec 22 '11 at 15:39
  • @3dinfluence just 1 cpu – Аймен Ахмед Dec 22 '11 at 16:43
  • If you only have one cpu then over 1 would indicate that you're system is waiting on something. Unless all 1000 are active at the same time you shouldn't have high server load. But I'm not a mysql expert so I can't help you too much. But my advise to you is to find the root cause of your problem and asking a question that addresses. That will get you better answers than a question about high server load. Things that you could also look into would be caching solutions like memcache and tuning mysql w/ indexes and optimization of how your app interacts with the database. – 3dinfluence Dec 23 '11 at 21:19

2 Answers2

1

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.

-2

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
log-queries-not-using-indexes

Good luck!

bizna
  • 137
  • 5