Long one of the most common languages for application development, Java has started to gain support on cloud computing platforms. But due to the new and distributed architectures of platforms like Google App Engine, working with Java requires a different approach than developers may be used to. In the future, the key to cloud Java may be in the Java Virtual Machine (JVM), said Paul Hammant, principal technical architect at international consultancy ThoughtWorks.
In App Engine and the cloud computing space at large, use of JVMs seems to be increasingly common. Full-fledged Java EE componentry, though, is often seen as overkill. Because of the complexity they add, many of these components are not supported in App Engine. One such component is Enterprise Java Beans (EJB), a server-side component architecture for Java EE. Moreover Google BigTable, a non-relational data architecture used with Google App Engine, eschews the common data components associated with J EE.
The future of JVMs in cloud computing, however, looks "rosy" to Hammant. He said JVMs could become the major way Java is approached on the cloud.
"What I like in particular is that a WAR file deployment could be as small as, say, 10Mb of RAM in a VM that's sharing RAM with multiple virtual hosts," said Hammant. "If Google and similar can price things keenly against resource usage, then the price for these things could drift below anything that an [Amazon] EC2 style vendors can compete with."
While Amazon's EC2 instances come with assigned infrastructural components, a model like Google's charges only for bandwidth, storage and compute time. Though Amazon has more "capable" support for Java, Hammant said, the larger footprint of EC2 instances can be overkill for light-weight applications.
JVM surpassing full-blown Java EE.
Java applications that people are putting on the cloud tend toward lower CPU and memory requirements, Hammant said. With their slimmed-down specifications, it is more common to see lighter, self-contained applications on a JVM than on full-blown Java EE. This is important when approaching Java in App Engine because applications must be written for a sandbox environment where data ultimately sits on top of Google's non-relational BigTable.
"All apps have to be recoded and that, for many, is unpopular," said Hammant. "Sure it's powerful, but folks want ease of use more than the true scale BigTable offers."
Since the way this platform stores data is fundamentally different from the standard relational approach used in traditional Java applications, many developers have found the need to come up with workarounds. One such developer is Tom van Zummeren of JTeam, an open source Java shop in Amsterdam. Zummeren recently experimented with running the Spring framework on App Engine.
"Because of the server limitations, it is true that you can't write your application like a traditional Java Web application," said, Zummeren. "It's also true that you have to stick with JPA, JDO or plain SQL to store data."
Most Java developers should at least be familiar with the Java Persistence API (JPA), a Java framework for managing relational data, Zummeren said. However, App Engine's implementation of JPA does come with some limitations. In this system, you can't touch more than one entity in the same transaction, Zummeren said. He said this means it is practically impossible to commit a large set of data with one single transaction.
For Hammant, the major drawback to using App Engine is an issue with handling session data in a servlet-compliant way. Basically, if you are trying to store information in the running session itself, there is a risk of retrieving out-of-date items.
"Folks who make Web apps that do lots of Ajax between the browser and the server might be affected," said Hammant. "That is, lots of Ajax that may modify 'state' on the server where two or more modifying requests come in at the same time."
This problem wouldn't be an issue for stateless applications, he said, or situations where Ajax requests are sent at separate intervals.
App Engine is currently free to try for smaller applications. There is no charge if you can keep storage to under 500MB and page views to under 5 million per month.
Java on Windows Azure
Surprisingly, perhaps, the Microsoft Windows Azure cloud platform officially launched in January with support for .NET, C++, PHP, Ruby, Python and Java. In Azure, Java applications must also run in a sandbox environment.
Microsoft has been providing guidance to a number of collaborative projects that work toward better Java interoperability. One of these, WindowsAzure4J, just released a new build of its Azure SDK for Java on Feb. 15.
One drawback here for some developers will likely be the lack of administrative access to the Windows registry. This means applications have to be self-contained and copy-deployable, said Satish Nikam, an architect at Persistent Systems who works on Java interoperability with the Azure team.
Nikam said developers should be able to deploy a wider variety of traditional Java applications on Azure than App Engine. Unlike App Engine, applications in Azure can connect to an integrated relational database (SQL Azure) in addition to the unstructured data store (Azure Storage).
How to develop and deploy cloud apps on GAE