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). WillVarnish
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.
The ELB can still serve a purpose in that it:
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.
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:
But you'll have to:
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
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.
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.