X
Business

Making sure your Java isn't a load of old rubbish

Taking out the trash is a vital element of keeping your Java virtual machine running smoothly.
Written by Simon Bisson, Contributor

Java's had a lot of bad press recently, which has led to security consultants and even government agencies calling on users to uninstall Java from their PCs.

But enterprise Java is still an important technology – at the heart of many important cloud platforms and in enterprise servers, where it's a business-critical technology.

Back at QCon, the cross-platform developer conference, I sat down with Gil Tene, the CTO and co-founder of JVM vendor Azul, to talk about how a well-designed JVM can take the risk out of running enterprise-grade Java service and applications.

The Java Virtual Machine allocates a section of memory, its "heap", for use by objects and their associated data. With today's demand for in-memory processing and faster applications, the heap associated with a modern JVM can be very large indeed – possibly most of the memory on a modern high-end server. As the heap is managed by Java, it needs to be periodically cleaned out of stale objects and unused data. This garbage collection can be slow and resource intensive, making programs suddenly stall while Java reorganises its memory.

As such, with massive Java applications working with huge amounts of data, the risks come from Java's own garbage collection routines. They're non-deterministic and scavenge memory unpredictably.

That can stop your application in its tracks, and if you've got terabytes of heap in use, that pause can last a long time. In many cases that might not be an issue, but if you're running an ecommerce system and a pause interrupts a purchase, or a trading system and a trade suddenly halts, your business will be affected by lost customers and unbalanced and unprofitable delayed transactions.

Azul began life with a dedicated Java processor, which used a massively parallel architecture to handle complex Java applications in silicon, rather than a Java Virtual Machine. Azul's Vega remains a unique implementation of Java, one where a stub JVM handed byte code over to silicon – and where the heap was dedicated memory.

That let Azul handle garbage collection in a more predictable manner, with very little effect on your code.

The rest of the silicon world eventually caught up with Azul's technology, and by the time Intel released its x86 Nehalem processors, it was possible for Azul to switch from its own dedicated silicon to commodity hardware. Azul's Zing JVM builds on its hardware history to deliver an enterprise-grade JVM that out-performs the commonly-used consumer-based JVMs.

As Tene points out, managing the Java heap is key to getting the most out of your hardware, "Most developers are using less than four percent of their server capabilities," he says. "Our new JVM will run at the scale of the hardware you can buy."

Handling heap and garbage collection is key to offering low latency applications on Java, especially where latency can be an issue, in messaging and in trading. It also means not having to resort to complex programming techniques to handle memory – there's no need to fear large amounts of memory, allowing the use of sparse arrays, and faster, lower power programming techniques.

Changing the way Java does garbage collection can deliver significant advantages, allowing apps to run without being inconsistent.

While apps can have response times of the order of tens of microseconds, with most JVMs you will get jittering, as the system randomly pauses to handle garbage collections.

While you can use tricks (like rebooting a system daily) or use complex programming methods that don't take advantage of key Java features to avoid this, they slow down development and don’t allow the rapid deployment of new trading algorithms – where delivering a new app quickly can be the difference between profit and loss as more efficient algorithms replace the tools you’re currently using.

Azul's Zing means that instead of using work arounds, you can use off-the-shelf techniques, librariesand best practices to build new apps quickly, without having to train new developers in heap-friendly programming techniques.

Tene says of the result: "You have Java again, with the long-term bigger benefit of quicker, cheaper, less rigorous development." For many organisations, that's a big win.

Editorial standards