News Stay informed about the latest enterprise technology news and product updates.

Java on Google App Engine requires different approach

Google App Engine has risen up from Python to support the Java programming language. This and other cloud platforms are not a natural fit when it comes to the broader Java EE framework, however. Bare-bones JVMs and lightweight Java applications may fare better in cloud computing.

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.

[With Google App Engine] … apps have to be recoded and that, for many, is unpopular.
Paul Hammant
Principal Technical Architect,ThoughtWorks
Java support for cloud computing has been growing. The App Engine platform debuted in 2008 supporting only the Python programming language, a favorite at Google more so than in most enterprises. In April of 2009, App Engine added support for Java. Later Microsoft— hardly a Java zealot—broadened its Azure cloud platform support to include Java. Still, it is not clear how Java will ultimately fare on the cloud.

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.

Light-weight Java takes on the cloud
Forrester Research survey data suggests Java is used less commonly on the cloud than C#, C, C++ and multi-language situations. But research shows that where Java is present, it tends to be light-weight.  

"Java and [Java EE] tend to get lumped together and, in fairness, a lot of people are using Spring, Hibernate and Tomcat today," said Jeffrey Hammond, an analyst with Forrester.
Hammond said you can expect Java on the cloud to reside on top of "something like Tomcat." That is: a servlet-based model—a lighter, simpler model.

Having to work around BigTable is limiting, said Hammant, who began experimenting with Java on App Engine last year.

"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).

Next Steps

How to develop and deploy cloud apps on GAE

Dig Deeper on Topics Archive

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.