«

Glassfish Performance, OpenJDK vs Sun JDK

时间:2010-6-28 10:16     作者:fshell     分类:


I recently got a retired Dell Poweredge 600SC server from a local company.  This machine had a single Intel Pentium 4, 1.8GHz processor, with 1.5G SDRAM.  In terms of hardware, it's better than my old server machine (with 400MHz processor, 1G RAM), in which the Glassfish application server was installed to serve this blog and our online store application.   These java-based applications ran well in my old server and I would think that they would have better performance on the Dell machine.  I started to setup this Dell machine to replace the old server. 

The first problem that I encountered with the Dell machine was that I had problem installing the current version of Ubuntu into it.  I first tried to install Ubuntu 9.04, the same version in the old machine, but it faild to install.  Then I tried to install Ubuntu 10.04, the newest Ubuntu version as of this writing.  It also failed to install.  At last, I tried the Unbuntu 8.04 LTS version and it finally worked.   I was not sure why this Dell Poweredge 600SC couldn't install Ubuntu version newer than 8.04 version.  If you know the reason or know how to install the newer version on the Dell Poweredge 600SC,  please let me know.  I would appreciate your information very much!

After installing the Ubuntu server operating system, I tried to install the Glassfish Java application server.  I had an option to install either OpenJDK 6 or Sun JDK 6 for it first.  The Glassfish application server in the old machine ran on OpenJDK 6, the default option when installing the Glassfish application server.  Hoping it would perform better with Sun JDK 6, I installed Sun JDK 6 for the Glassfish application server this time.  The Glassfish application worked as I expected.  However, I realized at once that our online store application loaded slower than usual.  This application ran on Java EJB extensively and it took a few more seconds to load and initialize when compared with the old machine.  Checking the application logs on both machines confirmed my observations.   The time to perform the same operation in the Dell machine was in the magnitude of a few hundred milliseconds while it was in just a few ten milliseconds in the old machine!  I then ran some MySql tests to check the database performance on both machines.  MySql in the Dell machine indeed ran faster, cutting half of its time to run the same query in the old machine.  What made the application so slow in my new machine?  Would it be the Java version?  

I then installed the OpenJDK 6 to the Dell machine with: sudo apt-get install openjdk-6-jdk.  After a reboot, it worked!  The application finally picked up its speed as it should be.  It's a mystery to me that Glassfish(v2) in Ubuntu would behave in that way.  My guess was that the binary byte codes of Glassfish(v2) from Ubuntu were compiled with OpenJdk 6.  So using OpenJdk 6 might have advantages over Sun's Jdk 6. 

Now that the machine had two Java virtual machines installed in it, Sun Jdk 6 and OpenJdk 6,  I could choose which one to use with the following command in Ubuntu. sudo update-alternatives --config java