0

I'm still kinda novice but now i'm on AWS/EC2 Redhat Machines. I have:

  • 1x Load Balancer (Above)
  • 2x EC2 Apache Web Servers (Below)

Something like:

    LB
    |
 -------
 |     |
Web   Web

Then now if i going to put the 1x Varnish infront of 2x Web Servers:

  • What will the placements be?

Please suggest, and will it be like:

    LB
    |
   [V]
 -------
 |     |
Web   Web

Is it?
So here again my questions are:

  • If yes, the original LB is not very useful already (i suppose). Will Varnish be the Load-balancer again here?
  • Then, does it mean, I do NOT NEED default EC2 Load-Balancer anymore?

Please guide me the proper placement and share the logic.
Thank you so.

1
  • Are any of the answers acceptable for you? Nov 1, 2013 at 2:31

3 Answers 3

2

The ELB can still serve a purpose in that it:

  1. Can be configured to automatically replace the Varnish server if it dies by configuring an AutoScaling Group.
  2. Allows you to pull servers in and out of service by adding a new one then dropping the old one. This means there is no interruption to service for clients.
  3. Could allow you to trivially add more than one varnish server if your load ever got high enough to need it.
  4. Can act as a gateway to your backend Varnish server(s) residing in a Virtual Private Cloud (VPC)

All of these can probably be configured without the ELB but the clincher for me was handling SSL at the load balancer. Varnish will not handle SSL for you so you can get the Load Balancer to deal with it and talk http to your Varnish server.

2

There are a number of configurations available. Each configuration has certain benefits and drawbacks that you need to evaluate (such as performance, maintenance, ease of setup, scalability etc).

For the Load Balancer you can use ELB from Amazon, and/or your own Nginx/HAProxy solution. You van use one (or more) Varnish Server(s), and these can either be on their own machine, or Varnish can be installed and run on the same server as your Web Tier.

Varnish on Web Servers

A simple setup would be to varnish Installed on the Web Servers.

           LB
           |
     ---------------
     |             |
Web&Varnish   Web&Varnish 

While this has the drawback of not allowing you to scale your web independently from varnish it's is quicker to setup and to understand. It also simplifies your architecture. This approach may work very well for you. I imagine you will outgrow this at some point as it have some very obvious scalability issues.

2

As ianjs says, ELB could still play a role in your setup... it all depends on your needs (auto-scaling, SSL endpoint, redundancy, etc.). See how others have faced similar problems [1] [2]

Meantime, if you want to take advantage of Varnish as cache you'll need to place it between your load balancer(s), if any, and your backends (using consistent hashing [3] if there is more than one Varnish instance involved), but the architectural can turn quite complicated when you want to scale it horizontally (there is a nice example with HAProxy [4]).

So, if you're going for 1 Varnish instance and 2 Backends (without auto-scaling, ssl and none of Amazon's advanced features) you can stay simple and get rid of ELB:

  Varnish
     |
 ---------
 |       |
Web1   Web2

But you'll have to:

  • Choose a proper director [5]
  • Deal with backend healthchecks [6]

So it's up to you to choose the architecture that best suits your needs.

[1] https://stackoverflow.com/questions/14167561/using-an-aws-elb-behind-varnish-is-it-possible

[2] http://cloudreach.blogspot.com.au/2013/01/varnish-and-autoscaling-love-story.html

[3] http://en.wikipedia.org/wiki/Consistent_hashing

[4] http://blog.exceliance.fr/2012/08/25/haproxy-varnish-and-the-single-hostname-website/

[5] https://www.varnish-cache.org/docs/3.0/reference/vcl.html#directors

[6] https://www.varnish-cache.org/docs/3.0/reference/vcl.html#backend-probes

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .