Skip to content

Spring Microservices break up your code into small, distributed, and independent services that require careful forethought and design. Fortunately, Spring Boot and Spring Cloud simplify your microservice applications, just as the Spring Framework simplifies enterprise Java development. Spring Boot removes the boilerplate code involved with writi…

License

Notifications You must be signed in to change notification settings

joaocarlos1994/spring-cloud

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Spring Cloud Book

Microservice Patterns

Core Development Patterns

The core development microservice development pattern addresses the basics of building a microservice.

  1. Service granularity: Making a service too coarse-grained with responsibilities that overlap into different business problems domains makes the service difficult to maintain and change over time. Making the service too fine-grained increases the overall complexity of the application and turns the service into a “dumb” data abstraction layer with no logic except for that needed to access the data store.
  2. Communication protocols: How will developers communicate with your service? Do you use XML (Extensible Markup Language), JSON (JavaScript Object Notation), or a binary protocol such as Thrift to send data back and forth your microservices? We’ll go into why JSON is the ideal choice for microservices....
  3. Interface design: What’s the best way to design the actual service interfaces that developers are going to use to call your service? How do you structure your service URLs to communicate service intent? What about versioning your services? A well-design microservice interface makes using your service intuitive.
  4. Configuration management of service: How do you manage the configuration of your microservice so that as it moves between different environments in the cloud you never have to change the core application code or configuration?.
  5. Event processing between services: How do you decouple your microservice using events so that you minimize hardcoded dependencies between your services and increase the resiliency of your application?

Microservice routing patterns

  1. Service discovery: Service discovery abstracts away the physical location of the service from the client. New microservice instances can be added to scale up, and unhealthy service instances can be transparently removed from the service.
  2. Service routing:Service routing gives the microservice client a single logical URL to talk to and acts as a policy enforcement point for things like authorization, authentication, and content checking.

Microservice client resiliency patterns

Because microservice architectures are highly distributed, you have to be extremely sensitive in how you prevent a problem in a single service (or service instance) from cascading up and out to the consumers of the service. To this end, we’ll cover four cli- ent resiliency patterns:

  1. Client-side load balancing:The service client caches microservice endpoints retrieved from the service discovery and ensures that the service calls are load balanced between instances.
  2. Circuit breakers pattern:The circuit breaker pattern ensures that a service client does not repeatedly call a failing service. Instead, a circuit breaker "fails fast" to protect the client.
  3. Fallback pattern:When a client does fail, is there an alternative path the client can take to retrieve data from or take action with?
  4. Bulkhead pattern:How do you segregate different service calls on a client to make sure one misbehaving service does not take up all the resources on the client?

Microservice security patterns

There is more note on Chapter 7.
  1. Authentication
  2. Authorization
  3. Credential management and propagation

Microservice logging and tracing patterns

There is more note on Chapter 9.
  1. Log correlation:All service log entries have a correlation ID that ties the log entry to a single transaction.
  2. Log aggregation:An aggregation mechanism collects all of the logs from all the services instances.
  3. Microservice tracing:The development and operations teams can query the log data to find individual transactions. They should also be able to visualize the flow of all the services involved in a transaction.

Microservice build/deployment patterns

Note on Chapter 1.

Command to create Kafka container on docker:

docker run -p 2181:2181 -p 9092:9092 --env ADVERTISED_HOST=localhost --env ADVERTISED_PORT=9092 spotify/kafka

About

Spring Microservices break up your code into small, distributed, and independent services that require careful forethought and design. Fortunately, Spring Boot and Spring Cloud simplify your microservice applications, just as the Spring Framework simplifies enterprise Java development. Spring Boot removes the boilerplate code involved with writi…

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published