Critch on VMWare ESXi 4.0 Migration

vmware_logo We recently made the decision to upgrade our network and virtualization environment.  Thanks to Matt’s careful engineering and configuration, Greg has been able to migrate some serious client data.  One of the things that I think is cool about our setup now is that we have the ability to move IP addresses around that might be assigned to some of our clients websites. 

As I have mentioned before, Matt Critcher is one of the most brilliant server administrators / engineers that I have ever had the opportunity to work with.  He recently blogged about our migration to VMWare ESXi 4.0 on his blog, I have posted excerpts and links to both of his posts below…

VMWare ESXi 4.0 migration

As I posted last time, we decided to move over to ESXi and so far, its been pretty smooth. ThePlanet installed ESXi 3.5 on our servers, which I quickly upgraded into 4.0. When you install the vSphere Client there is an option to install the host update utility. Run it, point it to the zip file you’ve download from VMWare’s website, and wait a bit. It works like a charm (put the machine into maintenance mode first!!). Since the servers had no clients running on them, I did it during the day (which let me sleep last night! lol!!) I’ve been copying over the VM’s from our VMWare Server machine with good ol’ scp and using the vmkfstools command on the ESXi box to convert them into ESXi format. Takes about 30-40 min per server for the whole process, which isn’t exactly quick, but we’re moving low-traffic boxes in very off hours. I moved the server that this website runs on during lunch today….;o)

Read the Entire Post…

2 days later Matt added another post regarding the migration…

VMWare ESXi 4.0 Migration, Part Deux

As I wrote about last time, Pleth’s move from VMWare Server to VMWare ESXi has been very successful thus far, but in the process we’ve discovered a couple of "neat tricks" and have proven to ourselves that the technology choices we made a few years back were indeed the right ones.

When you copy a .vmdk (vmware disk image) over from a VMWare Server machine, you have to convert it over to ESXi format. This process makes the resulting disk image the whole size that you’ve allocated. This isn’t necessarily a bad thing, but if you had it set to thin provisioning in VMWare Server your disk usage just went up. WAY up.

We were working off of a template that we could clone into a new VPS rather quickly, so we settled on a default VPS size of 20gb. There are definite benefits to provisioning the entire disk at creation, but when you sell several to different customers using thin provisioning allows you to minimize the total size of the datastore because most of them are never going to use the whole 20gb we’ve allocated. In fact, most never use more than a few hundred megabytes that their website actually takes up. We’ve got plenty of space available even if all were fully allocated because we don’t believe in overselling disk space even if some other providers do. Having smaller disk images makes moving the machines from one ESXi server to another much easier and faster if the need ever arose, thereby limiting downtime. Now, you can avoid all of this by running your VMware environment on a SAN with tons of disk space and using vCenter and VMotion but given our small size, budget, and very small number (7) of VM’s we just can not justify the extreme yearly costs associated with it.

So how do you get around this? You leverage the technology you have to the fullest extent. We spent a lot of time evaluating different products and have tried to make the decisions that allow us to provide the absolute best service given our budgetary constraints. This led us to purchase a private rack at ThePlanet, an entire class C of IP addresses, and lease some extremely powerful machines for our hosting environment. We’ve chosen great software to help manage our hosting customers, and probably our best decision was to invest in a product called R1Soft CDP. It has the ability to make multiple block-level snapshots of servers per hour and can Bare-Metal Restore one in just a few minutes. I can not say enough how well R1′s CDP works. Over the past two years it has saved us HOURS of downtime and tons of headaches more times than I can mention. The ability to make so many snapshots so quickly lets you look like a rockstar when a customer calls and says "I accidentally deleted all changes I made this morning" and you can put them back in 30 seconds.

So how did I use R1Soft to pull this off? I created a new Virtual Machine with 20gb of thin partitioned space. I then assigned the CD-ROM to a ISO image of the R1Soft Restore Disk and booted the machine. We shut all services off on the old VMWare Server VM, made a quick backup with R1Soft CDP, and shut off the VM. On the newly created ESXi VM, I did a bare-metal restore of the old one. It took about 10 min to restore about 4gb of data. One quick reboot, and voila! It’s running again. We could have used VMware vCenter Converter to do this job. It will convert almost any disk image into almost any other disk image format. It also has some distinct advantages over our chosen method namely in creating virtual appliances, but the problem for us to use it was that we didn’t have a server in our rack we could dedicate to the task — only a VPS. We would have to import the data (ie copy it to the machine running Converter) and export it to the new server, which is basically copying it twice (ESX/i to ESX/i doesn’t require this step). Our chosen method meant no copying over the data, doing a conversion, and then recreating the image. Just 10 min and it’s done (which also means only 10 minutes of downtime). Not only that, we got thin-provisioned disks back on the machines we needed it on, while the other servers got to keep their fully provisioned disks. I love technology….

Read the Entire Post…

