Back

Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in AWS by (5.6k points)

 We are working on scaling out our EC2 architecture to a point where we would like to manage our own load Balancer. Currently, we have a series of machines configured on HAProxy to do basic load balancing, but we are looking for the "best practice" means to have a new instance come online and automatically join HAProxy.

Ideally, we would monitor the load on our systems or rely on a few years worth of analytics data to work out a rough schedule and when we reach a threshold have a processes fire up a new instance, have that new node connect to a system on our HAProxy machine to write its hostname into the config and reload HAProxy so it becomes part of the pool.

We are considering Amazon ELB once we grow big enough to need multiple zone coverage, but until then, we need a simple setup that can add/remove machines from HAProxy.

I know there are services out there that we can pay to manage this stuff, but Scalr seems to limit us to very specific instance types, and Rightscale is too expensive, so like many others, we are looking to roll our own solution.

1 Answer

0 votes
by (12.4k points)

You can simply "pre-configure: servers in your HAProxy configuration file, they will appear "down" and will never receive requests until you actually bring them online.

Here's an example,

listen web *:80

    balance source

    server  web1 192.168.0.101:80 check inter 2000 fall 3

    server  web2 192.168.0.102:80 check inter 2000 fall 3

    server  web3 192.168.0.103:80 check inter 2000 fall 3

    server  web4 192.168.0.104:80 check inter 2000 fall 3

    server  web5 192.168.0.105:80 check inter 2000 fall 3

    server  web6 192.168.0.106:80 check inter 2000 fall 3

    server  web7 192.168.0.107:80 check inter 2000 fall 3

    server  web8 192.168.0.108:80 check inter 2000 fall 3

    server  web9 192.168.0.109:80 check inter 2000 fall 3

    server  web10 192.168.0.110:80 check inter 2000 fall 3

With this config, you won't need to restart HAProxy.

You can also write a quick shell script to automatically generate this configuration, actually, you should write a script for that if you're adding 100 servers to your pool.

Want to become AWS Expert? Come & join AWS Certification.

Related questions

Browse Categories

...