How to setup load balancer with Elastic file system (EFS) in AWS? Part 1

5 min read. Feb 27, 2022

A couple of  weeks back, I had an opportunity to setup application load balancer in AWS and use elastic file system as network attached storage between the servers behind the load balancer. I had to juggle through multiple resources such as AWS documentation, medium articles, stackoverflow threads and YouTube videos as I could not find a single resource that guide me through the process. So, this is my attempt to connect the dots and sum up all the steps that I followed to configure load balancer with EFS in a single resource. As a single article would be too long to include all steps, therefore I'll be writing four part series article to describe the steps. 

In this first part, we're going to review the basic terminologies that are important to understand in order to configure the load balancer with elastic file system. Apart from that, we'll also review the architecture of our cloud infrastructure.
Every definitions on this article are taken from AWS documentation and other reliable resources.
All right, let's get started.

Basic terminologies

1. Load balancer

According to Nginx, "Load balancing refers to efficiently distributing incoming network traffic across a group of backend servers, also known as a server farm or server pool".  A load balancer can be essential when the traffic on the web application grows in order to avoid application downtime. 

2. Virtual private cloud

"A virtual private cloud (VPC) is a secure, isolated private cloud hosted within a public cloud" as stated by Cloudfare. A virtual private cloud allows to enforce multiple layers of security for the resources within it. In relation to elastic load balancer, all requests and responses to/from the web application passes through the load balancer therefore, only the load balancer can be hosted on internet facing public subnetwork while the web servers can be hosted in a private subnetwork with no internet access. 

3. Subnet/Subnetwork

According to Cloudfare, "subnet or subnetwork is a network inside a network". A subnet consists of a range of IP addresses which are subset of it's parent network. While configuring elastic load balancer, we can create multiple subnets inside the VPC and host an isolated server in each of them.

4. Availibility zones

In cloud computing, an availability zone is one or more isolated data center(s) which are backed by redundant power supply to avoid downtime in case of failures. The leading cloud service provider, AWS, has multiple availability zones in each AWS region. Similarly, Microsoft Azure follows the same.

5. Network attached storage

As stated in Red hat documentation, "Network-attached storage (NAS) is a file-level storage architecture that makes stored data more accessible to networked devices". An example of network attached storage is an Elastic file system (EFS) in AWS. Data stored in elastic file system can be accessed from multiple servers (EC2 instances).


Architecture of cloud infrastructure

Image: Architecture of elastic load balancer with EFS (Image inspired from: AWS blog )

Before configuring load balancer, it is really important to understand the architecture of the cloud infrastructure. As you can see in the above diagram, the load balancer act as a single point contact for the end users as opposed to the traditional web architecture where users directly interact with the web server. The loadbalancer is launched in the public-facing subnet so that end-users can access through internet. Similarly, the web servers (EC2 instances) are lunched in the subnet of different availability zones in order to increase the availibility of the web application.

Apart from that, the elastic file system is mounted on each of the EC2 instances so they both can read and write to/from the storage. The benifit of this approach is that we can deploy our code on the mount point of just one of the server and the application will be available on both of them. 

Lastly, we have all of our resources (load balancer, EC2 instances and EFS) within the virtual private network which adds additional layer of security to the infrastrucutre.


Wrapping up

Configuring application load balancer in AWS can be quite a challenging task if you don't have much experience in cloud services. The basic terminalogies in the above article may help to understand a bit about the moving wheels on configuring load balancer. In addition, the architecture diagram of the load balancer with EFS configuration can help to grasp a clear picture of the whole process. I hope this article was helpful.
See you in the next series of configuring load balancer.