Back in the day most systems started as a monolithic system, which basically means the entire application exists in a single code base and is deployed and, importantly, scaled as a single unit.
A monolithic application puts all its functionality into a single process… and scales by replicating the monolith on multiple servers. A monolithic application is harder to scale, as one small change must be deployed across all processes.
What are microservices ?
According to wikipedia, microservices are a software architecture style in which complex applications are composed of small, independent processes communicating with each other using language-agnostic APIs. These services are small, highly decoupled and focus on doing a small task, facilitating a modular approach to system-building.
Software developer advocates James Lewis and Martin Fowler gave the best definition we could find for this increasingly popular architectural pattern:
“The microservice architectural style is an approach to developing a single application as a suite of small services, each running in its own process and communicating with lightweight mechanisms, often an HTTP resource API. These services are built around business capabilities and independently deployable by fully automated deployment machinery. There is a bare minimum of centralized management of these services, which may be written in different programming languages and use different data storage technologies.”
A microservices architecture puts each element of functionality into a separate service…and scales by distributing these services across servers, replicating as needed.
Characteristics of microservices
- Small with a single responsibility
- Each application does one thing
- Small enough to fit your head – If a class is bigger than by head then it is too big
- Small enough that you can throw them away – Rewrite over Maintain
- Status aware and Auto scaling – multiple consumers (Competing Consumers pattern example
- WatchDog process to monitor app-status (expose metrics about itself eg: queue dept) auto-scale to meet throughput requirements.
- A single capability composed of a small number of activities and exposing a uniform interface (REST)
- Each is entirely decoupled from it’s clients, scalable, testable and deployable individually.
How does a microservice outshine a monolith?
- It makes your app more scalable with smaller teams.
- Enables modularity and is more open to change in general.
- Uses a smaller codebase.
What are microservice architecture’s limitations?
- It can cause communication problems among different parts of the app and within your team.
- It requires increased effort later on to catalog, test, and fix incompatibilities.
- You should still build the monolith before building the microservices on top of it.