3

I've looked into a lot of back end setups on Amazon Web Services, especially that of Instagram's. On their Instgram Engineering Blog they mentioned how they have an Elastic Load Balancer in front of their three NGINX servers which is front of their app servers which run django/Gunicorn, why is that (is it for buffering? caching?)

If that is the case, how can one connect those NGINX servers to the django/gunicorn app servers?

deadlock
  • 185
  • 2
  • 8

2 Answers2

3

Glancing at the Instagram post, I don't believe they're using Nginx for buffering or caching (although I could be wrong). I use something similar but with HAProxy instead of Nginx.

Some of the reasons why we took this approach:

  • Nginx and HAProxy operate at layer 7, whereas ELB is later 4. If you need layer 7 services, ELB can't provide it
  • Graceful connection termination when health checks fail. The ELB can continue passing traffic to HAProxy/Nginx while traffic is bled off of the out-of-service instance. See https://forums.aws.amazon.com/message.jspa?messageID=231571
  • You can scale out the load balancing layer live if necessary
  • Better metrics about traffic and performance of each instance behind the HAProxy/Nginx layer
  • ELB can detect when an HAProxy instance has failed and stop sending traffic to it
Shane Meyers
  • 1,008
  • 1
  • 7
  • 17
2

A few points I can think of:

  1. It distributes requests and monitors health of the servers, so if one of your nginx servers crashes the site continues working flawlessly.
  2. Amazon does some denial-of-service mitigation on their end. If you handle load balancing yourself, you're going to pay for all of the traffic hitting them. If Amazon blocks some attacks pointed at your ELB, you're not paying for that part.
  3. Allows you to lock the nginx servers' security groups to just the ELB, making them more secure than having them open to the public Internet.
ceejayoz
  • 32,910
  • 7
  • 82
  • 106
  • Hi, this somehow opened a few more eyes for me. Especially your point (2). I didn't think of that doing the load balancing by ourselves could cost more than which handled by ELB. Is that true? And if then, i would have wasted a lot of money by that already. :( – 夏期劇場 Jan 18 '16 at 10:43