Amazon Elastic Load Balancer Setup

May 20th, 2009

As I previously wrote about, Amazon announced a load balancing solution called Elastic Load Balancer.  While this may prove to be a great addition to AWS currently none of the GUI tools (including the AWS Console provided by Amazon) have built in functionality to create ELB instances.

So I became motivated to finally get comfortable with the EC2 API, allowing me to call EC2 commands from my windows command line.  I wrote a post detailing how to setup your command line environment for the EC2 API here.

Now armed with a load balancing solution and a working windows command line I wanted to delve into ELB and see what it has to offer.

ELB Documentation

Amazon Web Services in general has excellent documentation.  ELB is no exception.  Probably the most important document you can read is the ELB Quick Reference Card.  This one page sheet shows you all the ELB related commands and their argument options.

ELB Architecture

First a quick overview of the architecture of ELB.  Think of an ELB instance as sitting in front of  your EC2 instances.  ELB routes traffic to your instances you register to be included with ELB.  The ELB instance has it’s own IP address and public DNS name.

As we can see from the diagram the load balancer directs traffic to different instances, even across different availability zones.

One thing to keep in mind is that the requests are balanced between different availability zones and then evenly between the instances of that zone.  So if you have 10 instances in us-east-1a and 5 instances in us-east-1b your us-east-1b instances will service twice as much traffic per instance.  For that reason it is suggested that you keep your number of instances in each zone roughly equal.

When you create the ELB instance it will give you the public DNS name for the instance.  That DNS name will remain the same for the life of the instance.  You will want to create a CNAME record in DNS to point your branded URL (www.mysite.com) to the “ugly” DNS name that EC2 provides you.

Creating ELB Instance

To create an ELB instance first ensure that your command line environment is configured to work with the EC2 API and the ELB API.  I suggest you read my previous article, Setting Up EC2 Command Line Tools on Windows, if you have never use an EC2 command line tool before.

The command for creating an ELB instance is elb-create-lb.  The parameters available on this command are:

<default> Name of Load Balancer; I suggest you use the DNS name of your public service you will be exposing through this ELB instance
–availability-zones Comma delimited list of zones to allow registered EC2 instances in
–listener “protocol=value, lb-port=value, instance-port=value” This defines which protocol and port the ELB instance will listen on, and which port on the instances to send the traffic to.You can have as many –listener parameters as you want.  For example you could configure an ELB instance to listen on ports 80 and 443.

First lets create an ELB instance to listen for HTTP traffic:

d:aws>elb-create-lb Test  –availability-zones us-east-1a,us-east-1b  –listener “protocol=http,lb-port=80,instance-port=80”

DNS-NAME  Test-1736333854.us-east-1.elb.amazonaws.com

As you can see it returns the public DNS name associated with this instance.

Here we create an ELB instance to listen for HTTP and HTTPS traffic:

D:aws>elb-create-lb Test –availability-zones us-east-1a,us-east-1b –listener “protocol=http,lb-port=80,instance-port=80″ –listener “protocol=tcp,lb-port=443,instance-port=443″

DNS-NAME Test-851384903.us-east-1.elb.amazonaws.com

Notice on the protocols we specify HTTP for HTTP traffic, but TCP for HTTPS traffic.  HTTP and TCP are the only protocols supported.

Create CNAME Record for ELB Instance

When you create an ELB instance it provides you a public DNS name.  However they are not user friendly and you will want to create a CNAME record in DNS to redirect your friendly URL to your EC2 hosted website.

How you create the CNAME record depends on who is hosting DNS for you.  However here is the output of my test website I configured for this tutorial:

D:aws>nslookup

Default Server: ip-172-16-0-23.ec2.internal

Address: 172.16.0.23

>aws.LoudSteve.com

Server: ip-172-16-0-23.ec2.internal

Address: 172.16.0.23

Name: Test-5660601.us-east-1.elb.amazonaws.com

Address: 174.129.195.68

Aliases: aws.LoudSteve.com

If you delete your ELB instance and recreate it you will get a new public DNS name and will have to update your CNAME record.

Register EC2 Instance with Load Balancer

Now that you have an ELB instance you need to register EC2 instances with the load balancer.  The command to register an EC2 instance with the ELB instance is elb-register-instances-with-lb.  The parameters available on this command are:

<default> Name of Load Balancer instance to register EC2 instances with.
–instances Comma separated list of instance ID’s

First we need to get a list of our instances because we need the instance ID to register them with the ELB instance.  We do this with ec2-describe-instances from the EC2 API:

D:aws>ec2-describe-instances

<Lots of Stuff>

INSTANCE i-ed156e84   ami-da4daab3

<Lots of Stuff>

INSTANCE i-ef156e86   ami-da4daab3

<Lots of Stuff>

I removed quite a bit from the actual output to help with readability.  The part you want to focus on is where it says “INSTANCE i-**********”.  That is the information you need for each instance.

To register your instances you run the command elb-register-instances-with-lb:

D:aws>elb-register-instances-with-lb Test –instances i-ed156e84, i-ef156e86

INSTANCE-ID  i-ed156e84

INSTANCE-ID  i-ef156e86

You pass it the name of your ELB instance (Test in this case) and a comma separated list of the instance ID’s of your EC2 instances you this load balancer to route traffic to.

To de-register an instance you run the command elb-deregister-instances-from-lb:

D:aws>elb-deregister-instances-from-lb Test –instances i-ed156e84, i-ef156e86

No instances currently registered to LoadBalancer

It takes the same parameters as the register command.

HTTP vs HTTPS

There is not any information on the behavior between HTTP and HTTPS connections available yet.  But I can tell you what I have experienced with my limited tests.

When using HTTP (protocol=http) it appears to not have any session stickiness.  I loaded two web servers with a Default.htm file.  Each file specified which web server I was hitting.  When I repeatedly refreshed the page it bounced back and forth between the two servers pretty consistently.

When using HTTPS (protocol=tcp) the session was sticky.  In fact I could never get it to fail over to the other node.  When I pulled up the page on a different computer though it did pull up the other web server so I know that load balancing was working.

This is far from an extensive test.  I expect more detailed tests and hopefully Amazon themselves will provide specifics soon.

Instance Health Checks

A good load balancer needs a way to check that it’s nodes are online and traffic should still be routed to them.  Otherwise if a node failed the load balancer would continue to route traffic to them and would cause partial downtime for your site.

ELB checks a file that you specify on a schedule that you specify to determine instance health.  You configure this with the elb-configure-healthcheck command.  The parameters are:

<default> Name of Load Balancer instance to configure health checks on.
–target File to read
–interval How often to perform a health check
–timeout How long to allow the server to respond
–unhealthy-threshold How many consecutive failed checks before marking node as OutOfService
–healthy-threshold How many consecutive successful checks before marking node as InService

Here is an example of configuring health checks:

D:aws>elb-configure-healthcheck Test –target “HTTP:80/status.htm” –interval 5 –timeout 3 –unhealthy-threshold 2 –healthy-threshold 2

HEALTH-CHECK  HTTP:80/status  5  3  2  2

In this example we set the file http://<node IP address>:80/status.htm to be retrieved every 5 seconds.  We allow 3 seconds for the web server to respond.  If it fails to respond after 2 attempts we take the node out of service, if it responds successfully 2 times we put it back in service.

If we run the command elb-describe-instance-health before we configure health checks we will get the following output:

D:aws>elb-describe-instance-health Test

INSTANCE-ID i-ed156e84  InService

INSTANCE-ID i-ef156e86   InService

However once we enable the health checks we get the following output:

D:aws>elb-describe-instance-health Test

INSTANCE-ID i-ed156e84  OutOfService

INSTANCE-ID i-ef156e86   OutOfService

If we looked out our web server logs we would see that the load balancer tried to read the file status.htm and failed.  Once we put that file in place the nodes will go back to being InService.  This is important to note when adding this after you are in production.  You want to have your check file in place before you enable the monitoring.

You should also set that file to not be included in the log file, or you will have an entry in your logs every few seconds while the load balancer checks it’s health.  You should also leave the file blank since there is no reason to increase traffic load with irrelevant data.

Destroying ELB Instance

An ELB instance costs $18/month without even being in use.  Not a huge amount of money, but not something you want to be paying for if your not using it.

To delete an ELB instance you run the command elb-delete-lb:

D:aws>elb-delete-lb Test

Warning: Deleting a LoadBalancer can

lead to service disruption to any

