ActiveDev Inc.
  • Home
  • ADCLOUD
    • Getting Started
    • Developing a Microservice
    • Reference
  • Services
  • About
  • Contact
  • Articles

microservices - Spring cloud

4/4/2018

 
Spring Cloud
​
​In our last microservices-springboot article, we went through some of the ways that Spring helps us create REST microservices. But developing an application is just one piece of the puzzle.
As developers, we are so focused on developing the application that we sometimes forget about what happens once its deployed to production. We work hard to ensure we keep up to date with all of the best practices such as using SOLID principles, design patterns, Test Driven Development, and Continuous Integration. Nothing makes us happier than delivering a product with zero known defects. It makes the production support team happy too. Of course, that happiness can quickly turn to frustration if the application is a nightmare to deploy and configure. Even worse, if the application cannot be monitored forcing the support team to constantly be in reactive mode.

Spring Cloud along with Netflix OSS can create an environment that addresses a lot of these common issues.

Configuration
Having to maintain configuration files for multiple services can be time-consuming and error-prone. Spring Cloud provides a configuration server that maintains all of the configuration files in one central repository. Springboot applications can automatically tie into the config server by simply including the appropriate starter project.

Discovery
Without discovery, service locations would have to be hard-coded or maintained in a list. Each time a service was moved, every client would need to be modified. Even with small applications, this can quickly get out of hand.

Luckily Spring provides a Netflix discovery service called Eureka which allows services to register their location. Clients now only need to know the location of the discovery service and the service id. A gateway can further simplify this.

Gateway
Netflix has also shared their reverse proxy which is known as Zuul. It can proxy calls to microservices. This is extremely helpful as clients only need to know about the gateway. The gateway would determine where to route the request based on the url passed in. There are multiple configurations, but one of the more common ones is for the url to contain the service-id which the gateway uses to lookup the actual location from the discovery service.
In addition to routing, the gateway can also execute filters before and after a request is executed. This opens the door to many possibilities such as:
  • Logging
  • Auditing
  • Security and Role Based Authorization Control
  • and much more
The gateway can also take advantage of Ribbon for client side load balancing and Hystrix to provide circuit breakers and fallbacks for the services.

Circuit Breakers and Fallbacks
Netflix provides Hystrix which does the following (taken from their description on Github):
  1. Latency and Fault Tolerance - Stop cascading failures. Fallbacks and graceful degradation. Fail fast and rapid recovery. Thread and semaphore isolation with circuit breakers.
  2. Real-time Operations - Real-time monitoring and configuration changes. Watch service and property changes take effect immediately as they spread across a fleet. Be alerted, make decisions, affect change and see results in seconds.
  3. Concurrency - Parallel execution. Concurrency aware request caching. Automated batching through request collapsing.
​
Health and Metrics
Spring provides many ways to monitor the health of the system. This can be achieved through :
  • Eureka Dashboard - to see the status of the registered services
  • Hystrix Dashboard - to view the circuits and thread pools
  • Actuator - exposes metrics for each Spring Boot application
  • Spectator - collects metrics
  • Atlas - manages metrics
​
Next
This article just scratches the surface on what Spring Cloud has to offer. In upcoming articles, we look at AD Cloud and how it can help tie everything together.

Comments are closed.
    Picture
    Visit our ​Code Repository for samples and demos.

    ARTICLES

    All
    Becoming A Consultant
    Development
    EAI - Part 1
    EAI - Part 2
    Microservice - Spring Boot
    Microservice - Spring Cloud
    Problem Solving
    Roadmap

Site powered by Weebly. Managed by SiteGround
  • Home
  • ADCLOUD
    • Getting Started
    • Developing a Microservice
    • Reference
  • Services
  • About
  • Contact
  • Articles