Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
share|improve this question
add comment

5 Answers

up vote 3 down vote accepted

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.

share|improve this answer
    
@danlefree How do I check if the swap memory is used ? –  Patrick Nov 4 '10 at 13:28
    
@Patrick - Run free -m –  danlefree Nov 4 '10 at 15:28
    
@danlefree I've updated my question with the results. How should I interpret the numbers ? thanks –  Patrick Nov 4 '10 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 '10 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. –  Patrick Nov 4 '10 at 16:36
show 11 more comments

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.

share|improve this answer
    
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 ? –  Patrick Nov 4 '10 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. –  jgoldschrafe Nov 4 '10 at 14:39
add comment

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

share|improve this answer
    
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 –  Patrick Nov 4 '10 at 13:35
    
I've run the script you suggested but this is what I get - INITIAL LOGIN ATTEMPT FAILED - –  Patrick Nov 4 '10 at 13:36
    
You have to set your login variables first in ~/.my.cnf –  zaub3r3r Nov 4 '10 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 '10 at 17:00
add comment

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?

share|improve this answer
    
Start controlling database layer, and make sure you run a php byte code cacher like xcache –  3molo Nov 4 '10 at 12:48
    
I've installed mysql (it is local). Very simple installation as I always did before on other VPS. –  Patrick Nov 4 '10 at 12:48
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.