Whether you’re a traffic-heavy media site or a small simple e-commerce site that foresees a wave of traffic coming its way, you will find Elastic Load Balancers incredibly useful to keep your ship from tipping. With that in mind, I decided to ask the web and our engineering team for a few tips and tricks that will ensure you’re making the most out of your ELBs:
DON’T put all your eggs in one basket
When using ELB’s, it pays to be secure and spread the load across multiple zones so that, should a zone fail, the load balancer would act as a guard; stopping anything being sent to the bad zone and routing it to other zones.
DO request to pre-warm ELBs
Expecting a spike in traffic? While AWS ELB’s are designed to handle large (20k/sec) loads when the level reached this gradually (several hours), it struggles when traffic spikes this high in shorter periods (several minutes). If you’re expecting the latter, simply call Amazon Web Services support team and request that they pre warm it to make the increase gradual and facilitate the ELB.
DON’T be confined to just HTTP
Aside from HTTP, ELBs can also be used with HTTPS (secure HTTP), TCP and SSL (secure TCP).
DON’T get timed out
Running a process that leaves your ELB idle for a while (e.g. generating large reports through EC2)? Try to send something on the socket every 40 seconds while you’re waiting in order to avoid your ELB timing out.
DON’T get blindsided by infrastructure hotspots
If requests are coming from a single IP or similar IPs (in a range), it will not conduct a round robin regularly, instead putting all of these towards a single EC2 instance or, in a multi-tenancy model, a single availability zone. This is a result of the ELBs basing affinity on IP addresses and can cause unexpected hotspots in your infrastructure. This can commonly happen during load tests and thus it is advisable to load test on multiple distributed agents.
DON’T expect ELBs to work multi-region
Though they let you balance between zones in a region, ELBs don’t let you balance between different regions. So, if you’re multi-region, you are better off balancing between different instances within each region, or, if you need to balance a load between 2 regions, you can use AWS Route 53 DNS RR/LBR.