What does Consul do?

Kamasu Paul
2 min readOct 28, 2022

--

image of consul usage on https://containersonaws.com/architecture/consul-connect-service-mesh

When deploying monolith applications, the application usually consists of different components, that even though independent work together and the application is deployed as a single Monolith app.

The challenge with monolithic applications is that as the application gets bigger and the team grows it becomes harder to develop and debug. Hence, the solution to the monolith problem is to divide the application into different sub-application that work independently in what is known as service-oriented architecture or microservices. This makes the development and deployment of the different sections of the system easier. But this has its own drawbacks.

The most significant problem is Discovery, because of the distributed nature of now the divided app. How do the different components(services) know where the other is?

Approaches to solving the service discovery problem.

One approach to the problem is to add a load balancer to each service and then each service hard codes, the IP address of the load balancer of the services it need. However, this introduces the problem of more load balancers which not only leads to more cost, it also leads to a single point of failure, because if the load balancer goes down, so is the service.

This is where CONSUL comes in.

How does consul solve the service discovery problem?

Consul provides a registry that whenever a service boots up, it registers itself with the registry and now whenever a service wants to communicate with that service, it queries the registry and gets the address of the service, and in case one of the instances of one service dies, the registry doesn't return it when queried for the address of that service. This avoids the problem of a single point of failure. And also avoids the problem of many load balancers.

The other problem that consul solves in a service-oriented architecture is the problem of which service is allowed to talk to the other service, it's known as the Segmentation problem.

Consul by HashiCorp provides many services beyond discovery in a microservices architecture. find out more about what it offers by visiting its GitHub page.

That's one minute. Hope it helps. Happy coding!

--

--

Kamasu Paul

Software Engineer | Backend | APIs - On a journey to write 1000 articles in 1000 days