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

apache-2.2hostingperformancePHPvps

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>

Best Answer

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 :).