Running Drupal under VMware
Initial Performance Planning
Drupal has huge potential for scalability due to its structure. As a result, Drupal can be installed under a multitude of configurations. Splitting the database and search from the main web application is a common setup. Using a virtualized environment, such as a VMware Server, is an excellent way to create environments as needed for any possible configuration due to the ease of creating and scaling new machines.
With this flexibility, we need to address some additional performance planning prior to the installation of the operating system. Specifically in 2 areas.
- The Files directory
- MySQL performance
Most sites I have come across who leverage VMware server with a Drupal setup are heavy microsoft shops with a few occasional Linux setups. I have run web applications written in .Net quite comfortably using IIS and Microsoft SQL server running under VMware. However, methods that work for Windows, may not work as well for Linux setups. The database is a prime example.
MySQL in VMware
Database performance is usually reflected through a number of factors, with the most prevalent being writing to the disk. Virtualized filesystems are not recommended for a number of reasons, primarily the time it takes for the database to receive a handshake from the OS to say the database record was written successfully to the filesystem. The time taken to execute this transaction can slow down a database if it is writing to a virtual filesystem.
To improve the response time, we recommend you use a physical disk with hardware raid and 1+0 striping (hardware is recommended over software, such as a volume manager). This can be mounted into the virtual machine as a direct mount. If the raid card has memory built in it reduces the transaction time because the raid card will respond with the handshake before the record is physically written to the hard drive.
For optimum performance, separate the OS from your database disks, and spread your virtual disks across physical drives. Also remember to avoid dynamically reconfiguring virtual disks while MySQL is running. This also applies to regular hardware as this can cause problems with the database, and is a common mistake with virtualized hardware. Linux is very memory bound, so you should make physical changes with the service or preferably the OS off, so that everything can be written back to the disks before you make your changes.
Additional tweaks which can improve performance include:
- Ensure your queries use indices effectively reducing unnecessary I/O workload
- RedHat is often prone to frequent timer interrupts which may be managed by the divider command.
- Reduce the number of virtual CPU's on your database server to a minimum. As a larger number of vCPU's will incur more scheduling overhead, your workload will increase in terms of CPU usage on the database server, but will run more efficiently.
- Disable floppy drive, CD roms, and USB adapters in your virtual machine because they can cause IRQ conflict and reduces overhead.
- Use physical NICs to reduce network collisions. Split your database traffic out on a different card from your web traffic.
In a Windows "shop" a common configuration for the filesystem is to have a Windows share available to Linux using samba to mount the drive. This is so a backup tool can pick it up and include it in a predominantly Windows backup scenario. This can cause some problems both within Linux and also Drupal.
Rather than have a Windows drive, use a native Linux partition and share it with your Windows system. I would rather have a delay in writing a transaction to my backup, which often runs at low usage times and is not time dependent. As compared to Drupal, finding the ability to write to a Windows partition through a transport protocol causes slowdowns, which are then passed on to our website visitors in the form of performance issues.
Often, writing data between Linux and Windows shares can be slow. This is usually a simple case of a difference in the TCP/IP packet size between the two operating systems. As much as Windows and Linux uses a packet size of 64k. Samba often uses as a default size of 32k. To fix this compatibility issue, you can adjust the size using the CIFSMaxBufSize setting inside your samba configuration. This will significantly improve file system performance for your filesystem when talking to windows.
VMware is a great tool in a sysadmin's toolbox for creating responsive and scalable Drupal deployments. With some initial performance planning of the architecture, you can avoid performance issues once your site has been deployed.
- MySQL Performance tuning whitepaper
- Todor Ivanov's Blog
- Database Systems on Virtual Machines: How much do You Lose?