In the introduction part, I put some note about the comparison between microservice architecture and monolithic architecture. I am sorry to write it in my mother language :p Well, nothings important, just my summary note of what I’ve read.

In this article, I want to write about step-by-step of how to build a microservice application using spring boot and its library. The architecture I want to build is as follows:

The library included is as follows:

  • User Interface Layer: React
  • Gateway: Zuul
  • Discovery Server: Zookeeper
  • Logging library: Sleuth, Zipkin
  • SVC: Gitlab
  • API Documentation: Swagger
  • Monitoring: Actuator
  • Fault Tolerance: Hystrix
  • Virtual Environment: Docker

Long way to go~~

Actually this architecture is not a really new architecture. We’ve learned it in college. Its called distributed system. In above picture, I separated the service into 5 small services (might be changed in the future haha). To let each service discovers each other, we need to implement one server called Discovery Server. Each service will register himself to the discovery server. So that other service will know how to find this service by asking the discovery server.

The gateway will be used for distributing the accessed service from client. So gateway’s role is to direct the call to the right service.

We need to implement circuit breaker (feature included in Hystrix), to tolerance the fault. In distributed system, error is easily occurred. When error occurred, we need to solve the error as soon as possible before it affect to others and keep spreading. That is why we need circuit breaker, to break the network circuit, so that it prevents the error from spreading.

Step-by-Step:

  1. Configure Zookeeper
  2. Configure Zookeeper in Docker
  3. Configure Gateway
  4. Configure Circuit Breaker
  5. Configure Sleuth, Zipkin
  6. Create Swagger
  7. Configure Actuator

 

Project Source Code:

https://gitlab.com/ninankara/atmosphere

 

References:

https://o7planning.org/en/11733/understanding-spring-cloud-eureka-server-with-example

https://o7planning.org/en/11739/undertanding-load-balancing-in-spring-cloud-with-ribbon-and-example

https://dzone.com/articles/microservice-architecture-with-spring-cloud-and-do