I've lighttpd on Ubuntu 10 on a 256MB RAM VPS. My goal is to completely avoid swapping. I'm running a Drupal webste with some images, shopping cart (no videos.. quite low estimated traffic).

So.. still the system is swapping memory. I was wondering if I should configure now a MPM module with Lighttpd as I did with Apache (prefork). Is there some configuration to do with Lighttpd as well ? If not, any tip ?

Also uploading files with drupal (through php) takes quite long... around 20 seconds for only 300kbs... However, when I run info.php, it displays immediately.. it seems only Drupal is slow.

These are my php settings: Memory limit 128MB post max size 64MB

(I would prefer to not set memory limit to only 64MB because some Drupal modules require 128M. Do you think this is the issue ?)


  • 1
    What is the output of free when you DON'T have a web server running? – Andrew M. Nov 7 '10 at 16:06
  • @Redmumba Good question. Swapping is 30M, Free 481M.. so what's the issue ? mysql ? – aneuryzm Nov 7 '10 at 16:59

Linux will swap pretty readily by default so as to make the best use of available memory. You can control how readily this happens by modifying the "vm.swappiness" kernel parameter. By default it is set to 60, but if you tune this down to 0, the system will only swap when absolutely necessary.

sysctl -w vm.swappiness=0

Bear in mind, however, that Linux usually does a pretty good job of handling swapping already and your slowness may be caused by other issues, up to and including the other users that you share the physical hardware with.

| improve this answer | |
  • do I need to restart unix or just run the command you gave me ? I can try to see if the server goes faster or not.. – aneuryzm Nov 7 '10 at 17:30
  • Nope. In fact, it is the complete opposite -- it will become effective immediately but will reset upon a reboot. In order to make the change permanent across reboots, you'll need to add the parameter to /etc/sysctl.conf. – ktower Nov 7 '10 at 23:50

Slow down from swapping is only when memory is full and you're writing heavily to disk. If you still have free memory you generally have no reason to worry about swapping.

| improve this answer | |
  • ok, what if swapping occurs for each client request ? I'm noticing this when I run a Drupal page. – aneuryzm Nov 7 '10 at 23:11
  • Can maybe the main issue be that while developing I'm not compressing all css and javascript files into 2 files ? In other terms.. each page performs multiple requests (ie. default drupal 5..6 css files). Probably this is the main reason.. the requests are triplicated – aneuryzm Nov 7 '10 at 23:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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