VMWare ESXi 4.0 migration | www.mcritch.com

Critch on VMware, Apache, PHP/MySQL

I am happy (bordering on giddy) that our server engineer / administrator Matt Critcher is now blogging, dude is probably one of the sharpest guys I have ever met and he is an all around cool guy to hang with too, but beware of the fancy cheese he brings to dinner parties because you could find yourself in the emergency room on New Years Eve thanks to a long-standing penicillin allergy.

As some of you might know we made the transition to Virtualization a while back and have been extremely happy with the versatility it has brought us with our managed hosting and vps products that it has allowed us to bring to our clients, but with growth there can also be growing pains, it is for this reason that I am so glad we have Matt in our corner, dude knows his stuff and he can get to the bottom of an issue better than anyone I have ever worked with.

Lately we have been transitioning to VMware and have had some issues w/ websites that are slow to respond via browsers, but yet they still ping out okay.  It’s been a weird week or so, here’s a post that Matt put together the other night about the issues, I thought maybe someone else could benefit from his findings down the road:

I posted a few weeks back that Pleth had transitioned some of their equipment over to VMware Server and for the most part it’s been a very smooth process. But, as of late we’ve ran into some slowdowns, especially on the VPS with Plesk (which happens to host several of our websites). After doing a bunch of research and spending many a late hour digging through tons of mpstat and other sysutils data I think I found the culprit(s).

VMware Server, unlike the ESX/ESXi products, does not run in a Type 1 Hypervisor. This means that the underlying OS (in our case Red Hat Enterprise Linuxwas tuned out of the box for a general all-purpose server. This configuration isn’t always optimal for a Type 2 Hypervisor. It works just fine as long as things are "normal," but as the new VMware server got a larger load (in terms of I/O and CPU) performance went downhill.

One of the major problems has to do with how VMware Server uses disk-backed memory files (*.vmem). There is great debate on the web whether or not you should disable them, but one thing that is clear — when a site is busy, the file will be updated with memory information to reflect the changing memory of the VPS in question. This is where the problem lies — servers with unga-bunga hardware RAID solutions with 15K RPM disks and tons of spindles have a less of a problem with it but moderate quad-core Xeon and SAS disks in a RAID1 configuration like we and most other webhosts our size have it is a bigger issue. All those writes causes a wait-state in the CPU and therefore a backlog of transactions to be processed causing said server slowdown.

One way to deal with this is to modify the /etc/sysctl.conf to add (or modify) the following parameters:

vm.dirty_background_ratio
vm.dirty_ratio

I set my vm.dirty_background_ratio = 2 and vm.dirty_ratio = 85

Basically what these 2 parameters do is dictate the percentage of memory that can be "dirty" before it begins to flush (background_ratio) and the percentage of memory that can be "dirty" before a forced flush begins. When these files are updated, we can either have them done in the background (hence the low number for background ratio) with pdflush which allows other processes to continue to run, or we can have them queued up and wait for a synchronous (forced) write causing the iowait states (hence the large number for dirty_ratio). The big gap between background writes and synchronous is to try to keep the background writes coming consistently and avoid the synchronous writes as much as possible. You’ll have to play around with these figures to see what works best for you. See this page about half-way down for a little more in-depth explanation of these two parameters.

I also made some configuration changes to PHP and Apache to try to get a tad bit more performance out of each of them. I had written out a whole list of stuff that I’d modified to post here, and as I was looking for websites to help explain the modifications, I stumbled upon this website from IBM that lists pretty much every change that I made to Apache and PHP.

If you want to tune your MySQL database, this website is invaluable. It explains almost every parameter that you can possibly adjust and how to adjust them. One that it doesn’t really get into though is

innodb_flush_log_at_trx_commit

Setting this to "2" will force the system to write out any changes to the transaction log when the commit occurs but will only cause a flush of this data from memory to disk once every second (which gets stuck in the scheduler and is handled in the background by pdflush). The default setting of "1" will write out to file and flush this data from memory every time a commit happens. On really busy servers with InnoDB tables, this can cause slowdowns if your server really isn’t designed to handle a heavy DB load (most webservers aren’t). The drawback to this is that if the system crashes, you could lose 1 second of writes. Depending on what you are doing, this might be acceptable. Setting this to 0 will cause the write every second, but if the server crashes you might lose a ton of data because nothing is done at transaction commit. Scary, but fast (to me, scary outweighs speed in this case).

None of these changes should be taken without first thinking about what might happen. We have a test box in our office that basically mirrors our production server that I could test on beforehand. The Apache and PHP config changes are easy — no server reboots required, and you’ll know almost immediately if you mess them up. If you modify sysctl.conf incorrectly, the server might not boot. Better test a few things out (a VMware VM is a perfect testbed for these settings) BEFORE you have downtime.

VMware, Apache, MySQL, and PHP Performance Tuning | www.mcritch.com