Robert has several years of professional experience and a PhD in the field of automated software migrations. He is the co-founder and CEO of Numition Ltd., a start-up company specialized in developing software migrators. Robert is a DZone MVB and is not an employee of DZone and has posted 10 posts at DZone. You can read more from them at their website. View Full User Profile

Hosting Java Web Applications: Why Is It Still So Hard?

  • submit to reddit

Hosting Java Web applications is far from trivial. Ask anyone who has tried it and you'll start to understand why Java Web applications are not popular outside the enterprise. On the other hand, another common type of Web application - PHP based - has no such hosting issues. While there is lots of information on this topic throughout the Internet, I thought about performing my own simple test and I focused on three representative hosting providers.

The benchmark

Our company has recently launched the Java translation of phpBB 2, branded as nBB2. It's open-source and you can get it from So what I had at hand was the Java equivalent of a popular PHP forum engine. Same look, same behavior, only backed by a different programming language. If one wants to compare the hosting options for small-to-medium PHP and Java Web applications, the phpBB/nBB2 pair looked to me like a good test material.

My reasoning was to use a Java application that is the very close counterpart of something that runs on even the cheapest PHP hosting options. By "close counterpart" I mean they both carry out the same operations on system resources (e.g. writing files, using sockets, accessing databases).

Another concern I had was performance. I wanted to find out not only whether the Java application can run on a certain hosting plan, but also how fast. Again, the most reasonable benchmark was to compare performance with the original PHP application running in the same environment.

I started by setting up a testing scenario using Apache JMeter which performs the following workflow: main page → login page → main page (automatic redirect) → view forum → view topic → post reply → log out → main page (automatic redirect).

This scenario is executed by 10 concurrent threads (users), 30 times each. This produces 300 new topic posts at the end of the performance test. All JMeter project files are available on the CVS here.

Reference tests

Before using the hosting providers, I conducted reference testing on two of our machines (one Linux, one Windows). The results were consistent: phpBB 2 was 10-15% faster than nBB2.

I ran PHP 5.2.3 through the Apache 2.x PHP module, a pretty common setup. For nBB2, I used Apache Tomcat 5.5 (on J2SE 6) and I imposed a heap limit of 32 MB, close to what one can expect in a remote hosting environment. More performance tuning could produce better nBB2 results, but this was enough to prove that the performance of the two applications is comparable.

The JMeter aggregate reports are also on the CVS. In case you wonder why Java doesn't blow out PHP for speed (or vice-versa), do not forget that both applications share the same architecture.

Shared hosting

For Java Web applications, the basic hosting options I have encountered feature a setup in which several users share the same instance of Tomcat 5.x. Perhaps Caucho Resin would be a better choice, but that's another discussion.

After many attempts, I gave up on GoDaddy's cheap Linux-based Java hosting account (the Deluxe Plan with $6.99 per month). I can only say what many others do, that it isn't suitable for anything but the simplest servlets or JSP pages.

Their JVM is set up to be very restrictive. As a rule of thumb, any part of the Java API that requires security permissions will probably not work. Think of write access to your own account (or /tmp), reading of system properties, creation of URL stream handlers, FTP connections. Before dismissing the importance of write access, think about logging. You'll be forced to log to a database. Log4j JDBCAppender is your friend, but it can't replace a simple log file. But I digress.

Other basic hosting accounts forbid the use of third-party JARs, like the case of HostIgnition's StarterFire plan.

Deployment/redeployment is another issue, since you don't have direct access to the JVM and so you cannot restart it at your convenience. According to GoDaddy's documentation, they have scheduled restarts each night at 1 AM Arizona time. In practice, they seem to do restarts more often than that. Other providers have on demand restarts. Each user can request a certain number of restarts each day. The problem is that other users you are sharing the JVM with can temporarily take down your application.

