Skip navigation.

The fine art of application virtualization #

The new 8-core Intel Xeon 7550 processors are extremely powerful and a good platform for virtualised applications. My company is setting up PHP application running on a Xen based virtualisation on two HP Proliant DL580 for a total of 64 cores in a high availability environment. .

Why Virtualise?

First let's investigate why virtualisation is attractive. The advantages are:

  • Simplified maintenance, as all software is running on virtual machines (VMs). Easy to stop and start VMs from the VM server console.
  • High availability is easier to achieve, as you can just restart the VM on a secondary server if the primary server fails, assuming that the VM is stored in shared storage accessible by all servers, using shared storage methods such as NFS, iSCSI or a SAN (Storage Area Network).
  • Able to optimize server hardware utilisation globally as CPUs, memory, hard disk, network resources are all shared.

The disadvantages are strangely enough related to the advantages:

  • The maintenance is simplified, but the initial setup is more complex as not merely do you need to setup the hardware and the operating systems, but you have to plan out the virtual environment, such as the virtual network, and make sure that everything is properly sized as you are buying a few big machines, instead of lots of smaller servers.
  • High availability means you need to invest in high quality shared storage to store the shared VMs, typically a SAN, the SAN switches and the Fibre Channel HBA cards to connect to the SAN switches.
  • Need to over-configure the hardware as there is some overhead in virtualisation, particularly in terms of network I/O and storage I/O. CPU overhead for virtualisation is normally not a concern with modern virtualisation technologies such as VMWare, Xen, or Hyper-V.

In this case, our customer was comfortable with virtualisation, as they are big users of IBM AIX Logical Partitions and VMWare. Secondly, they already operate several large Storage Area Networks, and merely had to upgrade the SAN to support us. Lastly they had the budget to pay for all of this :)

VM Technology

We are using Zend Server CE (PHP 5.2), Apache 2.2 and Oracle 11gR2 running on Red Hat Linux 5.5 and Oracle VM 2.2 (which uses the Xen Hypervisor).

In the VM world, there are 4 main technologies that are popular:

  • VMWare - the market leader, this company has been doing virtualisation for over 10 years and they have good products.
  • Xen Based products - Xen is an open source technology that arose from some research on Hypervisors (the bare metal OS that controls all the virtual machines) done in Cambridge University. Today, several companies offer products using Xen, including Red Hat, Citrix, and Oracle. Has good support for Linux and Windows.
  • KVM - many kernel hackers were dissatisfied with Xen (because the Xen Hypervisor is not Linux-based internally), resulting in the development of KVM, which is fully Linux based. KVM is not as mature as Xen, but improving really fast. Support Linux and Windows.
  • Hyper-V - Microsoft's virtualisation technology. Microsoft is committed to supporting Linux also.

We chose Oracle VM (Xen) because it has good performance with Linux and Oracle databases (naturally). Oracle VM is free with optional paid support available. There are also licensing advantages to using Oracle VM with Oracle databases. Oracle database licensing dictates that if you are using virtualisation technologies such as VMWare and are purchasing CPU licenses, you still have to pay database licenses for all the CPU cores of the server, even if the database VM is using only 1 core. However if you are using Oracle VM, then you only have to pay for the CPU cores you use using; this is known as "hard-partition" licensing in Oracle terminology.

I also have experience with VMWare, and can recommend it as an mature alternative. Apparently the Citrix Xen Server is a good product, but I don't have experience with it.

I will cover more technical details in part 2, which i will be writing in September after I complete this installation.

Updated Optimizing PHP Article #

I have just updated my popular Optimizing PHP article with additional information on caching. I discuss memcache and squid. I also updated the PHP Accelerators and changed the tone of some parts of the article. I quote:

Perhaps the most significant change to PHP performance I have experienced since I first wrote this article is my use of Squid, a web accelerator that is able to take over the management of all static http files from Apache. You may be surprised to find that the overhead of using Apache to serve both dynamic PHP and static images, javascript, css, html is extremely high. From my experience, 40-50% of our Apache CPU utilisation is in handling these static files (the remaining CPU usage is taken up by PHP running in Apache).

It is better to offload downloading of these static files by using Squid in httpd-accelerator mode. In this scenario, you use Squid as the front web server on port 80, and set all .php requests to be dispatched to Apache on port 81 which i have running on the same server. The static files are served by Squid.

Malaysian FOSS Conference 2009 Opening Keynote #

Last Saturday, I gave the opening keynote of the Malaysian Free & Open Source Software 2009 conference. The speech was prepared the day before, but as usual, I will improvise some stuff, so some parts have been amended based on memory:

Ladies and gentlemen, honored guests, good morning!

Today the landscape of information technology has been transformed by the vision of free software and open source. The search engines of Google roar with the sounds of open source Linux. Our Malaysian government encourages the use of open source whenever possible. Sounds of PHP, MySQL, Apache, GPL have become familiar names in the tapestry of IT.

