Image for post
Image for post
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

Image for post
Image for post
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

Image for post
Image for post
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

Image for post
Image for post
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 for post
Image for post
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

Image for post
Image for post
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

Image for post
Image for post
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

Image for post
Image for post
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.


Using user-defined private keys

Image for post
Image for post
Photo by Chris Barbalis on Unsplash

AWS S3 storage offers four ways of server-side data encryption:

  • SSE-S3, where the encryption keys are managed by AWS.
  • SSE-KMS, where the encryption keys are managed by AWS KMS, offering control over the key rotation policy.
  • SSE-C, where the user/uploader provides the encryption key.
  • Client-side encryption, which uses the S3 encryption client.

Suppose that we are building a web application that would store data on S3, and that data should be encrypted using a private key that would be only known to the application.

In this scenario, we would utilize SSE-C data encryption, where the application is responsible for creating…


In Javascript applications

Image for post
Image for post
Photo by Glenn Carstens-Peters on Unsplash

One common misunderstanding, especially when testing reactive streams, is treating synchronous data sources as asynchronous. In this post I will try to explore the differences between synchronous and asynchronous data sources, along with respective examples in RxJS.

Synchronous data sources

Every reactive library offers the possibility to create a stream from different types of data. For this example, we are going to take into consideration a simple array [2, 12, 35] that will be wrapped into an observable:

const sourceA = from([2, 12, 35]);
sourceA.subscribe(console.log);
Output:
2
12
35

This example indicates that when the observable is subscribed to, the values of the…

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