how to make containers discovery & influence loadbalancers

22
How to Make Containers Discovery & Influence Loadbalancers

Upload: roman-naumenko

Post on 19-Feb-2017

162 views

Category:

Engineering


2 download

TRANSCRIPT

Page 1: How to Make Containers Discovery & Influence Loadbalancers

How to Make Containers Discovery & Influence

Loadbalancers

Page 2: How to Make Containers Discovery & Influence Loadbalancers

About me:

Sr DevOps Engineer at GliffyAWS Solutions ArchitectSystems Engineering background

[email protected]@naumenko_roman

Page 3: How to Make Containers Discovery & Influence Loadbalancers

1. Make several servers participate in the service and do the same work

2. Maintain service unaffected during predefined number of servers failures (high availability)

Traditional objectives for load balancers

Page 4: How to Make Containers Discovery & Influence Loadbalancers

Load balancing methods

Round Robin DNS

- First line of balancing, even before request reaches servers- Easy to implement, no integrations on client side

However:

- Recursive resolution- No control over TTLs- DNS server must know infrastructure state (Route53 health checks)

Page 5: How to Make Containers Discovery & Influence Loadbalancers

“Hardware”/Layer4 Load Balancers- network transport layer (TCP/UDP)- handle large number of TCP sessions- expensive (hardware), active-passive failover, horizontal scaling

Software/Layer7 Load Balancers- application layer (HTTP/HTTPS/SMTP etc) - number of features for balancing and inspection- secure: no direct access to backend servers- backends see LB’s IP only (look at proxy-protocol)

Page 6: How to Make Containers Discovery & Influence Loadbalancers
Page 7: How to Make Containers Discovery & Influence Loadbalancers

Yes, it can! Put more servers, reconfigure everything

But can we haz more services, please?

Page 8: How to Make Containers Discovery & Influence Loadbalancers

Things are getting complicated…

Page 9: How to Make Containers Discovery & Influence Loadbalancers

Infrastructure for services is dynamic

• Ephemeral containers: Swarm/ECS/K8S

• Ephemeral hostnames & randomly named endpoints: ELB, EC2, RDS (won’t see“mysql-db01” any more)

• Random “IP:port” for backends:“-p 8081:80” is not your friend any more

• Dynamic reconfiguration: for example ssl certificates renewed every day (not every 2 years), etc

Page 10: How to Make Containers Discovery & Influence Loadbalancers

• Support dozens of internal and multiple external services

• Dynamically add/remove front- and back-ends

Micro-services require LB to do this as well:

• Rate limiting• Deployments control (“blue-green”, “canary”)• Rewrites/ssl offloading/certs

renew/caching/timeouts/etc• {{Insert your own backlog item here}}

LBs have to be dynamic as well

Page 11: How to Make Containers Discovery & Influence Loadbalancers

So given the complexity, is there a way to make load-balancers great

again?

Page 12: How to Make Containers Discovery & Influence Loadbalancers

Yes, and it is actually easy!

And it will work on your computer™

Page 13: How to Make Containers Discovery & Influence Loadbalancers

What is modeled?

That’s your M&M services over there

Page 14: How to Make Containers Discovery & Influence Loadbalancers

docker-compose: consul

Page 15: How to Make Containers Discovery & Influence Loadbalancers

docker-compose: registrator

Page 16: How to Make Containers Discovery & Influence Loadbalancers

docker-compose: load-balancer

Page 17: How to Make Containers Discovery & Influence Loadbalancers

docker-compose: a service

Page 18: How to Make Containers Discovery & Influence Loadbalancers

Lets run a little demo

Dynamic load balancing with:

services discovery: registrator+consulautomatic configuration: consul-template, KVscaling: docker-composehealth-checks: consul

Page 19: How to Make Containers Discovery & Influence Loadbalancers

Configuration complexity

<-HAproxy

Nginx ->

Page 20: How to Make Containers Discovery & Influence Loadbalancers

Configuration simplicity

<- Traefik

Fabio ->

$ cat fabio.propertiesregistry.consul.addr = consul:8500

Page 21: How to Make Containers Discovery & Influence Loadbalancers

Use cases for docker-compose

★ Faster dev loop: new rules, configs in prod-like env

★ Integration tests for edge servers: Use anything: curl, serverspec, selenium

★ Evaluate baseline performance, compare versions running nginx in docker adds <1 ms (Linux)

★ Model canary and blue-green deployments

★ Effective collaboration for teams

★ Lots of fun

Page 22: How to Make Containers Discovery & Influence Loadbalancers

THANK [email protected]@naumenko_roman

https://github.com/rokka-n/lb-sd