Service Discovery in Microservices Architecture is the most essential component and requires careful configuration to recover from network partitioning,hardware failures, etc. I am going to present a decentralized and distributed Service Discovery solution based on Airbnb Smartstack and Spring Boot (without the need for Spring Eureka). You can read more about components, architecture and advantages of Smartstack on Airbnb blog.
The core components of Smartstack are Nerve and Synapse. A architecture with Smartstack is given here
When using Spring Boot, Eureka serves as the Service Discovery component which requires configuration to be mentioned in dependent component. But Smartstack will help decouple this.
I am going to reuse the Docker images from newsweaver and use a spring boot based sample project (Caution : Do not use these Docker images in production, one should not rely on public docker images as most of them have vulnerabilities. Rebuild the docker images and use private registry).
Start Zookeeper
Smartstack relies on Zookeeper as a key-value store to keep track of all the discovery information. You can start use your own Zookeeper, or simply start it in container (and expose it to the host on port 2181):
1
|
|
Inspect the IP address of docker container using (docker inspect jplock/zookeeper)
Connect to Zookeeper Docker container
1
|
|
shows lot of verbose and ends in a terminal
1 2 |
|
Run the Spring Boot Webservice
Now I am building Docker container of the sample Spring Boot Rest Webservice with nerve and running it, the code for the project is here
1 2 |
|
You should be now seeing the service information under nerve
1 2 |
|
Conclusion
So we achieved service registration in Zookeeper using Smartstack and decoupled the configuration from Spring Boot project. In Part II I will show how to consume this service.