A Few Tips for Improving the Performance of Your Web Applications

In this post, we will mostly be talking about a few things that we should keep in mind while writing web APIs to get the best possible performance out of them. Most organizations work with large amounts of data that need to be processed every second. So, it's very important to keep things organized and optimized in order to deliver a great user experience. Let's discuss a few points to help you understand how we can work more of performance optimization.

Virtual Tables

If you're using MySQL or any other SQL-based database, using virtual tables is the best thing that you can do. Let's look at an example. I have three databases and in a single query I am fetching data from four different tables. This process may take some time. In that case, you can create virtual tables in your SQL databases, which are sometimes referred as views, and keep all the columns that you want to retrieve from all four tables. This time, instead of looking at all four tables, the query will pull everything into a single table. This will help to reduce the response time.

Multiple Cache Configurations With Caffeine and Spring Boot

Caching is key for the performance of nearly every application. Distributed caching is sometimes needed, but not always. In many cases, a local cache would work just fine, and there’s no need for the overhead and complexity of the distributed cache.

So, in many applications, including plain Spring and Spring Boot, you can use @Cacheable on any method and its result will be cached so that the next time the method is invoked, the cached result is returned.

Spring Cache: Profiling

At Plumbr, we're constantly working on how software can be made faster and more reliable. The promise we've made to our customers is to avoid 100 million failures and save 100 million hours for their users per year.

While we're making things better for engineers around the world, we're also improving our software. Recently, I invested time in tuning the performance of one particular part of the Plumbr codebase. It is quite a tight loop, reading data from Kafka, performing several computations, and then writing data to a file. After several rounds of optimization, an unexpected code path started appearing on the profiler output.