Simple Scalable Cloud Architecture for Apache2/MySql Application

Problem Statement


A LAMP application with approx. 500 users were facing slow/connection and spike issues with connecting to their accounts via web or mobile devices. Root cause analysis shows that the existing MySQL database is hosted on the same EC2 as the web server along with many other services which it shares cpu/ram/iops resources.

The present server has reached the end-of-life limits for the concurrent user base.


Solution

Izumo proposes a new load balancer architecture along with security.




Database

QLOUD

Moving MySQL from the shared EC2 hosted server to Aurora (mysql). Aurora is a scalable RDBS which is compatible with MySQL and easily portable with some minor changes.Aurora uses read replicas which has two main purposes. You can issue queries to them to scale the read operations for your application. You typically do so by connecting to the reader endpoint of the cluster. That way, Aurora can spread the load for read-only connections across as many Aurora Replicas as you have in the cluster. Aurora Replicas also help to increase availability. If the writer instance in a cluster becomes unavailable, Aurora automatically promotes one of the reader instances to take its place as the new writer. Aurora has a read-replica as well as a horizontal/vertical scalable architecture which can handle loads up and above 1 million users based on the DB schema.

Elastic Load Balancer

QLOUD

Elastic Load Balancing automatically distributes your incoming application traffic across all the EC2 instances that you are running. Elastic Load Balancing helps to manage incoming requests by optimally routing traffic so that no one instance is overwhelmed.After attaching a load balancer to your Auto Scaling group, you can configure your Auto Scaling group to use Elastic Load Balancing metrics (such as the Application Load Balancer request count per target) to scale the number of instances in the group as demand fluctuates.



Auto Scaling Groups

QLOUD

helps in scaling PHP/MySQL application based on demand. ASG monitors applications and automatically adjusts the capacity to maintain steady, predictable performance. Since scaling is based on demand, the servers are terminated once the demand drops, and servers are scaled down. Auto Scaling also leads to better fault tolerance and high availability for PHP/MySQL application.

Github Pipeline

QLOUD

PHP/MySQL code which is hosted on github will be pulled each time there is a new Scaling group that is deployed. Each time the load balancer launch’s a EC2 to route traffic to the new server, the server will launch and pull the code from the master branch from the designated repo. 。 We would not be able to use a AMI since there might be code drift in case of any code changes in primary and additional servers using AMI’s.



Cloudfront

QLOUD

CDN will serve static CSS/Image files for all requests with low latency based on the user location. The files are located in a S3 bucket. This helps in improving the downloading speed of these static contents.

WAF

QLOUD

Offers rules to inspect any element of a web request. AWS WAF protects web applications against threats by filtering traffic according to the rules created. WAF rules for CSS, SQL Injections, DDOS will prevent attacks on PHP/MySQL application.