Microservices Patterns

A pattern is something that can be repeated regularly and in a predictable manner.

This concept applies in all contexts—in building, in designing, in IT, and in every context where something needs to be done.

The concept of patterns started late in the 70s in regards to architecture and building designs, but patterns have always been around. Look at nature, for example—it is full of patterns, both repeatable and predictable. They occur in spirals, waves, and broccoli, and in mathematics with symmetric geometry, fractals, and so on.

However, in our context—the IT context—we first found patterns in the middle of the 90s in one of the books I read.

The pattern language continued to evolve to keep up with the speed of the evolution and revolution of IT, and at the beginning of the new millennium, new tools and systems were coming out. The internet was exploding and distributed systems went public with new infrastructures, new architectures, and new patterns.

Before we start, it's worth mentioning that the microservices architecture is an alternative to monolithic architecture, in the sense that every architecture has its own pros and cons—it's all about the trade-off.

The old principles and patterns, such as service discovery and routing from the SOA, are still valid and in use on both monolithic and microservice architectures. However, with microservices and containers, methods to design, implement, and deploy software have changed drastically. Applications are now optimized for flexibility, scalability, failure, elasticity, and to adapt to new requests and businesses rapidly. Driven by new principles, these new architectures require a different set of patterns and practices to be applied.

In this chapter, we will not visit and describe the complete lists of patterns to be used with the microservices approach, but we will concentrate on the most used ones to get you started and interested in the topic of patterns. There are tons of books about patterns, and if you care about cloud environments, you should read the Java EE 8 Design Patterns and Best Practices by Packt (https://www.packtpub.com/application-development/java-ee-8-design-patterns-and-best-practices).

The patterns that will be covered in this chapter are as follows:

  • Decomposition
  • API gateway
  • Bulkheads
  • Circuit breaker
  • Sidecar
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset