cdocutils.nodes document q)q}q(U nametypesq}q(X0modifying availability zones for a load balancerqNXelb-configuring-a-health-checkqXelastic load balancingqXdeleting a load balancerq NXcreating a connectionq NXports and protocolsq NXelb_tutq Xelastic compute cloudq X&manually adding and removing instancesqNXcreating a load balancerqNXgetting existing load balancersqNXconfiguring a health checkqNXputting it all togetherqNX#adding instances to a load balancerqNX:an introduction to boto's elastic load balancing interfaceqNXelastic load balancing conceptsqNuUsubstitution_defsq}qUparse_messagesq]qUcurrent_sourceqNU decorationqNUautofootnote_startqKUnameidsq}q(hU0modifying-availability-zones-for-a-load-balancerqhUelb-configuring-a-health-checkq hUelastic-load-balancingq!h Udeleting-a-load-balancerq"h Ucreating-a-connectionq#h Uports-and-protocolsq$h Uelb-tutq%h Uelastic-compute-cloudq&hU&manually-adding-and-removing-instancesq'hUcreating-a-load-balancerq(hUgetting-existing-load-balancersq)hUconfiguring-a-health-checkq*hUputting-it-all-togetherq+hU#adding-instances-to-a-load-balancerq,hU:an-introduction-to-boto-s-elastic-load-balancing-interfaceq-hUelastic-load-balancing-conceptsq.uUchildrenq/]q0(cdocutils.nodes target q1)q2}q3(U rawsourceq4X .. _elb_tut:Uparentq5hUsourceq6X=/Users/kyleknap/Documents/GitHub/boto/docs/source/elb_tut.rstq7Utagnameq8Utargetq9U attributesq:}q;(Uidsq<]Ubackrefsq=]Udupnamesq>]Uclassesq?]Unamesq@]UrefidqAh%uUlineqBKUdocumentqChh/]ubcdocutils.nodes section qD)qE}qF(h4Uh5hh6h7Uexpect_referenced_by_nameqG}qHh h2sh8UsectionqIh:}qJ(h>]h?]h=]h<]qK(h-h%eh@]qL(hh euhBKhChUexpect_referenced_by_idqM}qNh%h2sh/]qO(cdocutils.nodes title qP)qQ}qR(h4X:An Introduction to boto's Elastic Load Balancing interfaceqSh5hEh6h7h8UtitleqTh:}qU(h>]h?]h=]h<]h@]uhBKhChh/]qVcdocutils.nodes Text qWX:An Introduction to boto's Elastic Load Balancing interfaceqXqY}qZ(h4hSh5hQubaubcdocutils.nodes paragraph q[)q\}q](h4XThis tutorial focuses on the boto interface for `Elastic Load Balancing`_ from Amazon Web Services. This tutorial assumes that you have already downloaded and installed boto, and are familiar with the boto ec2 interface.h5hEh6h7h8U paragraphq^h:}q_(h>]h?]h=]h<]h@]uhBKhChh/]q`(hWX0This tutorial focuses on the boto interface for qaqb}qc(h4X0This tutorial focuses on the boto interface for h5h\ubcdocutils.nodes reference qd)qe}qf(h4X`Elastic Load Balancing`_UresolvedqgKh5h\h8U referenceqhh:}qi(UnameXElastic Load BalancingUrefuriqjX+http://aws.amazon.com/elasticloadbalancing/qkh<]h=]h>]h?]h@]uh/]qlhWXElastic Load Balancingqmqn}qo(h4Uh5heubaubhWX from Amazon Web Services. This tutorial assumes that you have already downloaded and installed boto, and are familiar with the boto ec2 interface.qpqq}qr(h4X from Amazon Web Services. This tutorial assumes that you have already downloaded and installed boto, and are familiar with the boto ec2 interface.h5h\ubeubh1)qs}qt(h4XG.. _Elastic Load Balancing: http://aws.amazon.com/elasticloadbalancing/U referencedquKh5hEh6h7h8h9h:}qv(hjhkh<]qwh!ah=]h>]h?]h@]qxhauhBK hChh/]ubhD)qy}qz(h4Uh5hEh6h7h8hIh:}q{(h>]h?]h=]h<]q|h.ah@]q}hauhBKhChh/]q~(hP)q}q(h4XElastic Load Balancing Conceptsqh5hyh6h7h8hTh:}q(h>]h?]h=]h<]h@]uhBKhChh/]qhWXElastic Load Balancing Conceptsqq}q(h4hh5hubaubh[)q}q(h4Xb`Elastic Load Balancing`_ (ELB) is intimately connected with Amazon's `Elastic Compute Cloud`_ (EC2) service. Using the ELB service allows you to create a load balancer - a DNS endpoint and set of ports that distributes incoming requests to a set of EC2 instances. The advantages of using a load balancer is that it allows you to truly scale up or down a set of backend instances without disrupting service. Before the ELB service, you had to do this manually by launching an EC2 instance and installing load balancer software on it (nginx, haproxy, perlbal, etc.) to distribute traffic to other EC2 instances.h5hyh6h7h8h^h:}q(h>]h?]h=]h<]h@]uhBKhChh/]q(hd)q}q(h4X`Elastic Load Balancing`_hgKh5hh8hhh:}q(UnameXElastic Load Balancinghjhkh<]h=]h>]h?]h@]uh/]qhWXElastic Load Balancingqq}q(h4Uh5hubaubhWX- (ELB) is intimately connected with Amazon's qq}q(h4X- (ELB) is intimately connected with Amazon's h5hubhd)q}q(h4X`Elastic Compute Cloud`_hgKh5hh8hhh:}q(UnameXElastic Compute CloudhjXhttp://aws.amazon.com/ec2/qh<]h=]h>]h?]h@]uh/]qhWXElastic Compute Cloudqq}q(h4Uh5hubaubhWX (EC2) service. Using the ELB service allows you to create a load balancer - a DNS endpoint and set of ports that distributes incoming requests to a set of EC2 instances. The advantages of using a load balancer is that it allows you to truly scale up or down a set of backend instances without disrupting service. Before the ELB service, you had to do this manually by launching an EC2 instance and installing load balancer software on it (nginx, haproxy, perlbal, etc.) to distribute traffic to other EC2 instances.qq}q(h4X (EC2) service. Using the ELB service allows you to create a load balancer - a DNS endpoint and set of ports that distributes incoming requests to a set of EC2 instances. The advantages of using a load balancer is that it allows you to truly scale up or down a set of backend instances without disrupting service. Before the ELB service, you had to do this manually by launching an EC2 instance and installing load balancer software on it (nginx, haproxy, perlbal, etc.) to distribute traffic to other EC2 instances.h5hubeubh[)q}q(h4XRecall that the EC2 service is split into Regions, which are further divided into Availability Zones (AZ). For example, the US-East region is divided into us-east-1a, us-east-1b, us-east-1c, us-east-1d, and us-east-1e. You can think of AZs as data centers - each runs off a different set of ISP backbones and power providers. ELB load balancers can span multiple AZs but cannot span multiple regions. That means that if you'd like to create a set of instances spanning both the US and Europe Regions you'd have to create two load balancers and have some sort of other means of distributing requests between the two load balancers. An example of this could be using GeoIP techniques to choose the correct load balancer, or perhaps DNS round robin. Keep in mind also that traffic is distributed equally over all AZs the ELB balancer spans. This means you should have an equal number of instances in each AZ if you want to equally distribute load amongst all your instances.qh5hyh6h7h8h^h:}q(h>]h?]h=]h<]h@]uhBKhChh/]qhWXRecall that the EC2 service is split into Regions, which are further divided into Availability Zones (AZ). For example, the US-East region is divided into us-east-1a, us-east-1b, us-east-1c, us-east-1d, and us-east-1e. You can think of AZs as data centers - each runs off a different set of ISP backbones and power providers. ELB load balancers can span multiple AZs but cannot span multiple regions. That means that if you'd like to create a set of instances spanning both the US and Europe Regions you'd have to create two load balancers and have some sort of other means of distributing requests between the two load balancers. An example of this could be using GeoIP techniques to choose the correct load balancer, or perhaps DNS round robin. Keep in mind also that traffic is distributed equally over all AZs the ELB balancer spans. This means you should have an equal number of instances in each AZ if you want to equally distribute load amongst all your instances.qq}q(h4hh5hubaubh1)q}q(h4X5.. _Elastic Compute Cloud: http://aws.amazon.com/ec2/huKh5hyh6h7h8h9h:}q(hjhh<]qh&ah=]h>]h?]h@]qh auhBK'hChh/]ubeubhD)q}q(h4Uh5hEh6h7h8hIh:}q(h>]h?]h=]h<]qh#ah@]qh auhBK*hChh/]q(hP)q}q(h4XCreating a Connectionqh5hh6h7h8hTh:}q(h>]h?]h=]h<]h@]uhBK*hChh/]qhWXCreating a Connectionqq}q(h4hh5hubaubh[)q}q(h4XIThe first step in accessing ELB is to create a connection to the service.qh5hh6h7h8h^h:}q(h>]h?]h=]h<]h@]uhBK,hChh/]qhWXIThe first step in accessing ELB is to create a connection to the service.qq}q(h4hh5hubaubh[)q}q(h4XLike EC2, the ELB service has a different endpoint for each region. By default the US East endpoint is used. To choose a specific region, use the ``connect_to_region`` function::h5hh6h7h8h^h:}q(h>]h?]h=]h<]h@]uhBK/hChh/]q(hWXLike EC2, the ELB service has a different endpoint for each region. By default the US East endpoint is used. To choose a specific region, use the qDžq}q(h4XLike EC2, the ELB service has a different endpoint for each region. By default the US East endpoint is used. To choose a specific region, use the h5hubcdocutils.nodes literal q)q}q(h4X``connect_to_region``h:}q(h>]h?]h=]h<]h@]uh5hh/]qhWXconnect_to_regionqυq}q(h4Uh5hubah8UliteralqubhWX function:qӅq}q(h4X function:h5hubeubcdocutils.nodes literal_block q)q}q(h4XM>>> import boto.ec2.elb >>> elb = boto.ec2.elb.connect_to_region('us-west-2')h5hh6h7h8U literal_blockqh:}q(U xml:spaceqUpreserveqh<]h=]h>]h?]h@]uhBK3hChh/]qhWXM>>> import boto.ec2.elb >>> elb = boto.ec2.elb.connect_to_region('us-west-2')qޅq}q(h4Uh5hubaubh[)q}q(h4XWHere's yet another way to discover what regions are available and then connect to one::h5hh6h7h8h^h:}q(h>]h?]h=]h<]h@]uhBK6hChh/]qhWXVHere's yet another way to discover what regions are available and then connect to one:q允q}q(h4XVHere's yet another way to discover what regions are available and then connect to one:h5hubaubh)q}q(h4X>>> import boto.ec2.elb >>> regions = boto.ec2.elb.regions() >>> regions [RegionInfo:us-east-1, RegionInfo:ap-northeast-1, RegionInfo:us-west-1, RegionInfo:us-west-2, RegionInfo:ap-southeast-1, RegionInfo:eu-west-1] >>> elb = regions[-1].connect()h5hh6h7h8hh:}q(hhh<]h=]h>]h?]h@]uhBK9hChh/]qhWX>>> import boto.ec2.elb >>> regions = boto.ec2.elb.regions() >>> regions [RegionInfo:us-east-1, RegionInfo:ap-northeast-1, RegionInfo:us-west-1, RegionInfo:us-west-2, RegionInfo:ap-southeast-1, RegionInfo:eu-west-1] >>> elb = regions[-1].connect()q셁q}q(h4Uh5hubaubh[)q}q(h4XHAlternatively, edit your boto.cfg with the default ELB endpoint to use::qh5hh6h7h8h^h:}q(h>]h?]h=]h<]h@]uhBKDhChh/]qhWXGAlternatively, edit your boto.cfg with the default ELB endpoint to use:qq}q(h4XGAlternatively, edit your boto.cfg with the default ELB endpoint to use:h5hubaubh)q}q(h4Xe[Boto] elb_region_name = eu-west-1 elb_region_endpoint = elasticloadbalancing.eu-west-1.amazonaws.comh5hh6h7h8hh:}q(hhh<]h=]h>]h?]h@]uhBKFhChh/]qhWXe[Boto] elb_region_name = eu-west-1 elb_region_endpoint = elasticloadbalancing.eu-west-1.amazonaws.comqq}q(h4Uh5hubaubhD)q}q(h4Uh5hh6h7h8hIh:}r(h>]h?]h=]h<]rh)ah@]rhauhBKKhChh/]r(hP)r}r(h4XGetting Existing Load Balancersrh5hh6h7h8hTh:}r(h>]h?]h=]h<]h@]uhBKKhChh/]rhWXGetting Existing Load Balancersr r }r (h4jh5jubaubh[)r }r (h4X(To retrieve any existing load balancers:rh5hh6h7h8h^h:}r(h>]h?]h=]h<]h@]uhBKMhChh/]rhWX(To retrieve any existing load balancers:rr}r(h4jh5j ubaubcdocutils.nodes doctest_block r)r}r(h4Xg>>> conn.get_all_load_balancers() [LoadBalancer:load-balancer-prod, LoadBalancer:load-balancer-staging]h5hh6h7h8U doctest_blockrh:}r(hhh<]h=]h>]h?]h@]uhBKPhChh/]rhWXg>>> conn.get_all_load_balancers() [LoadBalancer:load-balancer-prod, LoadBalancer:load-balancer-staging]rr}r(h4Uh5jubaubh[)r}r(h4XYou can also filter by namerh5hh6h7h8h^h:}r (h>]h?]h=]h<]h@]uhBKRhChh/]r!hWXYou can also filter by namer"r#}r$(h4jh5jubaubj)r%}r&(h4Xm>>> conn.get_all_load_balancers(load_balancer_names=['load-balancer-prod']) [LoadBalancer:load-balancer-prod]h5hh6h7h8jh:}r'(hhh<]h=]h>]h?]h@]uhBKUhChh/]r(hWXm>>> conn.get_all_load_balancers(load_balancer_names=['load-balancer-prod']) [LoadBalancer:load-balancer-prod]r)r*}r+(h4Uh5j%ubaubh[)r,}r-(h4XQ:py:meth:`get_all_load_balancers ` returns a :py:class:`boto.resultset.ResultSet` that contains instances of :class:`boto.ec2.elb.loadbalancer.LoadBalancer`, each of which abstracts access to a load balancer. :py:class:`ResultSet ` works very much like a list.h5hh6h7h8h^h:}r.(h>]h?]h=]h<]h@]uhBKWhChh/]r/(csphinx.addnodes pending_xref r0)r1}r2(h4XU:py:meth:`get_all_load_balancers `r3h5j,h6h7h8U pending_xrefr4h:}r5(UreftypeXmethUrefwarnr6U reftargetr7X1boto.ec2.elb.ELBConnection.get_all_load_balancersU refdomainXpyr8h<]h=]U refexplicith>]h?]h@]Urefdocr9Xelb_tutr:Upy:classr;NU py:moduler<NuhBKWh/]r=h)r>}r?(h4j3h:}r@(h>]h?]rA(UxrefrBj8Xpy-methrCeh=]h<]h@]uh5j1h/]rDhWXget_all_load_balancersrErF}rG(h4Uh5j>ubah8hubaubhWX returns a rHrI}rJ(h4X returns a h5j,ubj0)rK}rL(h4X$:py:class:`boto.resultset.ResultSet`rMh5j,h6h7h8j4h:}rN(UreftypeXclassj6j7Xboto.resultset.ResultSetU refdomainXpyrOh<]h=]U refexplicith>]h?]h@]j9j:j;Nj<NuhBKWh/]rPh)rQ}rR(h4jMh:}rS(h>]h?]rT(jBjOXpy-classrUeh=]h<]h@]uh5jKh/]rVhWXboto.resultset.ResultSetrWrX}rY(h4Uh5jQubah8hubaubhWX that contains instances of rZr[}r\(h4X that contains instances of h5j,ubj0)r]}r^(h4X/:class:`boto.ec2.elb.loadbalancer.LoadBalancer`r_h5j,h6h7h8j4h:}r`(UreftypeXclassj6j7X&boto.ec2.elb.loadbalancer.LoadBalancerU refdomainXpyrah<]h=]U refexplicith>]h?]h@]j9j:j;Nj<NuhBKWh/]rbh)rc}rd(h4j_h:}re(h>]h?]rf(jBjaXpy-classrgeh=]h<]h@]uh5j]h/]rhhWX&boto.ec2.elb.loadbalancer.LoadBalancerrirj}rk(h4Uh5jcubah8hubaubhWX5, each of which abstracts access to a load balancer. rlrm}rn(h4X5, each of which abstracts access to a load balancer. h5j,ubj0)ro}rp(h4X0:py:class:`ResultSet `rqh5j,h6h7h8j4h:}rr(UreftypeXclassj6j7Xboto.resultset.ResultSetU refdomainXpyrsh<]h=]U refexplicith>]h?]h@]j9j:j;Nj<NuhBKWh/]rth)ru}rv(h4jqh:}rw(h>]h?]rx(jBjsXpy-classryeh=]h<]h@]uh5joh/]rzhWX ResultSetr{r|}r}(h4Uh5juubah8hubaubhWX works very much like a list.r~r}r(h4X works very much like a list.h5j,ubeubj)r}r(h4X^>>> balancers = conn.get_all_load_balancers() >>> balancers[0] LoadBalancer:load-balancer-prodh5hh6h7h8jh:}r(hhh<]h=]h>]h?]h@]uhBK_hChh/]rhWX^>>> balancers = conn.get_all_load_balancers() >>> balancers[0] LoadBalancer:load-balancer-prodrr}r(h4Uh5jubaubeubeubhD)r}r(h4Uh5hEh6h7h8hIh:}r(h>]h?]h=]h<]rh(ah@]rhauhBKbhChh/]r(hP)r}r(h4XCreating a Load Balancerrh5jh6h7h8hTh:}r(h>]h?]h=]h<]h@]uhBKbhChh/]rhWXCreating a Load Balancerrr}r(h4jh5jubaubcdocutils.nodes definition_list r)r}r(h4Uh5jh6Nh8Udefinition_listrh:}r(h>]h?]h=]h<]h@]uhBNhChh/]rcdocutils.nodes definition_list_item r)r}r(h4XTo create a load balancer you need the following: #. The specific **ports and protocols** you want to load balancer over, and what port you want to connect to all instances. #. A **health check** - the ELB concept of a *heart beat* or *ping*. ELB will use this health check to see whether your instances are up or down. If they go down, the load balancer will no longer send requests to them. #. A **list of Availability Zones** you'd like to create your load balancer over. h5jh6h7h8Udefinition_list_itemrh:}r(h>]h?]h=]h<]h@]uhBKih/]r(cdocutils.nodes term r)r}r(h4X1To create a load balancer you need the following:rh5jh6h7h8Utermrh:}r(h>]h?]h=]h<]h@]uhBKih/]rhWX1To create a load balancer you need the following:rr}r(h4jh5jubaubcdocutils.nodes definition r)r}r(h4Uh:}r(h>]h?]h=]h<]h@]uh5jh/]rcdocutils.nodes enumerated_list r)r}r(h4Uh:}r(UsuffixrU.h<]h=]h>]UprefixrUh?]h@]UenumtyperUarabicruh5jh/]r(cdocutils.nodes list_item r)r}r(h4XxThe specific **ports and protocols** you want to load balancer over, and what port you want to connect to all instances.h:}r(h>]h?]h=]h<]h@]uh5jh/]rh[)r}r(h4XxThe specific **ports and protocols** you want to load balancer over, and what port you want to connect to all instances.h5jh6h7h8h^h:}r(h>]h?]h=]h<]h@]uhBKdh/]r(hWX The specific rr}r(h4X The specific h5jubcdocutils.nodes strong r)r}r(h4X**ports and protocols**h:}r(h>]h?]h=]h<]h@]uh5jh/]rhWXports and protocolsrr}r(h4Uh5jubah8UstrongrubhWXT you want to load balancer over, and what port you want to connect to all instances.rr}r(h4XT you want to load balancer over, and what port you want to connect to all instances.h5jubeubah8U list_itemrubj)r}r(h4XA **health check** - the ELB concept of a *heart beat* or *ping*. ELB will use this health check to see whether your instances are up or down. If they go down, the load balancer will no longer send requests to them.h:}r(h>]h?]h=]h<]h@]uh5jh/]rh[)r}r(h4XA **health check** - the ELB concept of a *heart beat* or *ping*. ELB will use this health check to see whether your instances are up or down. If they go down, the load balancer will no longer send requests to them.h5jh6h7h8h^h:}r(h>]h?]h=]h<]h@]uhBKfh/]r(hWXA rr}r(h4XA h5jubj)r}r(h4X**health check**h:}r(h>]h?]h=]h<]h@]uh5jh/]rhWX health checkrr}r(h4Uh5jubah8jubhWX - the ELB concept of a rr}r(h4X - the ELB concept of a h5jubcdocutils.nodes emphasis r)r}r(h4X *heart beat*h:}r(h>]h?]h=]h<]h@]uh5jh/]rhWX heart beatrr}r(h4Uh5jubah8UemphasisrubhWX or rr}r(h4X or h5jubj)r}r(h4X*ping*h:}r(h>]h?]h=]h<]h@]uh5jh/]rhWXpingrr}r(h4Uh5jubah8jubhWX. ELB will use this health check to see whether your instances are up or down. If they go down, the load balancer will no longer send requests to them.rr}r(h4X. ELB will use this health check to see whether your instances are up or down. If they go down, the load balancer will no longer send requests to them.h5jubeubah8jubj)r}r(h4XOA **list of Availability Zones** you'd like to create your load balancer over. h:}r(h>]h?]h=]h<]h@]uh5jh/]rh[)r}r(h4XNA **list of Availability Zones** you'd like to create your load balancer over.h5jh6h7h8h^h:}r(h>]h?]h=]h<]h@]uhBKih/]r(hWXA rr}r(h4XA h5jubj)r }r (h4X**list of Availability Zones**h:}r (h>]h?]h=]h<]h@]uh5jh/]r hWXlist of Availability Zonesr r}r(h4Uh5j ubah8jubhWX. you'd like to create your load balancer over.rr}r(h4X. you'd like to create your load balancer over.h5jubeubah8jubeh8Uenumerated_listrubah8U definitionrubeubaubhD)r}r(h4Uh5jh6h7h8hIh:}r(h>]h?]h=]h<]rh$ah@]rh auhBKlhChh/]r(hP)r}r(h4XPorts and Protocolsrh5jh6h7h8hTh:}r(h>]h?]h=]h<]h@]uhBKlhChh/]rhWXPorts and Protocolsr r!}r"(h4jh5jubaubh[)r#}r$(h4XAn incoming connection to your load balancer will come on one or more ports - for example 80 (HTTP) and 443 (HTTPS). Each can be using a protocol - currently, the supported protocols are TCP and HTTP. We also need to tell the load balancer which port to route connects *to* on each instance. For example, to create a load balancer for a website that accepts connections on 80 and 443, and that routes connections to port 8080 and 8443 on each instance, you would specify that the load balancer ports and protocols are:h5jh6h7h8h^h:}r%(h>]h?]h=]h<]h@]uhBKmhChh/]r&(hWXAn incoming connection to your load balancer will come on one or more ports - for example 80 (HTTP) and 443 (HTTPS). Each can be using a protocol - currently, the supported protocols are TCP and HTTP. We also need to tell the load balancer which port to route connects r'r(}r)(h4XAn incoming connection to your load balancer will come on one or more ports - for example 80 (HTTP) and 443 (HTTPS). Each can be using a protocol - currently, the supported protocols are TCP and HTTP. We also need to tell the load balancer which port to route connects h5j#ubj)r*}r+(h4X*to*h:}r,(h>]h?]h=]h<]h@]uh5j#h/]r-hWXtor.r/}r0(h4Uh5j*ubah8jubhWX on each instance. For example, to create a load balancer for a website that accepts connections on 80 and 443, and that routes connections to port 8080 and 8443 on each instance, you would specify that the load balancer ports and protocols are:r1r2}r3(h4X on each instance. For example, to create a load balancer for a website that accepts connections on 80 and 443, and that routes connections to port 8080 and 8443 on each instance, you would specify that the load balancer ports and protocols are:h5j#ubeubcdocutils.nodes block_quote r4)r5}r6(h4Uh5jh6Nh8U block_quoter7h:}r8(h>]h?]h=]h<]h@]uhBNhChh/]r9cdocutils.nodes bullet_list r:)r;}r<(h4Uh:}r=(Ubulletr>X*h<]h=]h>]h?]h@]uh5j5h/]r?(j)r@}rA(h4X80, 8080, HTTPrBh:}rC(h>]h?]h=]h<]h@]uh5j;h/]rDh[)rE}rF(h4jBh5j@h6h7h8h^h:}rG(h>]h?]h=]h<]h@]uhBKuh/]rHhWX80, 8080, HTTPrIrJ}rK(h4jBh5jEubaubah8jubj)rL}rM(h4X443, 8443, TCP h:}rN(h>]h?]h=]h<]h@]uh5j;h/]rOh[)rP}rQ(h4X443, 8443, TCPrRh5jLh6h7h8h^h:}rS(h>]h?]h=]h<]h@]uhBKvh/]rThWX443, 8443, TCPrUrV}rW(h4jRh5jPubaubah8jubeh8U bullet_listrXubaubh[)rY}rZ(h4X&This says that the load balancer will listen on two ports - 80 and 443. Connections on 80 will use an HTTP load balancer to forward connections to port 8080 on instances. Likewise, the load balancer will listen on 443 to forward connections to 8443 on each instance using the TCP balancer. We need to use TCP for the HTTPS port because it is encrypted at the application layer. Of course, we could specify the load balancer use TCP for port 80, however specifying HTTP allows you to let ELB handle some work for you - for example HTTP header parsing.r[h5jh6h7h8h^h:}r\(h>]h?]h=]h<]h@]uhBKxhChh/]r]hWX&This says that the load balancer will listen on two ports - 80 and 443. Connections on 80 will use an HTTP load balancer to forward connections to port 8080 on instances. Likewise, the load balancer will listen on 443 to forward connections to 8443 on each instance using the TCP balancer. We need to use TCP for the HTTPS port because it is encrypted at the application layer. Of course, we could specify the load balancer use TCP for port 80, however specifying HTTP allows you to let ELB handle some work for you - for example HTTP header parsing.r^r_}r`(h4j[h5jYubaubh1)ra}rb(h4X#.. _elb-configuring-a-health-check:h5jh6h7h8h9h:}rc(h<]h=]h>]h?]h@]hAh uhBKhChh/]ubeubhD)rd}re(h4Uh5jh6h7hG}rfhjash8hIh:}rg(h>]h?]h=]h<]rh(h*h eh@]ri(hheuhBKhChhM}rjh jash/]rk(hP)rl}rm(h4XConfiguring a Health Checkrnh5jdh6h7h8hTh:}ro(h>]h?]h=]h<]h@]uhBKhChh/]rphWXConfiguring a Health Checkrqrr}rs(h4jnh5jlubaubh[)rt}ru(h4XA health check allows ELB to determine which instances are alive and able to respond to requests. A health check is essentially a tuple consisting of:rvh5jdh6h7h8h^h:}rw(h>]h?]h=]h<]h@]uhBKhChh/]rxhWXA health check allows ELB to determine which instances are alive and able to respond to requests. A health check is essentially a tuple consisting of:ryrz}r{(h4jvh5jtubaubj4)r|}r}(h4Uh5jdh6Nh8j7h:}r~(h>]h?]h=]h<]h@]uhBNhChh/]rj:)r}r(h4Uh:}r(j>X*h<]h=]h>]h?]h@]uh5j|h/]r(j)r}r(h4X *Target*: What to check on an instance. For a TCP check this is comprised of:: TCP:PORT_TO_CHECK Which attempts to open a connection on PORT_TO_CHECK. If the connection opens successfully, that specific instance is deemed healthy, otherwise it is marked temporarily as unhealthy. For HTTP, the situation is slightly different:: HTTP:PORT_TO_CHECK/RESOURCE This means that the health check will connect to the resource /RESOURCE on PORT_TO_CHECK. If an HTTP 200 status is returned the instance is deemed healthy.h:}r(h>]h?]h=]h<]h@]uh5jh/]r(h[)r}r(h4XN*Target*: What to check on an instance. For a TCP check this is comprised of::h5jh6h7h8h^h:}r(h>]h?]h=]h<]h@]uhBKh/]r(j)r}r(h4X*Target*h:}r(h>]h?]h=]h<]h@]uh5jh/]rhWXTargetrr}r(h4Uh5jubah8jubhWXE: What to check on an instance. For a TCP check this is comprised of:rr}r(h4XE: What to check on an instance. For a TCP check this is comprised of:h5jubeubh)r}r(h4XTCP:PORT_TO_CHECKh5jh8hh:}r(hhh<]h=]h>]h?]h@]uhBKh/]rhWXTCP:PORT_TO_CHECKrr}r(h4Uh5jubaubh[)r}r(h4XWhich attempts to open a connection on PORT_TO_CHECK. If the connection opens successfully, that specific instance is deemed healthy, otherwise it is marked temporarily as unhealthy. For HTTP, the situation is slightly different::h5jh6h7h8h^h:}r(h>]h?]h=]h<]h@]uhBKh/]rhWXWhich attempts to open a connection on PORT_TO_CHECK. If the connection opens successfully, that specific instance is deemed healthy, otherwise it is marked temporarily as unhealthy. For HTTP, the situation is slightly different:rr}r(h4XWhich attempts to open a connection on PORT_TO_CHECK. If the connection opens successfully, that specific instance is deemed healthy, otherwise it is marked temporarily as unhealthy. For HTTP, the situation is slightly different:h5jubaubh)r}r(h4XHTTP:PORT_TO_CHECK/RESOURCEh5jh8hh:}r(hhh<]h=]h>]h?]h@]uhBKh/]rhWXHTTP:PORT_TO_CHECK/RESOURCErr}r(h4Uh5jubaubh[)r}r(h4XThis means that the health check will connect to the resource /RESOURCE on PORT_TO_CHECK. If an HTTP 200 status is returned the instance is deemed healthy.rh5jh6h7h8h^h:}r(h>]h?]h=]h<]h@]uhBKh/]rhWXThis means that the health check will connect to the resource /RESOURCE on PORT_TO_CHECK. If an HTTP 200 status is returned the instance is deemed healthy.rr}r(h4jh5jubaubeh8jubj)r}r(h4X*Interval*: How often the check is made. This is given in seconds and defaults to 30. The valid range of intervals goes from 5 seconds to 600 seconds.h:}r(h>]h?]h=]h<]h@]uh5jh/]rh[)r}r(h4X*Interval*: How often the check is made. This is given in seconds and defaults to 30. The valid range of intervals goes from 5 seconds to 600 seconds.h5jh6h7h8h^h:}r(h>]h?]h=]h<]h@]uhBKh/]r(j)r}r(h4X *Interval*h:}r(h>]h?]h=]h<]h@]uh5jh/]rhWXIntervalrr}r(h4Uh5jubah8jubhWX: How often the check is made. This is given in seconds and defaults to 30. The valid range of intervals goes from 5 seconds to 600 seconds.rr}r(h4X: How often the check is made. This is given in seconds and defaults to 30. The valid range of intervals goes from 5 seconds to 600 seconds.h5jubeubah8jubj)r}r(h4X\*Timeout*: The number of seconds the load balancer will wait for a check to return a result.h:}r(h>]h?]h=]h<]h@]uh5jh/]rh[)r}r(h4X\*Timeout*: The number of seconds the load balancer will wait for a check to return a result.h5jh6h7h8h^h:}r(h>]h?]h=]h<]h@]uhBKh/]r(j)r}r(h4X *Timeout*h:}r(h>]h?]h=]h<]h@]uh5jh/]rhWXTimeoutrr}r(h4Uh5jubah8jubhWXS: The number of seconds the load balancer will wait for a check to return a result.rr}r(h4XS: The number of seconds the load balancer will wait for a check to return a result.h5jubeubah8jubj)r}r(h4X*Unhealthy threshold*: The number of consecutive failed checks to deem the instance as being dead. The default is 5, and the range of valid values lies from 2 to 10. h:}r(h>]h?]h=]h<]h@]uh5jh/]rh[)r}r(h4X*Unhealthy threshold*: The number of consecutive failed checks to deem the instance as being dead. The default is 5, and the range of valid values lies from 2 to 10.h5jh6h7h8h^h:}r(h>]h?]h=]h<]h@]uhBKh/]r(j)r}r(h4X*Unhealthy threshold*h:}r(h>]h?]h=]h<]h@]uh5jh/]rhWXUnhealthy thresholdrr}r(h4Uh5jubah8jubhWX: The number of consecutive failed checks to deem the instance as being dead. The default is 5, and the range of valid values lies from 2 to 10.rr}r(h4X: The number of consecutive failed checks to deem the instance as being dead. The default is 5, and the range of valid values lies from 2 to 10.h5jubeubah8jubeh8jXubaubh[)r}r(h4XThe following example creates a health check called *instance_health* that simply checks instances every 20 seconds on port 80 over HTTP at the resource /health for 200 successes.h5jdh6h7h8h^h:}r(h>]h?]h=]h<]h@]uhBKhChh/]r(hWX4The following example creates a health check called rr}r(h4X4The following example creates a health check called h5jubj)r}r(h4X*instance_health*h:}r(h>]h?]h=]h<]h@]uh5jh/]rhWXinstance_healthrr}r(h4Uh5jubah8jubhWXn that simply checks instances every 20 seconds on port 80 over HTTP at the resource /health for 200 successes.rr}r(h4Xn that simply checks instances every 20 seconds on port 80 over HTTP at the resource /health for 200 successes.h5jubeubj)r}r(h4X>>> from boto.ec2.elb import HealthCheck >>> hc = HealthCheck( interval=20, healthy_threshold=3, unhealthy_threshold=5, target='HTTP:8080/health' )h5jdh6h7h8jh:}r(hhh<]h=]h>]h?]h@]uhBKhChh/]rhWX>>> from boto.ec2.elb import HealthCheck >>> hc = HealthCheck( interval=20, healthy_threshold=3, unhealthy_threshold=5, target='HTTP:8080/health' )rr}r(h4Uh5jubaubeubhD)r}r(h4Uh5jh6h7h8hIh:}r(h>]h?]h=]h<]rh+ah@]rhauhBKhChh/]r(hP)r}r(h4XPutting It All Togetherr h5jh6h7h8hTh:}r (h>]h?]h=]h<]h@]uhBKhChh/]r hWXPutting It All Togetherr r }r(h4j h5jubaubh[)r}r(h4XFinally, let's create a load balancer in the US region that listens on ports 80 and 443 and distributes requests to instances on 8080 and 8443 over HTTP and TCP. We want the load balancer to span the availability zones *us-east-1a* and *us-east-1b*:h5jh6h7h8h^h:}r(h>]h?]h=]h<]h@]uhBKhChh/]r(hWXFinally, let's create a load balancer in the US region that listens on ports 80 and 443 and distributes requests to instances on 8080 and 8443 over HTTP and TCP. We want the load balancer to span the availability zones rr}r(h4XFinally, let's create a load balancer in the US region that listens on ports 80 and 443 and distributes requests to instances on 8080 and 8443 over HTTP and TCP. We want the load balancer to span the availability zones h5jubj)r}r(h4X *us-east-1a*h:}r(h>]h?]h=]h<]h@]uh5jh/]rhWX us-east-1arr}r(h4Uh5jubah8jubhWX and rr}r(h4X and h5jubj)r }r!(h4X *us-east-1b*h:}r"(h>]h?]h=]h<]h@]uh5jh/]r#hWX us-east-1br$r%}r&(h4Uh5j ubah8jubhWX:r'}r((h4X:h5jubeubj)r)}r*(h4X>>> zones = ['us-east-1a', 'us-east-1b'] >>> ports = [(80, 8080, 'http'), (443, 8443, 'tcp')] >>> lb = conn.create_load_balancer('my-lb', zones, ports) >>> # This is from the previous section. >>> lb.configure_health_check(hc)h5jh6h7h8jh:}r+(hhh<]h=]h>]h?]h@]uhBKhChh/]r,hWX>>> zones = ['us-east-1a', 'us-east-1b'] >>> ports = [(80, 8080, 'http'), (443, 8443, 'tcp')] >>> lb = conn.create_load_balancer('my-lb', zones, ports) >>> # This is from the previous section. >>> lb.configure_health_check(hc)r-r.}r/(h4Uh5j)ubaubh[)r0}r1(h4XTThe load balancer has been created. To see where you can actually connect to it, do:r2h5jh6h7h8h^h:}r3(h>]h?]h=]h<]h@]uhBKhChh/]r4hWXTThe load balancer has been created. To see where you can actually connect to it, do:r5r6}r7(h4j2h5j0ubaubj)r8}r9(h4XB>>> print lb.dns_name my_elb-123456789.us-east-1.elb.amazonaws.comh5jh6h7h8jh:}r:(hhh<]h=]h>]h?]h@]uhBKhChh/]r;hWXB>>> print lb.dns_name my_elb-123456789.us-east-1.elb.amazonaws.comr<r=}r>(h4Uh5j8ubaubh[)r?}r@(h4XRYou can then CNAME map a better name, i.e. www.MYWEBSITE.com to the above address.rAh5jh6h7h8h^h:}rB(h>]h?]h=]h<]h@]uhBKhChh/]rChWXRYou can then CNAME map a better name, i.e. www.MYWEBSITE.com to the above address.rDrE}rF(h4jAh5j?ubaubeubeubhD)rG}rH(h4Uh5hEh6h7h8hIh:}rI(h>]h?]h=]h<]rJh,ah@]rKhauhBKhChh/]rL(hP)rM}rN(h4X#Adding Instances To a Load BalancerrOh5jGh6h7h8hTh:}rP(h>]h?]h=]h<]h@]uhBKhChh/]rQhWX#Adding Instances To a Load BalancerrRrS}rT(h4jOh5jMubaubh[)rU}rV(h4XWNow that the load balancer has been created, there are two ways to add instances to it:rWh5jGh6h7h8h^h:}rX(h>]h?]h=]h<]h@]uhBKhChh/]rYhWXWNow that the load balancer has been created, there are two ways to add instances to it:rZr[}r\(h4jWh5jUubaubj4)r]}r^(h4Uh5jGh6Nh8j7h:}r_(h>]h?]h=]h<]h@]uhBNhChh/]r`j)ra}rb(h4Uh:}rc(jU.h<]h=]h>]jUh?]h@]jjuh5j]h/]rd(j)re}rf(h4X'Manually, adding each instance in turn.rgh:}rh(h>]h?]h=]h<]h@]uh5jah/]rih[)rj}rk(h4jgh5jeh6h7h8h^h:}rl(h>]h?]h=]h<]h@]uhBKh/]rmhWX'Manually, adding each instance in turn.rnro}rp(h4jgh5jjubaubah8jubj)rq}rr(h4XMapping an autoscale group to the load balancer. Please see the :doc:`Autoscale tutorial ` for information on how to do this. h:}rs(h>]h?]h=]h<]h@]uh5jah/]rth[)ru}rv(h4XMapping an autoscale group to the load balancer. Please see the :doc:`Autoscale tutorial ` for information on how to do this.h5jqh6h7h8h^h:}rw(h>]h?]h=]h<]h@]uhBKh/]rx(hWX@Mapping an autoscale group to the load balancer. Please see the ryrz}r{(h4X@Mapping an autoscale group to the load balancer. Please see the h5juubj0)r|}r}(h4X):doc:`Autoscale tutorial `r~h5juh6h7h8j4h:}r(UreftypeXdocrj6j7X autoscale_tutU refdomainUh<]h=]U refexplicith>]h?]h@]j9j:uhBKh/]rh)r}r(h4j~h:}r(h>]h?]r(jBjeh=]h<]h@]uh5j|h/]rhWXAutoscale tutorialrr}r(h4Uh5jubah8hubaubhWX# for information on how to do this.rr}r(h4X# for information on how to do this.h5juubeubah8jubeh8jubaubhD)r}r(h4Uh5jGh6h7h8hIh:}r(h>]h?]h=]h<]rh'ah@]rhauhBKhChh/]r(hP)r}r(h4X&Manually Adding and Removing Instancesrh5jh6h7h8hTh:}r(h>]h?]h=]h<]h@]uhBKhChh/]rhWX&Manually Adding and Removing Instancesrr}r(h4jh5jubaubh[)r}r(h4XOAssuming you have a list of instance ids, you can add them to the load balancerrh5jh6h7h8h^h:}r(h>]h?]h=]h<]h@]uhBKhChh/]rhWXOAssuming you have a list of instance ids, you can add them to the load balancerrr}r(h4jh5jubaubj)r}r(h4XW>>> instance_ids = ['i-4f8cf126', 'i-0bb7ca62'] >>> lb.register_instances(instance_ids)h5jh6h7h8jh:}r(hhh<]h=]h>]h?]h@]uhBKhChh/]rhWXW>>> instance_ids = ['i-4f8cf126', 'i-0bb7ca62'] >>> lb.register_instances(instance_ids)rr}r(h4Uh5jubaubh[)r}r(h4XKeep in mind that these instances should be in Security Groups that match the internal ports of the load balancer you just created (for this example, they should allow incoming connections on 8080 and 8443).rh5jh6h7h8h^h:}r(h>]h?]h=]h<]h@]uhBKhChh/]rhWXKeep in mind that these instances should be in Security Groups that match the internal ports of the load balancer you just created (for this example, they should allow incoming connections on 8080 and 8443).rr}r(h4jh5jubaubh[)r}r(h4XTo remove instances:rh5jh6h7h8h^h:}r(h>]h?]h=]h<]h@]uhBKhChh/]rhWXTo remove instances:rr}r(h4jh5jubaubj)r}r(h4X)>>> lb.deregister_instances(instance_ids)rh5jh6h7h8jh:}r(hhh<]h=]h>]h?]h@]uhBKhChh/]rhWX)>>> lb.deregister_instances(instance_ids)rr}r(h4Uh5jubaubeubeubhD)r}r(h4Uh5hEh6h7h8hIh:}r(h>]h?]h=]h<]rhah@]rhauhBKhChh/]r(hP)r}r(h4X0Modifying Availability Zones for a Load Balancerrh5jh6h7h8hTh:}r(h>]h?]h=]h<]h@]uhBKhChh/]rhWX0Modifying Availability Zones for a Load Balancerrr}r(h4jh5jubaubh[)r}r(h4XJIf you wanted to disable one or more zones from an existing load balancer:rh5jh6h7h8h^h:}r(h>]h?]h=]h<]h@]uhBKhChh/]rhWXJIf you wanted to disable one or more zones from an existing load balancer:rr}r(h4jh5jubaubj)r}r(h4X$>>> lb.disable_zones(['us-east-1a'])rh5jh6h7h8jh:}r(hhh<]h=]h>]h?]h@]uhBKhChh/]rhWX$>>> lb.disable_zones(['us-east-1a'])rr}r(h4Uh5jubaubh[)r}r(h4XkYou can then terminate each instance in the disabled zone and then deregister then from your load balancer.rh5jh6h7h8h^h:}r(h>]h?]h=]h<]h@]uhBKhChh/]rhWXkYou can then terminate each instance in the disabled zone and then deregister then from your load balancer.rr}r(h4jh5jubaubh[)r}r(h4XTo enable zones:rh5jh6h7h8h^h:}r(h>]h?]h=]h<]h@]uhBKhChh/]rhWXTo enable zones:rr}r(h4jh5jubaubj)r}r(h4X#>>> lb.enable_zones(['us-east-1c'])rh5jh6h7h8jh:}r(hhh<]h=]h>]h?]h@]uhBKhChh/]rhWX#>>> lb.enable_zones(['us-east-1c'])rr}r(h4Uh5jubaubeubhD)r}r(h4Uh5hEh6h7h8hIh:}r(h>]h?]h=]h<]rh"ah@]rh auhBKhChh/]r(hP)r}r(h4XDeleting a Load Balancerrh5jh6h7h8hTh:}r(h>]h?]h=]h<]h@]uhBKhChh/]rhWXDeleting a Load Balancerrr}r(h4jh5jubaubj)r}r(h4X>>> lb.delete()rh5jh6h7h8jh:}r (hhh<]h=]h>]h?]h@]uhBKhChh/]r hWX>>> lb.delete()r r }r (h4Uh5jubaubeubeubeh4UU transformerrNU footnote_refsr}rUrefnamesr}r(Xelastic compute cloud]rhaXelastic load balancing]r(heheuUsymbol_footnotesr]rUautofootnote_refsr]rUsymbol_footnote_refsr]rU citationsr]rhChU current_linerNUtransform_messagesr]r(cdocutils.nodes system_message r )r!}r"(h4Uh:}r#(h>]UlevelKh<]h=]Usourceh7h?]h@]UlineKUtypeUINFOr$uh/]r%h[)r&}r'(h4Uh:}r((h>]h?]h=]h<]h@]uh5j!h/]r)hWX-Hyperlink target "elb-tut" is not referenced.r*r+}r,(h4Uh5j&ubah8h^ubah8Usystem_messager-ubj )r.}r/(h4Uh:}r0(h>]UlevelKh<]h=]Usourceh7h?]h@]UlineKUtypej$uh/]r1h[)r2}r3(h4Uh:}r4(h>]h?]h=]h<]h@]uh5j.h/]r5hWXDHyperlink target "elb-configuring-a-health-check" is not referenced.r6r7}r8(h4Uh5j2ubah8h^ubah8j-ubeUreporterr9NUid_startr:KU autofootnotesr;]r<U citation_refsr=}r>Uindirect_targetsr?]r@UsettingsrA(cdocutils.frontend Values rBorC}rD(Ufootnote_backlinksrEKUrecord_dependenciesrFNU rfc_base_urlrGUhttp://tools.ietf.org/html/rHU tracebackrIUpep_referencesrJNUstrip_commentsrKNU toc_backlinksrLUentryrMU language_coderNUenrOU datestamprPNU report_levelrQKU _destinationrRNU halt_levelrSKU strip_classesrTNhTNUerror_encoding_error_handlerrUUbackslashreplacerVUdebugrWNUembed_stylesheetrXUoutput_encoding_error_handlerrYUstrictrZU sectnum_xformr[KUdump_transformsr\NU docinfo_xformr]KUwarning_streamr^NUpep_file_url_templater_Upep-%04dr`Uexit_status_levelraKUconfigrbNUstrict_visitorrcNUcloak_email_addressesrdUtrim_footnote_reference_spacereUenvrfNUdump_pseudo_xmlrgNUexpose_internalsrhNUsectsubtitle_xformriU source_linkrjNUrfc_referencesrkNUoutput_encodingrlUutf-8rmU source_urlrnNUinput_encodingroU utf-8-sigrpU_disable_configrqNU id_prefixrrUU tab_widthrsKUerror_encodingrtUUTF-8ruU_sourcervh7Ugettext_compactrwU generatorrxNUdump_internalsryNU smart_quotesrzU pep_base_urlr{Uhttp://www.python.org/dev/peps/r|Usyntax_highlightr}Ulongr~Uinput_encoding_error_handlerrjZUauto_id_prefixrUidrUdoctitle_xformrUstrip_elements_with_classesrNU _config_filesr]Ufile_insertion_enabledrU raw_enabledrKU dump_settingsrNubUsymbol_footnote_startrKUidsr}r(h-hEh.hyh*jdh jdh&hh,jGh'jh$jh"jh)hh+jhjh!hsh(jh%hEh#huUsubstitution_namesr}rh8hCh:}r(h>]h<]h=]Usourceh7h?]h@]uU footnotesr]rUrefidsr}r(h ]rjaah%]rh2auub.