Shared hosting using a private JVM was the next logical step in my quest. This took the monthly charge well over $10 (e.g. $14.95 for HostIgnition's LiteFire with the Level 2 JSP/Servlets option). At this level one needs to get used to 32 MB of heap, at best. Above that, prices increase steeply (e.g. $59.95 for 64 MB of heap at HostIgnition). Having your own JVM, you may restart it at your convenience and can see even the Tomcat logs directory through FTP.

But even using the private JVM doesn't mean that all will go well. For instance, on my test Hostignition LiteFire account, I occasionally encountered the java.lang.OutOfMemoryError: GC overhead limit exceeded error during performance testing. This is documented to occur when the -XX:-UseGCOverheadLimit JVM option is enabled, more than 98% of the total time is spent in garbage collection and less than 2% of the heap is recovered. Now this could happen if a certain part of the heap resided in swap and could not be restored to RAM in a time-effective manner.

On a positive note, the performance of nBB2 slightly exceeded that of phpBB on my HostIgnition account - configuration options do help.

After all this, I see the shared hosting with private JVM as the cheapest viable Java hosting alternative. While the basic hosting services just won't do, this one is reasonable but starts to be a little pricey.

Virtual Private Servers (VPS)

After finding a reasonable Java Web hosting solution, I thought about going upwards in the price range. The next step is represented by the Virtual Private Servers. You get your own machine (Linux or Windows) and have full root/admin access through SSH/Remote Desktop. The catch is that all this is virtualized and you are sharing a physical machine with others. Depending on how many users are allocated to the same physical machine and on what they are doing at a given time, performance varies.

The downside is that, besides the JVM, you are in charge of the whole operating system. Setting up and maintaining the servers for DNS, email, database, Web etc. is no small task.

My Linux-based GoDaddy VPS (Economy Plan, $30+) had enough RAM (256 MB RAM + 1 GB of swap), but experienced occasional performance drops. This was really bad. I thought I'd try a different VPS provider.

On a LunarPages VPS also running on Linux, things were much better and consistent on the performance side. The problem was that I had only 512 MB of memory available, including swap space. I'd say that on a real machine this would be the equivalent of 128 MB RAM and 384 MB of swap. This memory was eaten up pretty fast by the running services and I had difficulties getting a JVM to fully use its 32 MB heap space (in client mode, since the server mode requires additional non-heap memory). This ate up all the memory and /proc/meminfo was consistently reporting low to critical memory resources. Under these circumstances, even simple Cron jobs were failing due to out of memory errors. Naturally, the JVM also required daily restarts, otherwise I'd get OutOfMemory errors there as well.

Had I skipped the Plesk administrative interface and disabled some non-essential services, I might have been able to fully use the 32 MB of heap space and have some memory to spare. But it seemed pointless to pay twice the price of a private JVM on a shared host to get the same level of performance at best.

Performance-wise, when the Java application DID work, the results were consistent with what I had obtained on our local machines.

Dedicated Hosting

It surely works great, but it is in a completely different price range. I find a $100+ monthly charge to be rarely justified for low to medium traffic sites running small sized Web applications. The JVM is snappy, while experiencing the same comparative performance as on my local tests. Memory is no issue since all dedicated plans come with at least 512 MB of RAM and a swap space for which you have exclusive use. It's a physical machine for your use only.

The conclusion

With all this effort, I managed to find out nothing new :-) Java runs well in an enterprise environment (good up-scaling) and lags outside of it (bad down-scaling). The memory overhead of the JVM translates into memory problems for the applications in a budget-friendly hosting environment, making the comparable performance (when/while things do run) a small consolation.

But PHP works well outside the enterprise. Its simple development and deployment life-cycles are ideal for shared hosting environments, just as if the language was been built with this in mind – well, actually, it was.

While Java comes out a little bruised from this comparison, future evolutions might change the balance of power. If the MVM (multi-tasking virtual machine) from JSR 121 that promises to run multiple isolated virtual machines inside the same JVM process will ever be released, this could make it easy and cost-effective for hosting providers to give full access to a JVM per account even in their basic hosting plans. Another possibility is for the embedded J2SE platform to be used by hosting providers, if it catches on.

Published at DZone with permission of Robert Enyedi, author and DZone MVB.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)


Jeroen Wenting replied on Fri, 2008/04/11 - 12:43am

I think a major part of the problem finding Java hosting on the low end of the market has nothing whatsoever to do with complexity of the work and everything with the type of people starting and running hosting companies at that end of the market.

