Pages

Wednesday, 2 April 2014

While Handling Site loading slow issue!

Hey Guys,

If any client complaints that the site loading slow for him, then it's not good practice to reply him like "it's loading fine from our end!". There are a few reasons that make the site load slow

1. Server load

The first thing you need to make sure that, the server load is not high. There are a few commands that can help you to monitor the same

# nice top -c
# sar

If it's not showing any spike in his logs, then you can move to the next step.

2. Apache connections

Make sure there are not heavy connections to port 80. If it's an OpenVZ VM then 500 connections to that VM is a little higher value.
Make sure there are no DDos, you can use below commands to check the connections to the server

# netstat -plan | grep :80 | wc -l [to check the current connections to port 80]

There are lots of options are available for netstat command. You can check that, if you notice any IP having large number of connections, block him on the firewall.

3. Large number of database queries

Next, you need to check the database. Use the below command to see the current query status on MySQL

# mysqladmin proc

It will show you the current stats. If any user having large query in queue. Then kill that user process using below command

# killall -9 -v -u username

Then you can optimize that yours database that caused the issue. Using below command

# mysqlcheck --all-databases -o [To optimize all database]

Only MyIssam tables can be optimized using above command.

You can also optimize tables using PHPMyAdmin.

1. Login to WHM
2. Go to PHPMyAdmin
3. Select database
3. Select all MyIssam tables
4. There will be a drop down table at the bottom, select optimize option for that.
5. Done

It will fix the site loading issues in most of the cases.

4. Tweak Apache settings

Go to WHM » Home » Service Configuration » Apache Configuration » Global Configuration

See the values in

Server Limit (Maximum: 20,000)
Max Clients
Max Requests Per Child
Keep-Alive >> On
Keep-Alive Timeout
Max Keep-Alive Requests
Timeout

Adjust the values according to your need and current connections to the server.

5. Tune MySQL, instant.

In cPanel 11.40 MySQL tuner has been already there on the server.

Run # /usr/local/cpanel/bin/mysqltuner.pl

It will display the values that needed to be adjusted to fit for current need.

Note: If you put any large value in my.cnf file, then there is a chance to get not enough memory error on MySQL. Please be careful while adding large values like
1G/2G

No comments:

Post a Comment