ELB Load Balancing (High Availability and Scalability) Flashcards
scalability
your application can handle greater loads by adapting
two kinds of scalability
vertical
horizontal (=elasticity)
vertical scalability
increasing the size of the instance
if your app runs on t2.micro, scaling means running it on t2.large
vertical scalability use cases
non-distributed systems such as a database
RDS, ElastiCache
horizontal scalability
increase the number of instances / systems for your application
distributed system
common for modern web applications
high availability
usually goes hand in hand with horizontal scaling but not all the time
you run your app in at least 2 data centers (== AZ in AWS) in order to survive a data center loss
can be passive (RDS multi AZ) or active (horizontal scaling)
RDS
Amazon relational database service
is a web service that makes it easier to set up, operate, and scale a relational database in the AWS Cloud.
Multi-AZ
Amazon RDS provides high availability and failover support for DB instances using Multi-AZ deployments.
In a Multi-AZ deployment, Amazon RDS automatically provisions and maintains a synchronous standby replica in a different Availability Zone.
high availability for EC2
run instances for the same application across multi AZ
Autoscaling Group multi AZ, Load Balancer multi AZ
horizontal scalability for EC2
increase number of instances (scale in or scale out)
Autoscaling Group
Load Balancer
Amazon ElastiCache
Amazon ElastiCache is a web service that makes it easy to deploy, operate, and scale an in-memory data store or cache in the cloud. The service improves the performance of web applications by allowing you to retrieve information from fast, managed, in-memory data stores, instead of relying entirely on slower disk-based databases.
load balancers
servers that forward internet traffic to multiple servers (EC2 instances) downstream
available on the left panel Load balancing
why should we use load balancers
- we can spread load across instances and expose a single point of access to your app, DNS.
- we dont need to know about all the EC2 backend instances, we just need to know the single point of access, the host name of your balancer.
- LB will perform regular health checks to your instances so it knows when not to send traffic to your instances
- provide SSL termination (HTTPS) for your website
- enforces stickiness with cookies
- high availability across availability zones
- separate public traffic (user - to LB) from private traffic (LB to EC2 instances)
why AWS load balancer
- it’s a managed LB. AWS guarantees that it will be working, takes care of upgrades, maintenance, high availability
- although costs less to set up your own, a lot more effort on my end
- integrated with many AWS offerings and services
health checks
enables LB to know if the instances it sends traffic to are available to reply to requests in a good way
done on a port and a route (/health is common). If the response is not 200 OK, the instance is deemed unhealthy
you can configure how often
three types of load balancers
- classic LB (v1 old generation) - 2009
- application LB (v2 new generation) - 2016
- network LB (v2 new generation) - 2017
it is recommended to use the 2 last of the new generation, provide more features
classic load balancer
supports TCP, HTTP and HTPPS traffic
health checks are TCP or HTTP based
fixed hostname
application load balancer
- supports HTTP, HTPPS and WebSocket traffic
- only layer 7 LB
- fixed host name
-
network load balancer
supports TCP, TLS (secure TCP), UDP
internal (private) LB
private within your account, you can’t access it from the public web
external (public) LB
will allow your users to access for ex., your website
load balancer security groups
- create security group on LB with inbound rules allowing HTTP (port 80) traffic and HTTPS (port 443) from any users from any IPs
- create security group in EC2 instances that allows incoming traffic only from LB. In the security group we can reference the security group we created on LB in step1
load balancer and scaling
LB can scale but not instantaneously - contact AWS for a warm up
load balancer troubleshooting
- 4xx are client induced errors
- 5xx errors are app induced errors
- 503 means at capacity or no registered target
- if LB can’t connect to your app, check security groups
load balancer monitoring
- ELB access logs will log all requests
2. CloudWatch Metrics will give you aggregate statistics
TCP, HTTP´, HTTPS layers
TCP layer 4
others layer 7
load balancer stickiness
it is possible to implement stickiness so that the same client is always redirected to the same instance behind LB
works for classic and application LB
You are running a website with a load balancer and 10 EC2 instances. Your users are complaining about the fact that your website always asks them to re-authenticate when they switch pages. You are puzzled, because it’s working just fine on your machine and in the dev environment with 1 server.
load balancer stickiness use case
we want to make sure that user doesn’T lose his session data so keep on talking to the same EC2 instance
the cookie used for stickiness has an expiration date you control
enabling stickiness downside
may bring imbalance to the load over the backend EC2 instances
load balancer stickiness configuration
for classic LB it is configured in LB properties
for application LB - at the target group level (left panel –> Load Balancing –> Target Groups), checkbox
you can configure for how long
takes a little bit of time to kick in
cross-zone load balancing
each LB instance distributes evenly across all registered instances in all AZ
(one LB can be deployed in multiple AZ –> hence multiple LB instances)
if cross-zone load balancing disabled, each instance will distribute evenly only in its zone
cross-zone load balancing and classic LB
disabled by default but you will not be charged if you enable it
the setting is on tab Description
cross-zone load balancing and application LB
always on and can’t be disabled but you will not be charged for data crossing AZones
there is no setting to change it
cross-zone load balancing and network LB
disabled by default but you will be charged if you enable it
the setting is on tab Description