There are several things I do to get the most out of virtual machines, some of this also works on physical machines but not all.
The simple rule of thumb in computing is memory is faster than any other device. So if code can be executed out of memory without first reading from disk, if HTML and PHP and all of that can be served from memory, it's going to be faster than even a flash memory device or drive.
So ways to make that happen. First lots of RAM, Linux will use any RAM it doesn't use for something else as disk cache. So whatever system board and CPU you choose, stuff the board completely full of as much RAM as will fit and can be addressed. Know that Intel sometimes likes about this. They will quote max RAM based upon the number of memory modules allowed and the maximum size of memory available at the time. If you instead look at the number of address lines the processor makes available externally, take 2 raised to that number and you will know how much memory the processor can actually address. Then it is a question of whether or not your motherboard brings all of those lines out to the CPU. Asus and Gigabit are usually pretty good about this, the others, not so much.
So, some of Intels processors which they say can take 32GB may take 64GB with larger DIMMS and some that they say take 64GB might take 128GB with larger DIMMS. Tomms Hardware is a good source for information about this as someone there has tried just about anything conceivable and you can usually find out in advance if something will work.
Now to take full advantage of some of the suggestions I am going to be offering, it is important to have redundant disk I/O and UPS power, else you may lose data, because
what I recommend is using writeback caching. This allows a write call to return as soon as the data is in cache. If your machine was to lose power or a drive fail at this point, data loss will result. Thus I do this and I also use RAID10. Get the largest drives you can afford, do this because the bigger the drive the higher the density which means more data is transferred for each rotation. Get the highest spindle speed you can and equip your machine with a butt-load of fans.
There is an advantage to RAID10 in Linux that most people are not aware of. During reads, it will use all four drives at once so the read speeds are 4x as fast, essentially in write mode it's striping and then writing in parallel on two sets of two drives but in read it strips all four. This is assuming you are using the software RAID function in the Linux kernel.
Before I leave hardware, also a word on overclocking. Modern Intel processors tend to be limited in speed by one factor and that's heat. If you can get the heat out of the CPU fast, you can clock them ridiculously high. I run all my i7-6700k's at 4.4 GHZ ALL CORES, and my i7-6850's at 4.3 GHZ ALL CORES, and that is air cooled. I use a cooler rated to dissipate 220 watts with two fans per cooler and am very careful about applying an extremely thin layer of thermal paste and use a very good quality silver based paste. Do NOT put a big glob in the middle of the CPU and then tighten the cooler down. This will result in a thick layer and poor heat conductivity. Instead take a credit card or something similar and spread it as thin as you can across the surface of the CPU, then bolt the cooler down. I could actually clock these machines faster because under typical load they are damn near at room temperature, but I test with 2x as many copies as cores of an AVX version of mprime which is about as bad as it gets for CPU heat, and I clock them accordingly so nothing my customers can do will overheat them or even get them hot enough to thermally throttle.
Now on the machine machines with the exception of /root, you can add ordered to the fstab options and that will basically make it do writeback mode as well. On the virtual machines, I've bench-marked both Xen and KVM/Qemu under Linux and found little in the way of differences in performance but KVM/Qemu is simpler to setup, more flexible than Xen, and more secure. It can emulate non-native CPU, Xen can not. However, if you're working with ancient 32-bit hardware you'll need to go with Xen as KVM no longer supports 32 bit. At one point I di d have a 32 bit machine with 28GB of RAM running Xen and it mostly worked but KVM much better.
I use a tool called virt-manager, and under Ubuntu it is a much more complete implementation. Redhat's is not complete, no support for non-native CPU for example. When you create a drive in virt-manager in a new virtual machine you can either emulate real hardware or you can use virtio drivers if the guest operating system supports it. Most do, some don't, some like Windows, you have to obtain the virtio drives separately but I wouldn't use Windows for any Internet facing anything. Ubuntu and CentOS will both support virtio drivers. These are more efficient than emulating hardware. The drive has some performance options, choose writeback and threads driver. This will allow writes in your virtual machine to return as soon as it's written to cache.
Now there are a number of places you can use tmpfs, an in-memory file system to speed things up where temporary files are involved, for example in /etc/fstab, I use:
tmpfs /tmp tmpfs defaults,noatime,nosuid,nodev,mode=1777 0 0
tmpfs /var/tmp tmpfs defaults,noatime,nosuid,nodev,mode=1777 0 0
tmpfs /var/lib/php/sessions tmpfs defaults,noatime,nosuid,mode=1777 0 0
For applications that support memcached, use it. Much better storing temporary data in cache. It can be used for numerous things in Apache, and in many PHP applications such as phpbb3, wordpress, etc.
There are many tweaks you can use to optimize keeping things in memory, hopefully the above will help. The bottom line is try to serve everything out of RAM any time you can and that will optimize performance.
Ad blocker detected: Our website is made possible by displaying online advertisements to our visitors. Please consider supporting us by disabling your ad blocker on our website.
1 post • Page 1 of 1
Users browsing this forum: No registered users and 9 guests