Book Image

Java EE 8 High Performance

By : Romain Manni-Bucau
Book Image

Java EE 8 High Performance

By: Romain Manni-Bucau

Overview of this book

The ease with which we write applications has been increasing, but with this comes the need to address their performance. A balancing act between easily implementing complex applications and keeping their performance optimal is a present-day need. In this book, we explore how to achieve this crucial balance while developing and deploying applications with Java EE 8. The book starts by analyzing various Java EE specifications to identify those potentially affecting performance adversely. Then, we move on to monitoring techniques that enable us to identify performance bottlenecks and optimize performance metrics. Next, we look at techniques that help us achieve high performance: memory optimization, concurrency, multi-threading, scaling, and caching. We also look at fault tolerance solutions and the importance of logging. Lastly, you will learn to benchmark your application and also implement solutions for continuous performance evaluation. By the end of the book, you will have gained insights into various techniques and solutions that will help create high-performance applications in the Java EE 8 environment.
Table of Contents (12 chapters)

Caching challenges

To ensure that we keep in mind the pattern we target when we put caching in place, let's use a simple example taken from our quote manager application. Our goal will be to make our find by symbol endpoint go faster. The current logic looks like this pseudo code snippet:

Quote quote = database.find(symbol);
if (quote == null) {
throw NotFoundException();
return convertToJson(quote);

We only have two operations in this code snippet (find it in the database and convert the database model into a JSON model). Wonder what you're caching: the database lookup result, the JSON conversion, or both?

We will come back to this part later, but to keep it simple, here, we will just cache the database lookup. Therefore, our new pseudo code can look like the following:

Quote quote = cache.get(symbol);
if (quote == null) {
quote = database.find(symbol);
if (quote...