customers connected to the LoadBalancer.

Are you sure you want to delete

this LoadBalancer? [Ny] y

OK-Deleting LoadBalancer

You may want to run elb-describe-lbs to confirm that you no longer have unnecessary ELB instances in place.

Remember if you delete an ELB instance you will not get the same DNS name when you recreate it.  So if you delete it you will have to update your CNAME records to reflect the changes.

58 Responses to “Amazon Elastic Load Balancer Setup”

  1. Anton Says:

    Thanks – great article. One question I have is how to get round the single-point-of-failure at the ELB? Is this handled transparently by EC2, or is there some architecture that can be set-up to provide failover on the load balancer?

    Thanks for any advice.

  2. Steve Says:

    Anton,

    Great question. Assuming that Amazon does their job well you will not have to worry about ELB failure. They make ELB fault tolerant behind the scenes.

    However any system is prone to failure and if they did not implement that (internal) part of ELB well it is prone to downtime. Only time will tell how much we can rely on ELB.

    Another point this brings up is that doing load balancing yourself with EC2 is either prone to a single point of failure or you’re using two instances for fault tolerance. So if you were using two instances ELB is twice as attractive from a price standpoint. However I know several large sites on EC2 that have been using a single instance load balancer without issue, so I’m not sure how common a fault-tolerant load balancing solution is on EC2.

    I was actually half way through working on a script to automatically fail-over from one HAproxy instance to another when ELB came out. Unless ELB is a complete failure I do not plan on ever finishing that script.

  3. Anton Says:

    Thanks for the response Steve, sounds like Amazon have it covered. I’ve seen a number of pages from AWS stating that the ELB is fault-tolerant but I’d love a bit more documentation on how it works… must be the techie in me ;) .

  4. Setting up a load-balanced Oracle Weblogic cluster in Amazon EC2 – The Server Labs Blog Says:

    [...] At this point, although the machines are running in a cluster, we are accessing the two machines totally separately via different DNS names, which is not giving us high availability. We will introduce an Amazon Elastic Load Balancer (ELB) to balance requests between the two managed Weblogic servers. This means that under normal circumstances, requests will be equally distributed between the Weblogic instances. If one goes down, the other will receive all requests. This gives us high availability. Note that my instructions are based on those given in this blog post: http://LoudSteve.com/2009/05/20/amazon-elastic-load-balancer-setup/. [...]

  5. Dhivakar Says:

    Hi,

    Thanks for the great article. It was so helpful for me to setup Elastic Load balancer. Now my question is : How it should be handle when ELB instance was down? it will create an instance automatically or what needs to be done?

    Thanks

  6. Steve Says:

    Dhivakar,

    If (when) ELB has an outage your ELB instance will return once ELB service is restored. Until some time has passed there is no way to know if ELB will be more or less reliable than running your own load balancer on an EC2 instance.

    Considering it’s easier to run a load balancing service than a virtualazation service I think it’s safe to assume that ELB will be more reliable than EC2 is though. Again only time will tell though.

  7. Dhivakar Says:

    Hi Steve,

    Thanks for the information. Is that possible to setup ELB and my website application in single EC2 instance? If it so how it should be handle? or Can you please give me a rough idea that how to setup ELB and Auto-scaling for my Website application. Right now, we are running our environment in single EC2 medium instance and planning to implement ELB, CloudWatch and Auto-scaling on it.

    Sorry for asking you too many questions Since I am a newbie for this features.

    Thanks

  8. Steve Says:

    Dhivakar,

    ELB does not run in or as an EC2 instance. You can use ELB to front a single EC2 instance but you’re better off just using an Elastic IP since they are free.

  9. AndrewBoldman Says:

    Great post! Just wanted to let you know you have a new subscriber- me!

  10. Robert Says:

    Thanks for the instruction. It is very helpful.

    I followed your steps and my instances are always “outOfService”. I checked the access log on the instances and couldn’t find any “health checking” visits.

    Is Amazon LBS reliable?

    Thanks again.

  11. Steve Says:

    Andrew,

    Happy to have you :-)

  12. Setting up a load-balanced Oracle Weblogic cluster in Amazon EC2 « Arquitectura de Sistemas y administracion. Says:

    [...] At this point, although the machines are running in a cluster, we are accessing the two machines totally separately via different DNS names, which is not giving us high availability. We will introduce an Amazon Elastic Load Balancer (ELB) to balance requests between the two managed Weblogic servers. This means that under normal circumstances, requests will be equally distributed between the Weblogic instances. If one goes down, the other will receive all requests. This gives us high availability. Note that my instructions are based on those given in this blog post: http://LoudSteve.com/2009/05/20/amazon-elastic-load-balancer-setup/. [...]

  13. Steve Says:

    Robert,

    In my experience ELB has proven to be reliable. It sounds like your having issues getting the health checks working correctly. What did you configure for your check file?

  14. Robert Says:

    Hi Steve,

    Thank you for your response.

    I finally figured out the problem. I have to set up the load balancer in the same zone where the instances reside.

    I found out that Amazon ELB doesn’t support sticky session. It is a show-stopper for us.

  15. Dhivakar Says:

    Hi Steve,

    Is that possible to point ELB CNAME record to WWW (sub) domain?
    ex :
    http://www.abcd.com IN CNAME test-1034026428.us-east-1.elb.amazonaws.com.

    And, I have been experiencing sometimes that ELB distributes requests to only my first web server rather sending second web server. What would be the reason? I have tested like in your way loaded two web servers with a Default.htm file. Each file specified which web server I was hitting.

  16. Steve Says:

    Dhivakar,

    You can create a CNAME record (or multiple CNAME records) from any DNS name to the ELB provided DNS name. Presumably you’ll want to create CNAME records to redirect both http://www.abcd.com and abcd.com

    When you created the ELB instance did you set the listener protocol to HTTP or TCP? In my experience TCP (used for HTTPS) creates a sticky session.

    If you used HTTP as your protocol and are seeing only one host hit on a regular basis I would double check that elb-describe-instance-health is returning both instances as being online.

  17. Dhivakar Says:

    Hi Steve,

    Thanks for the information. When I created the ELB instance, I had set the listener protocol as HTTP for HTTP load balancer and TCP for HTTPS load balancer as like mentioned above in your article.

    Now my issue is – when I accessing my website, the requests are passing thru ELB and display page sometimes but sometimes error was throwing

    “Data Transfer Interrupted

    The connection to workace.vasatherm.com was interrupted while the page was loading.

    The browser connected successfully, but the connection was interrupted while transferring information. Please try again.

    * Are you unable to browse other sites? Check the computer’s network connection.
    * Still having trouble? Consult your network administrator or Internet provider for assistance.”

    I suspect there is some problem in my ELB settings. but when I checked with the elb-describe-instance-health command it shows my ELB instance as InService.

    Appreciate your help !!!

    Thanks,
    Dhivakar

  18. Steve Says:

    Dhivakar,

    You have this issue with both HTTP and HTTPS?

    If you bypass the load balancer do you have the same issue?

  19. BotchagalupeMarks for June 14th - 08:42 | IT Management and Cloud Blog Says:

    [...] Amazon Elastic Load Balancer Setup | Serk – Amazon Web Services in general has excellent documentation. ELB is no exception. Probably the most important document you can read is the ELB Quick Reference Card. This one page sheet shows you all the ELB related commands and their argument options. [...]

  20. Aniketto Says:

    Hi,

    I am behind a corporate firewall.

    When I tried to run the command elb-create-lb i got following error.

    C:>elb-create-lb IKILoadBalancer –headers –listener “lb-port=80,instance-port
    =8080,protocol=HTTP” –availability-zones us-east-1b
    elb-create-lb: Malformed input-Malformed service URL: Reason: Connection timed
    out: connect –
    https://elasticloadbalancing.amazonaws.com
    Usage:
    elb-create-lb
    LoadBalancerName –availability-zones value[,value...] –listener
    “protocol=value, lb-port=value, instance-port=value” [ --listener
    "protocol=value, lb-port=value, instance-port=value" ...]
    [General Options]
    For more information and a full list of options, run “elb-create-lb –help”

    When I tried to run it from my home it worked well.
    Now,
    1. What firewall settings I need to do to solve above problem
    2. I also set SERVICE_JVM_ARGS=-Dhttps.proxyHost= -Dhttps.proxyPort= =-Dhttp.proxyHost= -Dhttp.proxyPort=

    but it then starded giving me ‘elb-create-lb program error’.

    Aniketto

    Thanks in Advance,
    Aniketto

  21. Steve Says:

    Aniketto,

    To simply this what happens when you run the command:

    elb-describe-lbs

  22. Aniketto Says:

    When I run elb-describe-lbs it also gives me same error.
    i.e. ‘elb-describe-lbs program error’.

  23. Rajshekar Says:

    Hi Steve,

    (1) Does ELB maintains Sticky Sessions, if created as HTTP LB only. if not, what may be the solution.

    I have tested ELB, judiciously spreading load between instances with in the Auto Scaling Group.

    Please clarify the point of sticky session with your experience

    Thanks

  24. Steve Says:

    Rajshekar,

    Right now ELB doesn’t support sticky sessions. There are non-official rumors that it will be added.

  25. Elastic Load Balancing, Auto Scaling, and CloudWatch Resources « LocalLab : Foire aux Infos Says:

    [...] The Serk Tools Blog has a post on Amazon Elastic Load Balancer Setup. The post includes an architectural review of the Elastic Load Balancer service, detailed directions to create an Elastic Load Balancer instance, information about how to set up a CNAME record in your DNS server, and directions on how to set up health checks. [...]

  26. Shlomo Says:

    Nice summary of ELB!

    Readers may also be interested in my article about how ELB works and how to test ELB deployments:
    http://clouddevelopertips.blogspot.com/2009/07/elastic-in-elastic-load-balancing-elb.html

  27. Mike Says:

    Hi Steve -

    I’m a little confused about the Sticky Sessions question. In comment #24, you note that ELB does not support sticky session but in the body of the post (Section “HTTP/HTTPS”) it appears that the HTTPS sessions were sticky.

    Did further testing show different results? Meaning have been able to confirm that HTTPS in NOT sticky?

    Great post by the way – thank you very much.

  28. Steve Says:

    Mike,

    Great question, I’ve been feeling like I need to clarify the state sticky sessions but had not done so yet. Here’s what I’ve found from my experience.

    1. According to Amazon there is no sticky sessions support currently.
    2. According to Amazon adding sticky sessions is a top priority for the next release of ELB.
    3. In my use of ELB I’ve noticed that HTTP sessions are routed to completely random web servers. However in HTTPS sessions they have a strong tendency to use the same web server for the life of that session.
    4. I must admit that I’ve never seen ELB used in production so my observations in #3 might not be accurate. However in testing that is the behavior I’ve seen.

    Sorry I couldn’t provide a more clear cut answer. Once the next version of ELB comes out (no ETA that I’m aware of) I think this issue will be much more worked out.

  29. Mike Says:

    Steve,

    Thanks for the detailed response. We may do some of our own testing on this and I will report back if we have any useful results. It’s strange to me that there isn’t more discussion on this topic. Other than this post and one at the AWS Developer’s Forum (here: http://developer.amazonwebservices.com/connect/thread.jspa?threadID=35479&tstart=15), I haven’t found much.

    In any event, thanks again for the useful posts.

  30. Simple clustering with AWS and (free) RightScale | StyleFeeder Tech Blog Says:

    [...] easier than the raw services in the Amazon interface. If you’re a hard-core command-liner, this blog post and this manual tell you everything you need to know. We’ve gotten into the habit of doing [...]

  31. Winsolin Says:

    Hello All,

    I have a query regarding (“When using HTTPS (protocol=tcp) the session was sticky. In fact I could never get it to fail over to the other node. When I pulled up the page on a different computer”. Written up there.) the sticky session. I have set “–listener “protocol=http,lb-port=80,instance-port=80″ –listener “protocol=tcp,lb-port=443,instance-port=443″ but it dosen’t support the sticky session.

    With reference to AWS ELB docs ELB not support the sticky session. What is the correct one? I need to have the sticky session. It’s very urgent.

    Somebody please give me reply ASAP.
    It’s very urgent…

  32. Steve Says:

    Winsolin,

    In my experience HTTPS sessions are sticky, HTTP sessions are not.

    Amazon is well aware that not having sticky session support is a no-go for many clients and my sources say that it will be implemented in the next version of ELB. I have no timeline on that though.

  33. Jay Says:

    Hello Steve,

    In order to scale up and down according to load do you have to set up your own scripts for registering and de-registering instances with the elb or is that something that can be tied into the elb health check directly? Or perhaps there is some other elegant way of which I’m not aware. Your thoughts are appreciated.

    Jay

  34. Steve Says:

    Jay,

    There is no built in automatic way of adding or removing machines from ELB. If you have an automated process to bring EC2 instances up or down based on load I would think adding the registering/unregistering of EC2 instances in ELB would be trivial.

    If your looking at any kind of help managing your EC2 environment I would look at RightScale.

  35. Amazon Elastic Load Balancer Setup › ec2base Says:

    [...] http://LoudSteve.com/2009/05/20/amazon-elastic-load-balancer-setup/ [...]

  36. guneet Says:

    Hi

    i have setup the load balancer the way its described int eh article
    the heathcheck shows that lb is inService

    however i cannot get to the page
    i have added CNAME for the subdomain as the dns name of the load balancer.

    do i need to create any A record as well
    do i need to mention the lb dns name in the hostheader o fthe IIS server ?

  37. Josh G Says:

    “Data Transfer Interrupted
    The connection to workace.vasatherm.com was interrupted while the page was loading.
    The browser connected successfully, but the connection was interrupted while transferring information. Please try again.
    * Are you unable to browse other sites? Check the computer’s network connection.
    * Still having trouble? Consult your network administrator or Internet provider for assistance.”

    Was this issue ever resolved? We’ve been running simple load testing on our ELB using ab and httperf, and we seem to be getting similar errors. (ab reports differing response length on a page that should be static) We see these errors only when testing on the ELB, and we haven’t yet tested SSL. Further, we see these errors occurring more and more frequently as we increase concurrency.

    Thanks!
    Josh

  38. Bryan Says:

    Hi,
    I have a question regarding security groups and the elb. I would like to limit access to my site (which is behind an amazon elastic load balancer) by ip address, but the security groups don’t seem to let the client ip address through. when I go to the site, they only see the load balancer accessing the website instead, and filter according to that ip. So now, I’ve got a rule to accept the load balancers ip for http and https. This doesn’t allow for ip address filtering by client, which is critical for my app. Is this an intentional feature? is there a way to apply security groups to elb’s as a whole? or would I be better just doing this another way?

  39. Steve Says:

    Bryan,

    I doubt that was on purpose, but more the law of unintended consequences.

    Either way you may find it better to control access to your website via rules in your web server. Right now I can’t think of an elegant solution to use EC2 security rules to do what you want.

  40. Arnaud Says:

    Great post on how to setup/etc!

    You mentioned in the article that balancing is done at a zone level first, then within the zone. I created a ELB with 1 server in each zone, but when testing it appears that only the first server always gets all the requests.

    Healthcheck reports both instances available, and I see access to the “ping” page regularily as defined.

    Is this expected behavior, or is it possible to round robin between zones ?

    Thanks…

  41. Steve Says:

    What happens if you shutdown the instance getting all the traffic? Does the traffic divert to the other instance?

    My initial thought is that if it is configured correctly (which it sounds like it is, especially if the test above passes) your tests are probably just not pushing enough traffic to see it use both nodes. If your just simply hitting it with your web browser you probably are not getting enough concurrent sessions for the traffic to diverge.

  42. Robin Says:

    Hi Steve,

    My Colleague and I both have the same issue as Bryan. We really need to be able to lock down access to the load balancer by security group.

    Not being able to do this prevents us from providing restricted scalable services!!!

    Any ideas on how to get around this?

    Thanks!

  43. Steve Says:

    Robin,

    Thanks for commenting. I don’t have a solution for you unfortunately. I have a few contacts at Amazon and I’ll see if I can get you an answer. At the very least hopefully they can pass the shortcoming along and it can be resolved in a future version of ELB.

  44. Son Nguyen Says:

    Does anyone have an idea when Amazon will offer mapping an elastic IP to the load balancer? CNAME is not a good solution for many (those that want a hybrid solution, mixing EC2 with other clusters for HA, or those that want mapping to the main domain)

  45. Steve Says:

    Son Nguyen,

    I don’t have any details but I do know that Amazon is aware of the shortcomings of the CNAME solution and has a plan in place to resolve the issue. I have no details on how or when they are going to do that though.

  46. Geng Says:

    Good article. I have instances running in all three regions (West, East and Ireland). I like requests coming from those regions to use the ELB instance close to them to reduce latency. I have one single branded URL and all users will access using that URL. Is ELB able to direct traffic based on where the request is coming from? Is that possible to do? Thanks in advance.

  47. Steve Says:

    Geng,

    Your best solution is to use DNS to route clients to the closest webfarm. So you would want a ELB instance in each region (EU-West, US-East, US-West) and have your DNS provider hand out the IP address of the ELB instance which it thinks is closest geographically to the client.

    If you need some guidance around GeoDNS let me know.

  48. David Says:

    I’m seeing that all my logs behind the scenes now register the ELB’s internal IP address 10.x.x.x instead of their public address.

    Is there any way you can pass through the public IP for the ELBs request to the web server instances?

  49. Steve Says:

    Unfortanently right now there is no way to determine the source IP.

  50. Summer Camps Says:

    You you should edit the page name Amazon Elastic Load Balancer Setup | SerkTools to something more suited for your content you write. I loved the blog post withal.

  51. Ryan Says:

    Great article… This may be a dumb question but if the site is dynamic and the ELB is hitting different instances how are the instances remaining in sync from a top down network design level? …This is one thing that always got me, unless the db was separate and the web servers were both hitting it (or it was being mirrored?)

    Id like to use ELB but dont know how from a design standpoint.

    Thanks!

  52. Ryan Says:

    FYI I am thinking of a CRM, CMS or ERP when I mean dynamic. I know some CMS systems allow sharding of the db

  53. Steve Says:

    What you need to do is centralize your session data. For example in ASP.net you can take your session state from in-proc (the default) to out of proc by using the ASP.net Session State Service or SQL Server to store your session state data. This way all the server in your web farm are accessing the same sessions.

  54. Bin Says:

    Great article!

    “You can have as many –listener parameters as you want” – is this true? May i put 1000 listeners? I’d like to use it as a ftp load balancer to support passive mode, so need to open many ports.

    I cannot setup LVS, as it seems that LVS does not work with EC2 because of no supporting of IPIP or NAT or direct routing.

  55. Tham Tu Thanh Long Says:

    Thanks,
    It is good for me.

    All command should has [--region ]

    tham tu

  56. Lucky Says:

    Please help me I am new to amazon .

    Thanks in advance

    This is my setup

    LOAD BALANCER
    |
    |
    |————————|
    MACHINE1 MACHINE2

    I need to know is it correct or do I need to modify this? It has been 12 hours that my domain is not pointing to the loadbalancer

    Are all these DNS records are correct or more must be added? Do I need to add the IP ADDRESS OF my webserver?

    mydomain.com A(Alias) loadbal-123456789.us-east-1.elb.amazonaws.com
    http://www.mydomain.com A(Alias) loadbal-123456789.us-east-1.elb.amazonaws.com
    mydomain.com NS ns-1638.awsdns-12.co.uk.
    ns-148.awsdns-18.com.
    ns-842.awsdns-41.net.
    ns-1455.awsdns-53.org.

    mydomain.com SOA ns-1638.awsdns-12.co.uk. awsdns-hostmaster.amazon.com. 1 7200 900 1209600 86400

  57. Rituraj Says:

    Hi All,
    My scenario is ELB + Autoscallling with a single MySQL instance. ELB health check is calculate by port 22 as unable to configure 3306 port for health check. Auto scale is basis on CPU utilization. When CPU utilization is > 30% scale up a new instance and when < 5% extra instance will be scaled down. Everything is fine. on scale up ELB will divide query request to both instance. But when scaled down, how requests are handle? e.g. if 1st instance get 100 request to process, and 2nd also get 200 to process and CPU utilization in both are < 5%. Now auto scale will terminate a instance. let it be 1st one. Now question is what happen of these 100 requests? Are these requests are lost due to termination or ELB will wait to complete process these requests and then termination take place ?

    Thanks in advance.
    -RITURAJ

  58. Michael Says:

    I’m trying to use ELB on amazon implementing a cluster load balancing on MySQL. My question is that i’m affraid of the way the security is handled there because there is no IP on balancer but only a DNS. So can’t anyone telle how to assume that only the balancer would forward request to my database?