Skip to content
/ hub Public

A proof-of-concept application which demonstrates microservice architecture, with Auth, ZUUL API gateway, Eureka service discovery and centralized config server

Notifications You must be signed in to change notification settings

smajji/hub

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hub

A proof-of-concept application which demonstrates microservice architecture, with Auth, ZUUL API gateway, Eureka service discovery and centralized config server

This is a proof-of-concept application, which demonstrates Microservice Architecture Pattern using Spring Boot, Spring Cloud and Docker(Docker, integration TBD).

Config service

Spring Cloud Config is horizontally scalable centralized configuration service for distributed systems. It uses a pluggable repository layer that currently supports local storage, Git, and Subversion.

In this project, I use native profile, which simply loads config files from the local classpath. You can see shared directory in Config service resources

Client side usage

Just build Spring Boot application with spring-cloud-starter-config dependency, autoconfiguration will do the rest.

Now you don't need any embedded properties in your application. Just provide bootstrap.yml with application name and Config service url:

spring:
  application:
    name: hub-auth
  cloud:
    config:
      uri: http://localhost:8888
      fail-fast: true
      

API Gateway

API Gateway - It is a single entry point into the system, used to handle requests by routing them to the appropriate backend service or by invoking multiple backend services and aggregating the results. Also, it can be used for authentication, insights, stress and canary testing, service migration, static response handling, active traffic management.

Netflix opensourced such an edge service, and now with Spring Cloud we can enable it with one @EnableZuulProxy annotation. In this project, I use Zuul to store static content (ui application) and to route requests to appropriate microservices. Here's a simple prefix-based routing configuration for Auth service:

zuul:
  routes:
    auth-service:
        path: /uaa/**
        url: http://localhost:5000
        stripPrefix: false

Service discovery

Another commonly known architecture pattern is Service discovery. It allows automatic detection of network locations for service instances, which could have dynamically assigned addresses because of auto-scaling, failures and upgrades.

The key part of Service discovery is Registry. I use Netflix Eureka in this project. Eureka is a good example of the client-side discovery pattern, when client is responsible for determining locations of available service instances (using Registry server) and load balancing requests across them.

With Spring Boot, you can easily build Eureka Registry with spring-cloud-starter-eureka-server dependency, @EnableEurekaServer annotation and simple configuration properties.

Client support enabled with @EnableDiscoveryClient annotation an bootstrap.yml with application name:

spring:
  application:
    name: auth-service

Now, on application startup, it will register with Eureka Server and provide meta-data, such as host and port, health indicator URL, home page etc. Eureka receives heartbeat messages from each instance belonging to a service. If the heartbeat fails over a configurable timetable, the instance will be removed from the registry.

Also, Eureka provides a simple interface, where you can track running services and number of available instances: http://localhost:8761

Notes
  • Need to implement Docker set up, one additional service with Mongo DB access, Load balancer, Circuit breaker and Http client
  • Also, implement centralized logging, follow Ready-to-go Docker configuration described in sample project.
  • finally implement continous delivery approach
    1. The ability to release software anytime
    2. Any build could end up being a release
    3. Build artifacts once - deploy as needed

About

A proof-of-concept application which demonstrates microservice architecture, with Auth, ZUUL API gateway, Eureka service discovery and centralized config server

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published