5. Hystrix – Circuit breaker
pattern
Hystrix is a latency and fault tolerance library designed
to isolate points of access to remote systems, services
and 3rd party libraries, stop cascading failure and
enable resilience in complex distributed systems where
failure is inevitable.
6. Service Discovery:
Eureka Server
1. Eureka is the Netflix Service Discovery Server and Client.
The server can be configured and deployed to be highly
available, with each server replicating state about the
registered services to the others.
2. When a client registers with Eureka, it provides meta-
data about itself such as host and port, health indicator
URL, home page etc
3. Eureka receives heartbeat messages from each instance
belonging to a service. If the heartbeat fails over a
configurable timetable, the instance is normally removed
from the registry.
4. @EnableEurekaClient to enable Eureka client.
7. Eureka Server peer-peer
communication
Eureka can be made even more resilient and available by running multiple instances and
asking them to register with each other
spring:
profiles: peer1
eureka:
instance:
hostname: peer1
client:
serviceUrl:
defaultZone: http://peer2/eureka/
eureka:
instance:
hostname: peer2
client:
serviceUrl:
defaultZone: http://peer1/eureka/
8. Router and Filter: Zuul
1. Zuul is a JVM based router and server side load balancer by Netflix.
2. Zuul is the front door for all requests from devices and web sites to the backend of the
Netflix streaming application.
3. Could also be used a reverse proxy server
4. Netflix uses Zuul for the following
1. Authentication
2. Insights
3. Stress Testing
4. Canary Testing
5. Dynamic Routing
6. Service Migration
7. Load Shedding
8. Security
9. Static Response handling
10. Active/Active traffic management
9.
10. Configuration
application.yml :
1. zuul:
routes:
users: /myusers/**
This means that http calls to "/myusers" get forwarded to the "users"
service (for example "/myusers/101" is forwarded to "/101")
2. zuul:
routes:
users:
path: /items/price**
url: http://example.com/price_service_v2
- http calls to "/items/price/**" get forwarded to above URL.
11. Client Side Load Balancer:
Ribbon
1. A central concept in Ribbon is that of the named client.
2. Ribbon could be used in conjunction with Eureka server.
3. Ribbon could also be used independently by providing
servers list as shown below
stores:
ribbon:
listOfServers: example.com,google.com
13. Feign Client
1. Feign is a declarative web service client. It makes
writing web service clients easier.
2. Feign could be used in conjunction with Ribbon to
locate host names.
14. Config Server
1. A central place to manage external properties for
applications across all environments.
2. Exposes REST APIs (could be consumed by any
language).
3. Backed by Git.
15. Spring Cloud Bus
1. Spring Cloud Bus links nodes of a distributed system
with a lightweight message broker.
2. Could be used as a communication channel
between apps.
3. The only implementation currently is with an AMQP
broker as the transport
16. Configuration & End points
1. Configuration in application.yml :
spring:
rabbitmq:
host: mybroker.com
port: 5672
username: user
password: secret
2. /bus/env - sends key/values pairs to update each nodes Spring
Environment.
/bus/refresh - will reload each application’s configuration, just as if
they had all been pinged on their /refresh endpoint.
/bus/refresh?destination=customers:9000 - where the destination
is an ApplicationContext ID