Introduction
As modern, microservices-based applications gain popularity, containers are an attractive building block for creating agile, scalable, and efficient microservices architectures. Whether you are considering a legacy system or a greenfield application for containers, there are well-known, proven software design patterns that you can apply.
Microservices are an architectural and organizational approach to software development in which software is composed of small, independent services that communicate to each other. There are different ways microservices can communicate, but the two commonly used protocols are HTTP request/response over well-defined APIs, and lightweight asynchronous messaging. These services are owned by small, self-contained teams. Microservices architectures make applications easier to scale and faster to develop. This enables innovation and accelerates time-to-market for new features. Containers also provide isolation and packaging for software, and help you achieve more deployment velocity and resource density.
As proposed by Martin Fowler
-
Componentization via services
-
Organized around business capabilities
-
Products not projects
-
Smart endpoints and dumb pipes
-
Decentralized governance
-
Decentralized data management
-
Infrastructure automation
-
Design for failure
-
Evolutionary design
These characteristics tell us how a microservices architecture is supposed to behave. To
help achieve these characteristics, many development teams have adopted the twelve-factor app
-
Codebase - One codebase tracked in revision control, many deploys
-
Dependencies - Explicitly declare and isolate dependencies
-
Config - Store configurations in the environment
-
Backing services - Treat backing services as attached resources
-
Build, release, run - Strictly separate build and run stages
-
Processes - Execute the app as one or more stateless processes
-
Port binding - Export services via port binding
-
Concurrency - Scale out via the process model
-
Disposability - Maximize robustness with fast startup and graceful shutdown
-
Dev/prod parity - Keep development, staging, and production as similar as possible
-
Logs - Treat logs as event streams
-
Admin processes - Run admin/management tasks as one-off processes
After reading this whitepaper, you will know how to map the microservices design characteristics to twelve-factor app patterns, down to the design pattern to be implemented.