Skip to content
Example of a microservice architecture using Spring Cloud
Java Shell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Spring Microservices

Example of a microservice architecture using Spring Cloud


The architecture is composed by four services:

  • discovery-service: Service Discovery Server created with Eureka
  • api-gateway: API Gateway created with Zuul that uses the discovery-service to send the requests to the services. It uses Ribbon as Load Balancer
  • article-service: Simple REST service created with Spring Boot to use as an example
  • author-service: Simple REST service created with Spring Boot to use as an example

The services: api-gateway, article-service and author-service are already configured with Hystrix (latency and fault tolerance library) and are providing a stream that you can use to monitor with a Hystrix/Turbine dashboard. You can check the Hystrix Stream accessing the service URL with / (example: http://localhost:8765/

How to use

To test this architecture you will need to have: JDK 8+, Docker and Maven installed

  • Clone this repo and enter it

  • Run the script, it will use Maven to build the .jar file for each service and then use Docker to build the containers with the .jar files

In the default configuration you will have:

  • Discovery Service running on port 8761, access http://localhost:8761 to see the dashboard
  • API Gateway running on port 8765, you will send the requests to this service
  • Two Article Services running on ports: 8080 and 9080
  • Two Author Services running on ports: 8081 and 9081

After running the containers, head to http://localhost:8761 to make sure that the four services (two article and two author) are registered in the Discovery Service, when they're all registered you can test the application with curl making requests to the endpoints below:

  • curl http://localhost:8765/api/articles
  • curl http://localhost:8765/api/articles/id
  • curl http://localhost:8765/api/articles/author/id
  • curl http://localhost:8765/api/authors
  • curl http://localhost:8765/api/authors/id


Bug reports and pull requests are welcome on GitHub at This project is intended to be a safe, welcoming space for collaboration.


This project is available as open source under the terms of the MIT License.

You can’t perform that action at this time.