What is the conceptual difference between Service Discovery and Load Balancers tools that test node health?

Recently, several popular service search tools have become popular / "mainstream", and Im wonders when to use them for the first time instead of traditional load balancers.

With LB, you cluster the node node behind the balancer, and then clients make requests to the balancer, who then (usually) bypasses all requests on all nodes of the cluster.

With the discovery of the service ( Consul , ZK , etc.), you allow the centralized "consensus" service to determine which nodes for a particular service are healthy, and your application connects to nodes that the service considers healthy. Thus, while service discovery and load balancing are two separate concepts, service discovery gives you load balancing as a convenient side effect.

But, if the load balancer (say HAProxy or nginx ) has built-in monitoring and health checks in it, then to a large extent you get service detection as a side effect of load balancing! If my LB does not want to forward the request to an unhealthy node in its cluster, then this is functionally equivalent to the consensus server telling my application to not connect to the disappointing node.

Thus, service discovery tools look like 6-in-one, half-dozen in the other, equivalent to load balancers. Am I missing something? If someone had an application architecture based entirely on load-balanced microservices, what is the advantage (or not) of switching to a service-based discovery model?

+6
source share
3 answers

Load balancers typically require resource endpoints, which it balances the load on traffic. With the growth of microservices and container-based applications, dynamic containers (docker containers) created at runtime are ephemeral and do not have static endpoints. These container endpoints are ephemeral, and they change as they evict and are created to scale or for other reasons. Service discovery tools, such as Consul, are used to store endpoint information for dynamically created containers (docker containers). Tools such as container-based consul registrar registers container endpoints with service discovery tools such as consul. Tools like the Consul-template will listen for changes to the container endpoints in the consul and update the load balancer (nginx) to send traffic. Thus, both Discovery Tools services, such as Consul and Load Balancing tools, such as Nginx, coexist to provide runtime service discovery and load balancing capabilities, respectively.

Follow-up: What are the benefits of ephemeral nodes (those that come and go, live and die) over “permanent” nodes, such as traditional virtual machines?

[DDG]: everything that comes to my mind: ephemeral nodes like docker containers are suitable for stateless services like APIs etc. (There is a craving for persistent containers using external volumes - volume drivers, etc.)

  • Speed: Twisting or destroying ephemeral containers (docker containers from the image) takes less than 500 milliseconds, unlike minutes when traditional virtual machines are standing

  • Elastic infrastructure: in the age of the cloud, we want to scale in accordance with the needs of users, which implies the presence of containers with an ephemeral nature (possibly for IP addresses, etc.). Think of a weekly token campaign, for which we expect a 200% increase in TPS traffic, scale quickly with containers, and then publish the campaign and destroy it.

  • Resource use: The data center or Cloud is now one large computer (computing cluster), and containers pack the computing cluster to maximize the use of resources and, during weak demand, destroy the infrastructure for lower use of resources / resources.

Much of this is possible due to loss of communication with ephemeral containers and runtime detection using a service discovery tool such as a consul. Traditional virtual machines and tight IP binding can drown this opportunity.

+5
source

Please note that these two options are not necessarily mutually exclusive. It is possible, for example, that you can still redirect clients to the load balancer (which could fulfill other roles, such as throttling), but have a load balancer using the registry of services to search for instances.

It is also worth noting that service discovery allows load balancing on the client side, that is, the client can call the service directly without additional transition through the load balancer. I understand that this was one of the reasons Netflix designed Eureka to avoid calls between services that were supposed to go out and return through an external ELB that they would have to pay for. Client-side load balancing also provides a means for the client to influence the load balancing decision based on their own perspective of service availability.

+2
source

If you look at the tools from a completely different perspective, namely ITSM / ITIL, the load balancing will become “just like that”, while the discovery of services is part of the constant updating of CMDB, as well as all your services and their interconnections, for better visibility of the impact, in the event of downtime and a review of areas that may need to be supplemented, in the case of high availability applications.

In addition, service discovery only gives the image from the last scan, and not in real time (of course, it depends on what scan interval you set), while load balancing will maintain the current image of your application’s health.

+1
source

All Articles