Implementation and deployment of a Scalable Web Application using the services of AWS Elastic Beanstalk, DynamoDB, CloudFront and Edge Locations.

Olusegun Omotunde
8 min readSep 21, 2023

--

Project Description:

In this project based on a real-world scenario, I was responsible for implementing an application that needs to support the high demand of a large number of users accessing it simultaneously. This application has been used in a large conference that had more than 10,000 people, in-person and online, with participants from all over the world.

This event was broadcast online and in person and 10 vouchers were drawn for 3 Cloud certifications. At that moment, more than 10,000 people in the audience registered their e-mails to guarantee their participation in the raffle.

I used AWS Elastic Beanstalk services to deploy the web application, DynamoDB to store emails, CloudFront to cache static and dynamic files in an Edge Location close to the users.

Implementing the Application Solution:

This project solution is divided into threeparts:

  • Creating, Setting Up the DynamoDB and deploying the web application using AWS Elastic Beanstalk and setting up AWS AutoScaling.
  • Creating a Cloudfront Distribution to cache the Web Application closer for faster access by global users.
  • Web application performance and load testing.
AWS DynamoDB

AWS DynamoDB is a fully managed NoSQL databse services that provides fast and predictable performance with seamless scalability. This DynamoDB database will be used in this project for storing the users information in form of email adddresses entered by the attendees for the conference and it can easily scale up with the increasing demands of the web application in this project. In the DyamoDB, I will create and name a table and define it’s primary key.

creating a table in DynamoDB

AWS Elastic Beanstalk is a web service for deploying and scaling web applications and services. Elastic beanstalk simplifies the deployment of web application.

AWS Elastic Beanstalk

Autoscaling is a AWS service that continously monitors application performance and automatically adjusts application capacity to maintain steady and predictable performance at the lowest cost possible.

AWS Autoscaling

AWS Cloudfront is a content delivery network (CDN) service built for high performance, security and developer convenience. Cloudfront caches web content data, helps reduce latency and increases data retrieval performance.

AWS Cloudfront
Elastic Beanstalk

Creating, Setting Up the DynamoDB and deploying the web application using AWS Elastic Beanstalk and setting up AWS AutoScaling

For the elastic bean stalk, I took the following steps to create the web application:

  • I named the application and environment for the application
  • I defined the platform as a managed python platform
  • I defined the source code origin and imported my python file
  • The web application was configured to run in us-east-1 region with high availability
  • I used the defult vpc on aws, added IP address, selected all subnets
  • In the instance traffic and scaling settings, I configured my root volume type to be general purpose (ssd) with a size of 10gb
  • I set my scaling trigger to CPUUtilization, unit is Percent, period is 1min with the upper threshold as 50 percent and lower threshold as 40 percent with the scale up and scale down increments set to one ec2 instance. This means when when the CPU utilization is greater than 50 percent, the dynamic auto scaling will be triggered and a new ec2 instance will be created to ensure that one ec2 instance is not overwhelmed. When the CPU utilization falls below 40 percent, it means the workload is small and we can scale down by one ec2 instance.
elastic beanstalk settings
elastic beanstalk settings
elastic beanstalk settings
elastic beanstalk settings
elastic beanstalk settings
elastic beanstalk settings
elastic beanstalk settings
elastic beanstalk settings
elastic beanstalk settings
Settings review
Elastic Beanstalk is launching the application
Succesful deployment of the Conference web application

From the picture above, the web application as been created succesfully.

Error message after trying to enter data trough the web application

The next thing I did was to test whether the web application was deployed successfully with all the configurations set up correctly. The web application was deployed successfully but when I tried to enter data by adding a user to the database, an error occurred. To troubleshoot and debug this error, the logs from the elastic beanstalk was downloaded for one of the ec2 instance. The error message wasA role not authorized to put data in database error”. I resolved this error by using a IAM role and attaching a policy with the DynamoDBFullAccess permission to the AWS elastic beanstalk ec2 role. After this correction, I was able to add a user to the DynamoDB database using the web application.

Adding the DynamoDBFullAccess Permission to Elastic Beanstalk Ec2 role

Everything is working perfectly now, the web application has been successfully deployed and data can be added to the DynamoDB database.

Creating a Cloudfront Distribution to cache the Web Application closer for faster access by global users

For this project, There are global users joining from various countries who will be attending the web conference and to help deal with latency and provide faster access of this applications to global users, I will create and configure Cloudfront Distribution service.

AWS CloudFront Service

I took the following steps to create the Cloudfront distribution:

  • I chose my elastic load balancer as my origin domain
  • I selected HTTP and HTTPS as the viewer protocol policy and the allowed HTTP methods included: GET, HEAD, OPTIONS, PUT, POST, PATCH, and DELETE.
  • My cache policy was CachingOptimized and I enabled security protections.
Cloudfront distribution configuration
Cloudfront distribution configuration
Cloudfront distribution configuration
Cloudfront distribution configuration
Cloudfront distribution configuration
Cloudfront distribution configuration
Cloudfront distribution configuration
Cloudfront web application
DynamoDB Table

I verified the cloudfront application by opening the domain name and entering new data.

Web application performance and load testing

The web application has been succesfully deployed and worked in Elastic Beanstalk and using Cloudfront. I need to test the performance of the web application now and ensure that it can scale up when the demand rises or CPU Utilization increases and scale down when CPU Utilization reduces. Looking at the EC2, two instances are running succesfully as expected from the configuration of the Elastic Beanstalk. The health of the web application is also good, and no error message is detected. To test the performance of the web application, I need to ncrease the CPU stress and increase the load. In my terminal on my local computer, I connected to the Elastic Beanstalk using one of the ec2 instances. I checked all the running prcoesses first then I then ran the command “stress -c 4” which is used to apply stress to a computer’s CPU by launching four worker threads that will perform tasks designed to consume CPU resources. Each worker thread will simulate CPU-intensive tasks, which can be useful for testing the system’s stability, monitoring system performance under heavy load, or conducting stress tests.

After running the load test, I got a Warning status in my elastic bean stalk environment which showed my CPU Utilization at 100% and after some minutes a new ec2 instance was created and added. Looking at the settings now, three ec2 instances are running instead of the minimum 2 ec2 instances specified in the elastic beanstalk configuration. After a while the warning message disappears. This shows that the web application is scaling up and down effectively as the CPUUtilization increases and reduces without any error and working well.

connecting to elastic beanstalk in terminal
load test on web application
listing all the running processes
All the running processes
elastic bean stalk health warning
elastic bean stalk health warning
elastic bean stalk health warning
elastic bean stalk health warning
Health information of Elastic Beanstalk
Elastic beanstalk ELB load balancing

SERVICES & TECHNOLOGIES USED

In this project, I used a wide variety of services and technologies on Amazon AWS. Amazon Elastic Beanstalk was used to create and deploy a web application. Amazon Auto Scaling was used to monitor the web application performance and automatically increase or reduce the Web application capacity based on CPU Utlilization. A NoSQL Amazon DynamoDB database known for high performance and scalability was created to store the users emails. Amazon Cloudfront distributed this web applications to edge locations around the world for faster access by users and to reduce latency.

--

--

Olusegun Omotunde

Data Engineer with focus on Cloud & DevOps | AWS | Microsoft Azure | Google Cloud | Oracle Cloud |