Those people are typically Linux fanatics, with a decade of "hatred" of Microsoft and Java under their belts, so they won't even consider hosting Java even if they had skills exceeding those needed to create virtual hosts on Apache.
Some have bowed under pressure and started hosting Frontpage extensions because the home user and small business (their customers) often ask about those, since those users often use Frontpage to create their websites and Frontpage assumes Frontpage extensions to be available by default unless you tell it otherwise.
Java has no such penetration in the low end of the market of web designers (which is hardly surprising as Java was never aimed for web development at those people, where Microsoft very agressively targets ASP at them).

So it's a political/religious and economic issue more than a technology issue.
One could host a cluster of JBoss or Tomcat instances just as easily as a cluster of Apache instances. But these people don't want to, the very thought never even enters their mind, and they're still under the impression (from all the reports they saw on slashdot a decade ago and regurgitated there every few weeks) that "Java is slow", "Java is not secure", etc. etc.

Robert Enyedi replied on Fri, 2008/04/11 - 6:49am in response to: Ray Kelm


That said, I would have no problem with putting 10 virtual hosted php sites onto a single VPS, whereas putting a tomcat instance I'd recommend only one. Not that tomcat needs the full capacit, but that it's easier to manage those php virtual hosts.


Ray, it's good to know that you are in the hosting business. Did you attempt to provide shared hosting for Java? We all would like to hear some more thoughts about this. Previous posts did mention Java's lack of control over threads as one of the reliability issues. Having the ability to impose limits on memory and processor usage, arbitrary interruption etc. would certainly be nice.


I'm also a developer, and generally prefer java over php. I wish there were a better story for deploying java web apps. To that end, I've been working with OSGi, and I think there is something there worth using, but it's not yet at the point where it is easily deployed.


What parts of OSGi do you think that could ease Java web deployments? Is that the fact that you have better application lifecycle management than those that come with the popular Java web containers?

Eric MacAdie replied on Mon, 2008/04/14 - 5:35pm

I think that for servlet hosting, VPS might be the way to go. Hosting companies that have good servlet hosting seem to wind up costing as much as VPS does, so why not go that route?

It seems like over the past few years, shared hosting has gone down in price significantly, especially considering that they now offer a lot more hard drive space and bandwidth than a few years ago. But servlet hosting prices have not really changed, and they do not seem to offer more memory or disk space than a few years ago.


Robert Enyedi replied on Tue, 2008/04/15 - 4:34am in response to: Eric MacAdie


I think that for servlet hosting, VPS might be the way to go. Hosting companies that have good servlet hosting seem to wind up costing as much as VPS does, so why not go that route?


Eric, managing a VPS is a considerable task while a private JVM is managed by the hosting provider. Additionally, for shared hosting accounts you usually get a management console (CPanel/Plesk etc.) by default, something that you pay heavily for on a VPS (think of 10$+).


It seems like over the past few years, shared hosting has gone down in price significantly, especially considering that they now offer a lot more hard drive space and bandwidth than a few years ago. But servlet hosting prices have not really changed, and they do not seem to offer more memory or disk space than a few years ago.


From what I've seen, RAM prices didn't go down that much during the last couple of years, while disk space became way much cheaper and so did bandwith. And since Java web applications are much more memory hungry while idle (compared to the CGI execution model), this could explain it.

Ray Kelm replied on Wed, 2008/05/14 - 8:39am in response to: George Look

Yeah, but it's $13 for a developer JVM with onyl 64M ram. It's $20 for a 128M JVM, which puts it at the same level as a typical VPS. Hmm. Actually, a little less since the $20 price point usually includes 256M RAM. For that you pay $25 on that site, which make sense since they are doing the maintenance.

All in all it looks very comparable to VPS.


Nat Hu replied on Fri, 2011/01/14 - 3:38am

hello - i have having my website built, and the designer i hired beijing can only write my program in java. it's almost completed and I need to locate a hosting company this week. Could yo please tell me which java language hosting company is reliable and worth considering. From what I can read of reviews they have been a mixture to the extend that i am so totally confused by it. Would greatly appreciate your guidance here. nat

Carla Brian replied on Mon, 2012/05/07 - 9:55am

Once in a while you need to block the users of your Java web application so you can do maintenance on the system. - Paul E Perito

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.