1

I noticed our web project (Drupal) runs slower when it's using memcached in the virtual box. The page load time is more the twice as fast without memcached. I haven't noticed any unnatural memcached behavior.

The virtual box is (using vagrant):

  • Debian Squeeze 607
  • 1 CPU core (ICH motherboard driver)
  • 4G ram
  • SSD drive (ICH driver)

The Drupal specific settings are:

$conf['cache_backends'][] = 'sites/all/modules/contrib/memcache/memcache.inc';
$conf['cache_class_cache_form'] = 'DrupalDatabaseCache';
$conf['cache_default_class'] = 'MemCacheDrupal';
$conf['memcache_key_prefix'] = 'oursite_';

Just to compare it to a native (non virtualized) environment - on the same project memcached improves 10-20% of performance.

Any idea? Is there anything where I could continue the investigation?

itarato
  • 129
  • 4
  • 3
    VirtualBox isn't really a production ready environment whatever Oracle says. I personally wouldn't worry about the performance a VB development environment either. – user9517 Dec 09 '13 at 16:27
  • 1
    I would think so too, however I've heard too many saying it provides the same performance - so it would be good to see what makes memcached slow in a vbox. – itarato Dec 09 '13 at 17:16
  • I doubt many (if any) people here will be able to help it's not something that is used widely by sysadmins in the manner you're using it. Perhaps [SO] would be a better place to ask, presumably lots of people use it as a development environment. – user9517 Dec 09 '13 at 17:19
  • 3
    If you want something that's closer to a real environment, try using Vagrant's KVM provider. – Michael Hampton Dec 09 '13 at 18:22

1 Answers1

5

What you're seeing is pretty much exactly what I'd expect. The people telling you VirtualBox "provides the same performance" as real hardware are either lying or they've never run any real, stressful workloads on VirtualBox & the underlying OS.
There are certainly situations where VirtualBox will perform as well as (maybe even slightly better than) physical hardware, but this isn't one of them.

VirtualBox is a type 2 hypervisor.
Every action you take in VirtualBox has to hit the emulated hardware and be passed along to the Real OS underlying the system to actually handle the request.
With all that extra overhead I'd expect a memory-intensive program (like memcache) to crawl in emulation.


I really don't have any suggestions for improving the performance of virtualbox in these conditions.
You could fiddle with settings, allocate gobs of RAM to your virtualbox instance, and tell your host OS to prioritize the virtualbox process and never swap it out, but that's all sub-optimal.

My recommendation is to leave memcache turned off on your virtualbox instances unless you're specifically testing memcache-related functionality.
Alternatively switch to a type-1 hypervisor (VMWare, Hyper-V) or a production-quality type-2 hypervisor (KVM). You'll probably see performance on those which more closely maps to what you're seeing on physical hardware.

voretaq7
  • 79,879
  • 17
  • 130
  • 214