But that was not what it was like when I first started out as a young student in the mid-80s at the University of Melbourne, Australia. Things were different then. Concepts such as open source, GPL were still unknown. I still remember a fellow student was expelled from university for making copies of the source code of proprietary Unix software for his personal use.

I admit I was disturbed by this, because I too had an insatiable curiosity about how software worked, and it was impossible to learn more without access to the source code. I wanted to find and understand the wiring inside the software.

I remember fondly, and today with a bit of guilt, that I used to crack copy protected games, not for the pursuit of profit, but as an intellectual challenge – well ok, I have to admit I did it to play the games. The trick doing this (cracking) metaphorically is finding the wiring behind the copy protection and reversing the wires so that instead of refusing to run, it does the opposite and continues working.

Of course to quickly find the right wires to switch and crack a large program is not easy. Which brings me to the first piece of advice if you want to be successful in software design… You need to have good taste, which is kind of weird because nerdy programmers are notoriously bad dressers, fond of bad hair days and certainly not fussy about the finer points of fine dining.

What I’m taking about is of course is a taste for good logic. The feel of a beautiful idea, the taste of a mighty logic, or the fun in a great hack.

Games designers and coders are a talented bunch of people, and if you understand their logical rhythms and designs, it becomes obvious where the wires you need to reverse to crack the software reside.

The other important element of success is being happy. You have to have passion and enjoy what you are doing. To me cracking games was like cracking walnuts, a fun thing to do, but after a while it got boring. You need to do something with others and share with others to become really passionate about something.

Social responsibility is another important element of life. You need to channel your life productively - only then will you find true happiness. Cracking games became boring and I found other better diversions.

It was around this time my fellow student was expelled that I learned about the international USENET community. To young people, you have to imagine a time before the World Wide Web, when people used the Internet primarily for email. USENET was a fantastic group of mailing lists with forums and archives. USENET was also used to disseminate programming ideas and knowledge in the form of source code.

So even before the concepts of Open Source and licenses such as GPL became well known, there was this thriving community of programmers who shared their source code and learnt from others. Which brings me to the next lesson: the typical image of the best programmers being lonely introverted hackers is misleading. People are only successful in a community. Open source software needs to be grown organically and for that you need social skills. The classic example here is of course Linus Torvalds, author of Linux, who has skillfully led the Linux community from its inception.

It was through the USENET that I released software that I had written, including the one that won runner-up for best Australian Macintosh software in 1988 while still a foreign student in Melbourne.

You know, while preparing this speech, at the back of my mind I have always wondered why Malaysia has not had a bigger role in contributing software to the open source community? Was what I achieved due to my overseas education? I was thinking about it last night while writing this speech, and I don't think so: I will tell you why...

Malaysians do not lack ability. I see many smart and interesting people around me here at the conference. And I have seen many sophisticated pieces of software in the commercial world developed by talented teams of Malaysians. English, the language of Science and the Internet, is widely spoken here. However in the open source world, we have many more consumers than contributors.

Is it our education system? Perhaps an over-emphasis on exams it is a contributing factor, but I don’t think that is the main reason. I studied for 12 years in Malaysian state schools, and I survived sane and reasonably intelligent! And exposure to the Internet has made young people more worldly than any previous generation of Malaysians.

After reflecting, I suspect the reason is primarily economic. After college, it is difficult to sustain a living and have the time to contribute meaningfully to an open source project here in Malaysia. There are companies with strong support for open source here, but most companies here see little value in allowing their staff to contribute to open source.

So let’s flash forward from studying Melbourne in the 80’s to working in Malaysia in the year 2000. At that point in time, my company was planning on developing their next generation web application server, called PHPLens. An application server is a professional software framework which makes it easier for programmers to build high quality software modules.

We also wanted PHPLens to support as many databases as possible. That was the reason why we decided to open source our database abstraction library. Contributions from the programming community were encouraged so that we could support more databases.

And as this was the 3rd database abstraction library I had developed in my career, I had some meaningful experience in this area. Other developers liked it and today the library has become very popular world-wide and is in use by thousands of developers.

I have been working with and supporting the ADOdb abstraction library for over 9 years. I can tell you working on open source is sometimes not fun. You work for hours to implement some feature and then the feedback you get is that it’s not very useful. People will disagree with you. You also get cranky people emailing you in broken English to fix their problems urgently. And if you misunderstand them, it just gets worst. To survive, you need to be passionate about your work, really listen to people (which isn’t easy in an email exchange) and be committed to excellence.

I would like to show you now a presentation I did on ADOdb a few years ago. [presentation here]

In closing, I would like to ask how do I think the Malaysian Free & Open Source Software movement can advance further? Actually I think we are doing a good job. I see a lot of local companies have already switched to using Open Office or running Linux, Apache, MySQL, PHP for their web-sites.

As I mentioned before, the real factors we need to look into are still economic, your take-home pay. What we need is more demand for people with the right skills to support this open source infrastructure, and an ecosystem where the pay is attractive.

We need to transition from the idea that “free software is cheap” to “free software is cost-effective”. There is dignity in work, and people deserve to be rewarded. Thank you.