What do you use for service discovery?
There's a ton of choices out there - etcd, zookeeper, and more.
What are some of the pitfalls I should be aware of?
Should I keep things simple and roll my own using Redis backed by sentinel/clustering?
What are some of the pitfalls I should be aware of?
Should I keep things simple and roll my own using Redis backed by sentinel/clustering?
4 comments
[ 6.0 ms ] story [ 23.9 ms ] threadWhat's wrong with simply having a config file that tells your code the URL for each service it depends on (assuming my understanding of what discovery is is valid)?
It's definitely worked fine so far.
I was wondering if others had other solutions.
Also, don't you find it a little odd that you use a hostname to avoid being bound to a specific IP, but you've still hardcoded a port? Either there's value in being decoupled from the address of the service -- which must include the port -- or there isn't.
It generally comes down to gaining more control over the process to achieve higher availability and greater flexibility. Maybe you want all authentication requests from frontend12 to be routed to auth2 for some reason. At scale, it's unruly to do these types of changes by touching config files.
Let's say you have a load balancer with 4 web servers behind it, each with its own IP.
If you hit a traffic spike, you'd like your system to automatically provision another web server and add it to the load balancer with no manual intervention.
With a Service Discovery server, your load balancer could be polling the server for a list of nodes it needs to add or remove from its pool. It could also send a signal to the service discovery server that will indicate that it's dealing with a higher traffic threshold. This signal can then be captured by another Provisioning service (also polling Service Discovery) which then triggers the building of a new web server. The web server could then signal to the load balancer to add it to the pool.
Without a system like this, a person has to go in and manually update the configs on all the relevant servers. The idea behind service discovery is to prevent that.