How to Optimize Java’s Value in a Real Time Environment

By Scott Sellers | 22 May 2014

The State of Play

Trading at high speed can deliver impressive returns but a single bottleneck or mistimed trade can be devastating. The need to respond to shifts within highly automated markets has never been more critical. Now more than ever, organizations must ensure that the latency between an order being sent and processed is as low as possible.

Institutions have no choice but to deploy robust trading platforms and supporting applications that measure performance in microsecond-level scale – meeting machine-scale Service Level Agreements (SLAs) throughout the day – and especially during trading peaks at market open, close, and when news or Tweets influence the exchanges. During a trading day, if one out of 10,000 operations takes 20 milliseconds, profits can be seriously affected. This is the environment in which today's financial systems operate. Across the globe, real time markets need to be supported by platforms that support real time business.

What is a Real Time Business?

Today’s businesses fall into one of two basic camps. The first is “human-scale” real time. Human-facing interactive systems now address innovations like exploring hypothetical trades and near real time risk, allowing portfolio managers to explore “what if” trading scenarios and understand their exposure within minutes or seconds. Here, extra seconds of delay can range from frustrating to fatal, depending upon market conditions that can vary from minute to minute.

The second is “machine-level” real time. Exchange-facing systems and their supporting applications must be able to process huge volumes of market data and other latency-sensitive information, since even microsecond-level delays can create opportunities for competitors to swoop in. The ability to process massive amounts of information in real time (and be assured it’s processed consistently and reliably) helps enable better decision-making, more flexible trading strategies and algos, and, ultimately, higher profits.

The applications powering a trading platform need to be fast and consistent. An average latency measured in microseconds might be “fine,” but if the 99.9th percentile is measured in milliseconds, your firm may have a serious execution problem during a critical trading window.

The Strengths and Weaknesses of Java

Java-based applications are used throughout the electronic trading world – from trading platforms to settlement systems, risk and various reporting systems. As in other enterprise environments, Java is prevalent, and is associated with systemic benefits including productivity, improved time to market, and the ability to leverage a huge ecosystem of enterprise software components.

Yet, Java's recent usage trends in low latency trading may be surprising to many, as it has some technical shortcomings that can cause problems in environments requiring very low latency:

  • Performance. Java can be very fast, often as good as or better than C or C++ in real-world applications. However, Java was designed to get applications up-and-running quickly, even if that means initial performance after startup is relatively slow. The Java “warm-up” problem resides in the behavior of the Java Virtual Machine (JVM), the software responsible for running Java applications. As a Java application is launched, the JVM is responsible for compiling the Java application into a form that can be run on a computer or server, and as the application continues to run the JVM will recompile important parts of the application code to improve performance.  However, a problem exists as frequently a Java application has not yet been compiled optimally when peak performance is actually required and expected by traders.
  • Tuning and Tweaking. In production, Java platforms can be very fragile, requiring continuous and costly re-tuning to achieve optimum performance. When your best technologists are worrying about Java tuning flags and best practices to code around Java’s runtime pauses, they aren’t building new features and creating innovation.
  • Developer Productivity. Java was designed with developer productivity in mind, and that is one of the main reasons that Java powers most enterprise servers today. The Java Virtual Machine (JVM), the software responsible for actually running the Java application, manages memory and supports very complex multithreaded architectures with ease – functionality that otherwise needs to be built from scratch by highly skilled programmers. However, the price is that latency can be highly variable – an application with average latencies of 25 microseconds might see peaks in the 10s (or hundreds) of milliseconds.

Legacy Issues

Traditional JVMs, such as Oracle’s HotSpot, notoriously suffer from latency glitches, stalls, and jitter. Development teams are extremely aware of both the power of the Java language and the impact of the Java runtime on latency. Java’s reputation for jitter and unpredictable latency is the result of the inherent nature of "Stop the World" garbage collection built into legacy JVMs.

The pauses caused by this sort of JVM-internal processing can often create unacceptable latencies at unpredictable times, causing variances in low latency operation speeds that are measured in tens of thousands of per cent. These discontinuities represent Java's biggest issue which has consequently led to increased interest in looking at JVM alternatives.

How Can You Improve Java Performance?

Not all JVMs are created equal, and businesses ready to invest in new low latency Java-based systems must look for a JVM that meets the following requirements:

  • Deliver peak performance right at market open and at all times throughout the trading day even during unpredictable events; i.e., start fast and stay fast.
  • Achieve excellent average performance, but also reduce peak (worst-case) response times – even at the 99.9th and beyond percentiles.
  • Eliminate glitches, pauses and jitter caused by the JVM.
  • Reduce or eliminate the need for re-tuning the JVM.
  • Do away with the need for specialized low latency coding practices and hand-crafted libraries – use the full power of Java and keep your best developers productive and working towards business-level innovation.
  • Break the link between memory size and predictable performance – allow applications that can use more memory (i.e. hundreds of gigabytes) to do so, without the fear of Java garbage collection stalls or other hiccups

JVMs, such as Azul’s Zing, meet the performance (and predictability) requirements of today’s electronic markets. Zing is widely used in the front and middle office. Those are the areas where latency and faster response times are really critical for the business. Specifically, in the front office, Zing is used first and foremost in trading platforms that are processing millions of trades a day across the equities markets, across foreign exchange, across fixed income and a variety of other instruments, where the trader needs the absolute, most consistent performance. There are many other areas that require similarly consistent response times, so Zing powers many of the FIX engines and FIX gateways that are commonly used throughout today’s global banks and hedge funds.

In the mid-office, risk is moving from a batch process into real time and, as a result, the SLAs for the real time risk engines are now as strict as the trading platforms. The need to be able to constantly assess risk in real time, to be able to re-analyse risk based on changing prices and changing positions and based on hypothetical “what if” scenarios, has driven Zing’s global adoption in the mid-office as well.

System developers already use one of the most powerful and flexible languages known to the industry – Java. If you deploy a modern JVM, such as Azul’s Zing, developers can use all the features of Java yet not have to worry about the scalability, inconsistent response time and latency outliers associated with the language.

 

By Scott Sellers, CEO, Azul Systems

Become a bobsguide member to access the following

1. Unrestricted access to bobsguide
2. Send a proposal request
3. Insights delivered daily to your inbox
4. Career development