Microservice-Architecture
Sample currency-conversion app made of multiple micro-services.
Microservices include:
- limits-service: manages constants related to deployment
- currency-conversion-service: calculates equivalent value in currency
- currency-exchange-service: constants related to currency conversion
- netflix-eureka-naming-server: recognizes various instances of different services for load-balancing and communication between micro-services
- netflix-zuul-api-gateway-server: API gateway for all micro-services to implement common features like authentication/authorization, fallback methods, etc.
- without gatewayRouter: http://localhost:8765/{app-name}/{uri}
- with gatewayRouter: http://localhost:8765/{uri}
Dependencies include:
- H2database: In-memory database
- Feign-Client: Useful for creating proxy between microservices
- spring-cloud-loadbalancer: Useful for loadbalancing, imported with project at https://start.spring.io/
- Zuul-Client
- Hystrix
- Eureka-Client: To register each microservice with eureka, useful for load-balancing and communication between microservices
- Sleuth-Client
- Zipkin-Client: For distributed tracing of logs
- RabbitMQ-Client: Useful for communication between micro-services and zipkin
Local Setup
- Requirements include:
- Setup a local-gitconfig-repo: To fetch limits from limits-service
- RabbitMQ: For communication between the microservices and Zipkin
- Zipkin: To trace logs of different microservices at a single place
- Run at commandline:
RABBIT_URI=amqp://localhost java -jar zipkin.jar
- Default url: http://localhost:9411/zipkin
- Run at commandline:
- Run each microservice as a Java application
Docker Setup
- Building docker images for each microservice:
mvn spring-boot:build-image -DskipTests
- Update image name in docker-compose.yaml
- Run
docker-compose up