1

I've setup a new VPS hosting, to run a Drupal website but it is extremely slow.

It is Ubuntu 10, Apache, php5.2

I've enabled Multi-Processing Module (MPM) module and configured it as follows:

StartServers 4 MinSpareServers 2 MaxSpareServers 10 ServerLimit 20 MaxClients 20 MaxRequestsPerChild 200

But it is still too slow... it is a VPS slice: RAM 256MB BW 150GB

what could be the reason ? thanks

Update (Swaps)

             total       used       free     shared    buffers     cached
Mem:           245        220         24          0          1         26
-/+ buffers/cache:        192         52
Swap:          511        110        401

5 Answers 5

3

Make certain you are not regularly accessing swap space for anything - disk I/O is a very common bottleneck, particularly on Xen VPS' with relatively small RAM allocations (assuming you're at Slicehost, given your mention of using a "slice").

While having swap space seems like a plus (particularly because your VPS doesn't sputter and die when you try to run multiple memory-hungry applications like Apache w/dynamic PHP content and MySQL) it will quickly lead to substandard performance, particularly if you're on a VPS host node full of others doing the same thing.

Edit: I would highly recommend the LowEndBox Wiki (LowEndBox focuses upon virtual environments with memory allocations in the same neighborhood as your own) for optimization tips to get Apache and MySQL running smoothly within your virtual environment.

16
  • @danlefree How do I check if the swap memory is used ?
    – aneuryzm
    Nov 4, 2010 at 13:28
  • @Patrick - Run free -m
    – danlefree
    Nov 4, 2010 at 15:28
  • @danlefree I've updated my question with the results. How should I interpret the numbers ? thanks
    – aneuryzm
    Nov 4, 2010 at 16:12
  • @Patrick - It appears as though swap space is being allocated, though it may be held without being used. Run vmstat -a 1 and watch the si and so values while you request a page on your site to see how heavily swap is being relied upon (si and so will remain at 0 if your server is not actively using swap).
    – danlefree
    Nov 4, 2010 at 16:29
  • @danlefree So, they are usually 0, but when I visit a page they both change (i.e. 0 0, 312 0, 324 1516, 36 6768, 0 0). So I guess the server is using swap.
    – aneuryzm
    Nov 4, 2010 at 16:36
2

It's almost definitely not an Apache configuration issue, but you need to profile your application to find out where its time is being spent instead of blindly guessing at what the problem is. Xdebug is a popular tool for PHP profiling, and turning on the MySQL slow query log may help if MySQL is running inside your VPS.

Part of the problem with VPS environments is that since your VM doesn't really know what it's getting in terms of resources, it's practically impossible to determine if your server hardware is heavily oversubscribed. That makes things trickier.

2
  • uhm ok thanks. But the point is that I've just setup the VPS, installed everything.. so there is not a lot to investigate. What could be the reason of php running slow.. or maybe Drupal running slow on a server ?
    – aneuryzm
    Nov 4, 2010 at 13:26
  • Code isn't magic, it does things. The entire point is to figure out where it's running slow so you can figure out why it's running slow. As you said, you have absolutely nothing else to go on. Nov 4, 2010 at 14:39
1

First try the standard mpm settings:

<IfModule mpm_prefork_module>
    StartServers          5
    MinSpareServers       5
    MaxSpareServers      10
    MaxClients          150
    MaxRequestsPerChild   0
</IfModule>

Maybe you should also have a look at this: http://articles.slicehost.com/2010/5/20/configuring-the-apache-mpm-on-debian You should also reduce the KeepAlive settings.

What about the RAM? Are you sure you have enough and the server is not swapping? (free -m)

You should also check your database, it's relative easy with the Tuning Primer script: http://www.day32.com/MySQL/

Btw. on a Server with just 256MB RAM i would advise you to use a other Webserver like Lighttpd or Nginx (with PHP-FPM).

4
  • I've changed the values, but it is still the same. The server is fast if I visit a html page. It is a php/mysql problem I guess
    – aneuryzm
    Nov 4, 2010 at 13:35
  • I've run the script you suggested but this is what I get - INITIAL LOGIN ATTEMPT FAILED -
    – aneuryzm
    Nov 4, 2010 at 13:36
  • You have to set your login variables first in ~/.my.cnf
    – zaub3r3r
    Nov 4, 2010 at 13:41
  • 1
    As you can see your Server is swapping, try to disable Apache modules which you don't need. However i think that 256MB RAM are not enough to run a well performing LAMP-setup. Databases need cache and Apache also isn't a saveaholic. You should think about switching to Lighttpd, it's easy to setup and works well with less RAM. You don't need to worry about the rewrite-stuff, there are enough examples on the internet. I can't tell you why the same setup works on a other VPS, maybe different virtualisation or other hardware (faster harddrives ;) )
    – zaub3r3r
    Nov 4, 2010 at 17:00
0

I'm thinking it might be your database layer, does this connect to a shared database somewhere or is the database local to the server?

2
  • Start controlling database layer, and make sure you run a php byte code cacher like xcache
    – 3molo
    Nov 4, 2010 at 12:48
  • I've installed mysql (it is local). Very simple installation as I always did before on other VPS.
    – aneuryzm
    Nov 4, 2010 at 12:48
0

Make sure that localhost refers to the same vhost configured for external access and try some measurements against urls within http://localhost/ (e.g. browser over ssh tunnel, browser running on virtual server, or just write a php script to grab some urls) that should allow you to identify if there is throttling being applied outside your virtual server or whether the problem is with your server.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .