Website has become slower on a VPS, was much fast on a shared host. What’s wrong?

Posted on

Website has become slower on a VPS, was much fast on a shared host. What’s wrong? – Managing your servers can streamline the performance of your team by allowing them to complete complex tasks faster. Plus, it can enable them to detect problems early on before they get out of hand and compromise your business. As a result, the risk of experiencing operational setbacks is drastically lower.

But the only way to make the most of your server management is to perform it correctly. And to help you do so, this article will share nine tips on improving your server management and fix some problem about apache-2.2, php, performance, hosting, vps.

My shared host suspended my website stating system overload, so I moved my website to a VPS which has 4GB RAM. But for some reason the website has become very slow.

This is the vmstat output –

procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 1  0      0 3050500      0      0    0    0     0     1    0    0  0  0 100  0  0

Here’s the Apache Benchmark output for a STATIC html page I ran on the server itself –

Benchmarking www.ask-oracle.com (be patient)...apr_poll: The timeout specified has expired (70007)
Total of 20 requests completed

Update:

Server Config:

  • List item
  • Centos 5.6
  • 4 cores cpu
  • 4 GB RAM
  • LAMP stack with APC
  • WordPress
  • Only one website

It takes almost double time to load now, same website was much fast on shared hosting. I know I need to tweak some settings but have no clue where to start from?

I have already tried to optimize apache, mysql etc.

Update 2:

CPU usage is low, see uptime output:

 11:09:02 up 7 days, 21:26,  1 user,  load average: 0.09, 0.11, 0.09

Update 3:

When I load any webpage, browser shows “Waiting” for a long time and then page loads quickly. So I suspect server can accept only limited connections and holds extra connections in a waiting state. How to check this?

Update 4:
Following is the output on executing netperf

TCP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to localhost.localdomain (127.0.0.1) port 0 AF_INET
Recv   Send    Send
Socket Socket  Message  Elapsed
Size   Size    Size     Time     Throughput
bytes  bytes   bytes    secs.    10^6bits/sec

 87380  16384  16384    10.00    9615.40
[root@ip-118-139-177-244 j3ngn5ri6r01t3]#

Here are the Apache MPM settings from httpd.conf, do they look okay?

<IfModule worker.c>
StartServers       5
MaxClients        100
MinSpareThreads    50
MaxSpareThreads    250
ThreadsPerChild     125
MaxRequestsPerChild  10000
ServerLimit     100
</IfModule>

Solution :

My guess : your shared host did not limit your CPU and was even faster than your current VPS. Also it might be what happens with a lot of VPS, which is overselling. Your VPS is hosted on a shared machine and you might not get all of your CPU cycles. Also there could be very poor I/O or a slow internet connection.

You do not know what is happening above your VPS on the host machine, try to find it out :).

What are your apache MPM settings in httpd.conf? I tried connecting to your server, and it takes 5-10 seconds to even send a header back.

Badly written wordpress plugins and themes can hurt performance, but typically they’ll be spewing errors in log files or churning mysql/disk access, which doesn’t seem to be happening for you.

Update:
You might try running prefork instead of worker, especially with your 4GB of RAM. WordPress recommends that here:
http://codex.wordpress.org/High_Traffic_Tips_For_WordPress

run netstat -anp | grep TIME_WAIT | wc -l

This will return number of requests waiting for a response from apache. If this number is unusually high, tweak apache settings so that it can handle more requests per second without compromising overall server performance.

Setup apache preform MPM settings as follows:

<IfModule prefork.c>
StartServers       25
MaxClients        500
MaxRequestsPerChild  10000
ServerLimit     500
</IfModule>

Leave a Reply

Your email address will not be published.