Flyby is a simple distributed HAProxy layer used for load balancing our ECS shared cluster.
Flyby implements a simple distributed HaProxy layer configured via API.
Every minute the load balancer syncs-up and refreshes its configuration when needed.
Note: These commands assume you are using a docker-machine environment on 192.168.99.100
, you may need to update the IP address curl-ed to.
This docker-compose demo uses DynamoDBLocal for mocking DynamoDB, however it is possible to use other backends such as moto locally.
This is a simple scenario of registering a foo example service
## Start server with a dynamodb local server and a local service
docker-compose up
## Register a new service foo
curl -X POST -H "Content-Type: application/json" -d '{
"name": "foo",
"fqdn": "foo.example.com"
}
' "http://192.168.99.100:5000/service"
## Register a new target group 'foo-blue'
curl -X POST -H "Content-Type: application/json" -d '{
"service_name": "foo",
"target_group_name": "foo-blue",
"weight": 50
}
' "http://192.168.99.100:5000/target"
## Register a new backend
curl -X POST -H "Content-Type: application/json" -d '{
"host": "192.168.99.100:9000",
"service_name": "foo",
"target_group_name": "foo-blue"
}
' "http://192.168.99.100:5000/backend"
## Check the data
curl -X GET "http://192.168.99.100:5000/service"
curl -X GET "http://192.168.99.100:5000/haproxy/config"
A Docker compose file docker-compose-local-failover-test.yml
is provided which will set up an environment with 2 backends: foo and bar.
- foo.example.com will use the 'foo' backend but failover to the 'bar' backend if 'foo' is not available
Run the script setup_test_foo_bar.sh
after your docker compose has finished to provision the configuration.
Add a host entries for foo.example.com to localhost and you should be able to test failover.
A Docker compose file docker-compose-local-ssl-failover-test.yml
is provided which will set up an environment with 2 backends: foo and baz.
- foo.example.com will use the 'foo' backend but failover to the HTTPS 'baz' backend if 'foo' is not available
Run the script setup_test_foo_baz.sh
after your docker compose has finished to provision the configuration. The failover configuration includes setting 'failover_pool_ssl_allow_self_signed_certs' to allow 'baz' to expose a self-signed certificate.
Add a host entries for foo.example.com to localhost and you should be able to test failover.