View the Sessions from our Prime Time Virtual Event
Unlock the Power of a High-Performance Java Platform
Support
Blog chevron_right Java

How Java Handles the Challenges of Microservices

How Java Handles the Challenges of Microservices

Summary

Microservices rely heavily on containers for deployment. Containers simplify deployment because a containerized service can be run in almost any environment. 

In this post you will learn: 

  • The microservice architecture splits a monolithic application into numerous component tasks
  • Microservices are inherently distributed, which can exhaust resources
  • As the load on the service increases, performance can degrade
  • Supporting multiple JVM instances on the same physical hardware can be challenging
  • Spinning up new instances quickly and efficiently can be a sruggle
  • Azul Platform Prime provides enhanced performance for many categories of applications including microservices

Software has traditionally been developed in the form of monolithic applications, which are packaged into a single, unified codebase. 

A monolithic application is self-contained and independent from other applications. It can be deployed easily as a single unit, but even the smallest change requires the whole application to be rebuilt and redeployed. 

The microservice architecture splits a monolithic application into numerous component tasks. The microservices architecture is inherently distributed, which can lead to problems not exhibited in a monolithic application. 

  • When one service in the application synchronously invokes another, the service being invoked could be unavailable or unusable, which could make the whole application unusable. 
  • Limited resources, such as threads, might be consumed by the caller while waiting for the invoked service to respond. 

There are many challenges that make it hard to implement such systems in a reliable way. Many of the core concepts of these technologies form the basis of microservices. Java is very complementary to the microservices architecture. 

Microservices present challenges for the JVM 

Before deploying Java-based microservices, consider carefully how the JVM works in this type of environment. Three specific things need to be addressed – and where a high-performance Java platform may make better sense. 

Azul has developed Azul Platform Prime, a high-performance Java platform, to address these challenges. Prime is a JVM that provides enhanced performance for many categories of applications including microservices running inside containers. Prime provides significant advantages over vanilla JVM applications to the challenges presented by microservices, represented in the matrix below.

Challenge JVM Application Azul Platform Prime
As the load on the service increases, there should be no degradation in performance.  New service instances are started, ensuring that existing instances deliver consistent performance as load. As the load on an instance of a service increases, this will typically result in more object creation and an increased load on the JVM garbage collector, which must be accounted for in the service deployment configuration.  Platform Prime’s C4 garbage collector will not resort to a full stop-the-world compacting collection, even under heavy load. The performance of the JVM memory management remains consistent If services become memory constrained, it is simple to increase the allocated heap space to solve out of memory problems without affecting performance. The significant impact of the reduced and consistent latency produced by the C4 algorithm applies to circuit-breakers. There is a substantial reduction in how often circuit-breakers need to be activated in a system and the long timeouts before they reset. 
Challenge JVM Application Azul Platform Prime
Supporting multiple JVM instances on the same physical hardware.  This is not the issue of how to manage multiple versions of the Java runtime, but how to deal with having multiple JVM processes running on the same machine. Optimizing the use of resources is critical to being able to scale services on a particular server.  Platform Prime’s works in conjunction with the Linux operating system to optimize the memory management subsystem Prime’s System Tools will reserve an area of physical memory (the size of which is configurable), which is shared between all instances of the Prime VM running on that machine. Prime reuses memory pages that are already in cache (hot pages), unlike a traditional JVM that frequently gets cold pages from the OS as it allocates new objects on the heap. 
Challenge JVM Application Azul Platform Prime
How to add (“spin up”) new service instances quickly and efficiently for handling varying levels of workloads.  The need to start up new instances of services as the load increases require those services to be available and performing at their optimum level as quickly as possible. A traditional JVM takes time to warm up as it analyzes the bytecodes being used and compiles frequently used methods into native instructions.  The ReadyNow feature of Azul Platform Prime is ideally suited to enabling new service instances to start quickly and provide a full level of performance straight away. ReadyNow helps developers manage Java’s runtime de-optimization and gives them more control over Java compilation. ReadyNow also allows accumulated compiler optimization profiles to be saved and re-used. 

You can find a complete matrix of microservices challenges and Platform Prime features in our ebook, High-Performance Microservices Using Java

Azul Platform Prime and microservices 

Azul Platform Prime is based on the open-source OpenJDK source code, which is the reference implementation for the Java SE standard. To deliver better performance than vanilla JVMs, Azul replaced parts of the core JVM with alternative implementations. This includes the memory management system and part of the Just in Time (JIT) compilation system. 

Faster JIT compilation improves performance: A traditional JVM employs two JIT compilers. Azul Platform Prime uses a new, improved version called Falcon. Falcon is based on the open-source LLVM compiler project, which is supported by numerous corporations and individuals including Intel, NVidia, Apple, and Sony. 

Faster warmup with ReadyNow: Azul’s ReadyNow technology accelerates application warmup in production environments from the beginning. Each time the application starts, the JVM and JIT perform all the work it would normally do, eliminating warmup so the application starts running at nearly full speed. 

Leave resources available with Cloud Native Compiler: JIT compilation delivers the performance modern enterprise applications need, but at a cost in terms of warmup time. Cloud Native Compiler (CNC) shifts the work of the JIT compiler outside the JVM, so it sends the details to the CNC and leaves resources available for the local JVM. 

Improve JVM memory management with C4 Garbage Collection: In a traditional JVM, applications pause during garbage collection. These pauses can range from milliseconds to hours, and the timing is unpredictable. Azul Platform Prime uses a different GC algorithm, the Continuous Concurrent Compacting Collector (C4). Unlike other commercial GC algorithms, application threads can continue to operate while the C4 GC is working. 

Conclusion

Software development is moving to the cloud and using microservices to do this in a flexible,
scalable way. Java microservices also provide several advantages over those developed in other languages. However, if you’re using a traditional JVM, carefully consider several deployment issues when choosing an application architecture. Azul Platform Prime uses different internal algorithms for garbage collection and part of the JIT compilation system. When combined with the ReadyNow technology to effectively eliminate the warmup phase of microservice performance, Platform Prime becomes a perfect choice for use in modern Java application development on microservices. Read the ebook, High-Performance Microservices Using Java, to learn more.

Teal CTA Band

Don't Go!

Learn more about microservices and Java