Scenario
A client is seeking assistance with their website's performance issues.
The client's website:
Is a SPA React application backed by Python and Flask.
Uses PostgreSQL as the database.
Runs off a single AWS EC2 instance (t3.medium, 4GB of RAM).
The client's website is experiencing slow response times during peak periods and occasional server crashes due to insufficient memory. Additionally, they face downtime during deployments and lack a disaster recovery plan. Anticipating continued growth, they are seeking an architecture that could address these challenges while remaining cost-effective.
The client's requirements:
Improve website performance, including reducing response times during peak periods.
Eliminate server crashes due to insufficient memory.
Minimize downtime during deployments.
Implement a disaster recovery plan.
Design a scalable architecture that can accommodate future growth.
Remain cost-effective.
Proposal
The proposed architecture centres around Elastic Beanstalk, which conveniently consolidates HTTP load balancing, application servers, and database servers under a single management framework. By harnessing the power of Elastic Beanstalk, these components can be independently scaled, enabling effortless adjustment of resources allocated to the database server without disrupting the app server, and vice versa.
Architecture Diagram
Choice of AWS Services
Amazon Route 53: This fully managed DNS service will seamlessly connect the client's domain name to the load balancer, enabling automatic routing adjustments.
AWS Elastic Beanstalk: The application will be deployed to Elastic Beanstalk where simple command line tools are provided for application deployment. Minor code configuration adjustments may be necessary for compatibility with Elastic Beanstalk. Additionally, I have considered utilizing Code Pipeline (more details to follow) to further streamline the deployment process.
The Elastic Beanstalk environment is in three parts: Elastic Load Balancer, EC2 Compute Instances and an RDS PostgreSQL server.
Elastic Load Balancer: To enhance redundancy and scalability, Elastic Beanstalk incorporates a load balancer that effectively distributes traffic across multiple EC2 instances within one or more availability zones.
Amazon EC2 Auto Scaling Group: The main benefit of using Elastic Beanstalk lies in its seamless integration with EC2 to automatically scale the number of instances the application runs across. This mechanism dynamically adds or removes instances based on the application's load fluctuations. This dynamic scaling proves particularly beneficial when the application experiences peak demand periods, ensuring you only pay for the infrastructure capacity actively utilized.
Amazon RDS (PostgreSQL Server): Elastic Beanstalk seamlessly integrates with RDS to automatically set up and manage the PostgreSQL database.
Amazon S3: S3 serves as a versatile storage solution for RDS backups and file backups. Additionally, it can be seamlessly integrated to serve static files or media in the future, accommodating the application's potential growth requirements.
Multiple Availability Zones: To enhance redundancy, the application has been deployed across multiple availability zones (AZs). To further safeguard against potential disruptions, an additional RDS instance has been configured, enabling real-time replication from the production instance.
AWS Code Pipeline: As the application's user base expands globally, scheduling maintenance windows for downtime during deployments may become increasingly challenging. To address this, we can employ Blue-Green deployments, which involve creating a new Elastic Beanstalk instance for a new application version. The existing production environment, referred to as the Green environment, continues to operate while the new environment (Blue) is being deployed. Once the Blue environment is fully operational, the production URL is redirected to point to it, seamlessly transferring user requests to the new version. The Blue environment then becomes the new production environment, and the previous production environment can be safely decommissioned.
This process can be executed manually or automated using Code Pipeline, which integrates seamlessly with Elastic Beanstalk. CodePipeline can also replace an existing CI/CD pipeline if one is already in place.
Costs
Monthly costs will remain relatively consistent. For instance, the RDS instance price remains fixed until it's resized to a smaller or larger instance. Similarly, if the same EC2 instance(s) is utilized throughout the month, their cost remains constant regardless of the number of requests. Other components, such as the Load Balancer, will incur costs as the number of requests increases.
Once the client has a clearer understanding of the anticipated request volume and resource requirements, concrete pricing estimates can be provided using the AWS Pricing Calculator.
Conclusion
In response to the client's specific requirements, I've created an architectural diagram that outlines how to effectively utilize additional AWS services to elevate the application's current performance, seamlessly accommodate future growth, and streamline the deployment process.