HA Arhictecture: High Availability
ELB, ALB (Elastic Load Balancer, Application Load Balancer)
a physical/virtual device designed to balance network load across multiple web servers
at least 2 public Subnets are required when provisioning a load balancer
ELBs do not have a pre-defined IPv4 addresses; you resolve to them using a DNS name
types of load balancers
Application Load Balancers
Best suited for HTTP / HTTPS traffic
Operates at Layer 7
Application-aware
Advanced request routing, sending specified requests to specific web servers
Register target groups
Load balancing rules are supported
Network Load Balancers
Load balancing TCP traffic
Operates at Layer 4
Capable of handling millions of requests per seconds with ultra-low latencies
Classic Load Balancers
Legacy / previous generation load balancers
HTTP / HTTPS / TCP traffic
Operates at layer 4, supports
Layer-7 specific features, such as X-Forwarded and sticky sessions
Errors: 504 - Gateway timeout - ec2 instances are not responding
Registers instances
Health Checks
Checks the instance health by talking to it
Instances are reported as InService, OutofService
LBs have their own DNS name. You are never given an IP address
Connection Draining - the number of seconds to allow traffic to be flowing (300 seconds by default)
Auto-Scaling
Auto-Scaling Group
subnets should be assigned - instances will be distributed on these subnets
Scaling Policy
Target tracking scaling policy
Simple scaling policy
Scaling policy with steps
Scaling warm-up time
the time required to warm up an instance - during this time instance won’t contribute to the metrics
When deleting the auto-scaling group, the instances beneath it will be deleted as well.
Launch Configuration
IP Address Type
Default public IP assignment (as per subnet)
Assign public IP to every instance
Do not assign a public IP to an instance
HA Architecture
You should plan for failure
Netflix (Simian Army Projects)
Injecting failure into production systems
(https://medium.com/netflix-techblog/the-netflix-simian-army-16e57fbab116 )
More than one AZ should be used (2 AZs at least)
Always Design for failure
Use Multiple AZ’s and Multiple Regions wherever you can
In RSD Read Replica - creates a replica of AWS for performance purposes and not for HA
Multi-AZ configuration means replication across different AZs supporting seamless failover
Scaling out - adding ec2 instances using ASGs
Scaling up - increasing resources of ec2 instances (modifying instance type)
S3 storage classes
Highly Available
Standard S3
Standard S3 Infrequently access
Non-HA
Reduced redundancy storage
S3 single AZ
HA Wordpress Site
2 x Cloud Front distributions
Cloud Front distribution for static media content
Cloud Front distribution for the main site
2 x S3 Buckets
S3 Bucket for media
S3 Bucket for code synchronization
RDS MySQL/Aurora with Mutli-AZ enabled
Writer Node
LAMP installed
CRON commands
Sync/var/www/html/wp-content/uploads to media bucket
aws s3 sync –delete /var/www/html/wp-content/uploads s3://bucket-for-media-name/
Sync /var/www/html to code bucket
aws s3 sync –delete /var/www/html s3://bucket-for-code-name/
Reader Node(s)
LAMP installed
Scales in 3 AZs using ASG, min size is 2 instances
Traffic received by Cloud Front distribution for the main site
Route 53 domain record points at Cloud Front distrbution
ALB is defined as an origin
ALB forwards traffic to Target Groups
On user-data instances will pull the code content from S3 bucket-for-code
Periodically instances will run sync commands to get any updates done to the code from the Writer Node
CRON command
aws s3 sync –delete s3://bucket-for-code-name/ /var/www/html
.htaccess rewrite rule is added to serve the wp-content/uploads files from Cloud Front distribution serving the static media bucket from bucket-for-media-name
Simulating failure
Terminate an EC2 instance
RDS, Multi-az
You may reboot with failover to simulate the failure
This may still take your site offline for a couple of minutes
Is a way of completely scripting your cloud environment
From AWS website:
“AWS CloudFormation provides a common language for you to describe and provision all the infrastructure resources in your cloud environment. CloudFormation allows you to use a simple text file to model and provision, in an automated and secure manner, all the resources needed for your applications across all regions and accounts. This file serves as the single source of truth for your cloud environment.”
https://aws.amazon.com/quickstart/
Built by solution architects and partners
Cloud Formation templates to help you build your production or test environment quickly and starting using it immediately