Photo by Joshua Aragon on Unsplash

The service that you are building and exposing its functionality via an API has to be consumed by some client. That client could be a browser application or another backend service that needs to interact with your application. In the case where the only client is a browser application, you don’t need to do anything additional to simplify the work that needs to be done on the client-side.

However, when the client is another service, and that is a Java-based service, then you could fairly simplify the client by using a common technique which we will discuss in this post.


Photo by Caspar Camille Rubin on Unsplash

When you are building a Spring Boot application, it’s very likely that for auditing purposes you want to log the request body for every POST and PUT request made to the application. The best way to do that is by creating a Filter and registering it through the filter chain. It will be responsible for reading the request body and logging it to the standard output.

But before we start implementing it, let’s first analyze how a ServletRequest is processed:

When we talk about processing content in Java — in our case the request body, everything is represented in terms…


Multi-region infrastructure

The infrastructure of the system must be managed using an IaC tool. Period. In our case, we prefer to use Terraform as a tool that doesn’t depend on a specific cloud provider to manage the infrastructure, and we like to version control the entire infrastructure source code.

In this post, we focus on provisioning a multi-region infrastructure with Terraform in AWS.

Read the full post here.


Multi-region infrastructure on AWS

Multi-region infrastructure (Image source: Author)

The infrastructure-as-code concept allows you to manage an entire cloud infrastructure in a declarative way. AWS provides the CloudFormation service to enable the modeling of the entire infrastructure and application resources using a text file or programming languages in an automated way. Even though it’s very simple to learn and use, its main downside is that it’s tied to AWS only, and if you manage a multi-cloud infrastructure that consists of applications deployed in AWS, Azure, Google Cloud, etc., then you would use Terraform to build, change, and manage infrastructure in a safe and repeatable way throughout the clouds.

In…


Using AWS Lambda@Edge

Photo by Shahadat Rahman on Unsplash.

When developing a web application, you may decide to serve the landing page along with every static file through a CDN for better performance. CloudFront is a CDN offered by AWS that allows you to serve your content from different sources, known as origins, like S3 or a Load Balancer. Your application’s static files or dynamic data will be served through these origins to your users.

The Issues

But during the development process of the application, you would need to host on AWS. …


Using AWS CloudWatch

Photo by Luke Chesser on Unsplash

When your application is ready to roll out in production, monitoring every single activity related to it has a significant impact on its performance. You might need to analyze the server’s CPU utilization, network bandwidth, number of connections that it serves at the same time and so on.

AWS provides a monitoring service called CloudWatch, which would enable you to monitor different metrics for the servers your application is hosted on and store these metrics for later analysis. However, your application might be generating custom internal logs that are related to different business events: are they executing as expected, how…


Improve your Docker game

Image by Wallpaper Flare

A Docker Container is a lightweight executable program that includes everything from a runtime to system tools and libraries to run an application. When containerizing an application, we might often need to execute different commands inside the container — e.g., for debugging purposes or for running the application manually.

There are three ways to execute different commands inside a Docker container, and I’ll discuss each method in this article.

Using ‘CMD’ in the DockerFile

When building an image for an application, we need to specify a Dockerfile that’d contain instructions on how this image is going to be created and what application it’s going to…


Monitor, Lock and Semaphore

Photo by Christian Wiediger on Unsplash

Running multiple concurrent threads requires special attention when they access (perform read and write operations) the same memory block. The piece of code where this memory access happens is called a critical section, and thread access should be synchronized in order to avoid a race condition. In Java, synchronizing the access to critical sections can be done using different mechanisms: Monitor, Lock and Semaphore.

In this article, I will give a thorough comparison between these mechanisms, while trying to synchronize the well-known Producer-Consumer problem. The following code shows the basic Buffer data structure implementation. …


Using virtual scrolling

Photo by niko photos on Unsplash

Displaying long lists of items in a client application requires strict attention, as it’s well-known that the application performance can degrade rapidly while trying to render lists with hundreds or even thousands of items.

This happens since the browser must render the entire page and all the data inside it upfront, before showing it to the end-user, and as such, rendering thousands of items in a list would lead to great frustration.

Fortunately, we can use the virtual scrolling technique to address this problem.

From a high-level perspective, virtual scrolling allows the client to render just a small portion of…


Deliver private content through S3 and CloudFront

Photo by Dayne Topkin on Unsplash

When trying to design a solution architecture where the application can generate and store private files on a storage option like S3, and allow the possibility for these files to be accessed by specific users for a certain amount of time, and still remain private, we could follow two different approaches based on a real use case scenario.

Let’s write down some use cases and see how we can approach the best solution:

  1. An application that converts audio files from one format to another, allowing the user to download the converted file via a link that expires after five minutes.

Nasi Jofche

Software Engineer | AWS Solutions Architect

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store