A microservices architecture provides a highly scalable and distributed modern system
Modernizing applications in today’s world often means migrating to cloud-native applications built as microservices. They are then deployed using container technologies like Docker and Kubernetes. Netflix and Atlassian did it, as well as countless other organizations. The reason is, a microservices architecture improves scalability, development speeds, and service iteration.
A microservices architecture splits an application into a series of independently deployable services that communicate through APIs. This allows each individual service to be deployed and scaled independently. This approach allows for the rapid and frequent delivery of large, complex applications. In contrast to a monolithic application, a microservices architecture allows teams to implement new features and make changes faster, without having to rewrite a large portion of the existing code.
Some key characteristics of a microservices architecture are:
Example of a microservice architecture
Consider a hypothetical e-commerce software project as an example. The following diagram is of an e-commerce site with a web application and mobile application that interacts with multiple microservices, each of which provides specific capabilities for a domain.
Modern web applications run in browsers and are often served from a content distribution network (CDN). A CDN provides the benefit of distributing web applications to servers around the world, so they can be downloaded by web browsers quickly. CDNs are also used to serve media assets like images, audio, and video. For example, in this system, the images and videos of the goods for sale are served from the CDN.
The microservices in this graphic are:
The applications interact with the microservices via REST APIs that each of the microservices publishes. An API Gateway allows the applications to rely on the APIs provided by the microservices and allows the microservices to be swapped for other microservices with the same API.
Each microservice is composed of a service and database. The services handle the REST API, implement business logic, and store data in a database. For microservices, we isolate their resources such as databases and queues from each other, following the 12 Factor App contract.
How to build microservices
For many organizations, starting with a monolith architecture is the first step. Then, you will need to split the codebase into multiple services, implement the right patterns to fail gracefully and recover from network issues, deal with data consistency, monitor service load, and more. But that’s just the technical side. You’ll also need to reorganize your teams and most likely embrace a DevOps culture.
Then comes the hard part: you’ll need to decompose the monolith into microservices. Refactoring a monolithic database schema can be a delicate operation. It's important to clearly identify which datasets each service needs and any overlaps. Continuous delivery helps reduce the risks of release failure, as well as ensure your team is focused on building and running the application, rather than being stuck deploying it.
Microservices vs. monolithic architecture
A monolithic architecture is a traditional model of a software program, which is built as a unified unit that is self-contained and independent from other applications. A microservice architecture is like an inverse of a monolith, since it is an architectural method that relies on a series of independently deployable services. Monoliths can be favorable early in a project's life due to the ease of code management, cognitive overhead, and deployment. Once a monolith application becomes large and complex, it becomes difficult to scale, continuous deployment is challenging, and updates can be cumbersome.
While a monolithic application is built as a single, indivisible unit, microservices break that unit down into a collection of independent units that contribute to the larger whole. An application is built as a series of independently deployable services that are decentralized and autonomously developed.
Microservices fall under the category of a distributed system. By definition, a distributed system is a collection of computer programs that utilize computational resources across multiple, separate computation nodes to achieve a common, shared goal. Distributed systems help to improve system reliability and performance and allow easy scaling.
The nodes in a distributed system provide redundancy, since if a node fails the other nodes can replace the failure. Each node can scale horizontally and vertically, which improves performance. If a system undergoes extensive load, extra nodes can be added to help absorb the load.
Kubernetes vs. Docker
Docker is a commercial containerization platform and runtime that helps developers build, deploy and run containers. While Docker provides an efficient way to package and distribute containerized applications, running and managing containers at scale is a challenge with Docker alone.
Kubernetes is a popular open-source platform that orchestrates container runtime systems across a cluster of networked resources. It can be used with or without Docker. While Docker is a container runtime, Kubernetes is a platform for running and managing containers from many container runtimes.
Software configuration management is a process that manages, organizes, tracks, and monitors changes to a software systems configuration metadata. It is commonly used alongside version control and CI/CD infrastructure.
Configuration management helps engineering teams build robust and stable systems through the use of tools that automatically manage and monitor updates to configuration data. It helps to better manage software sprawl in a microservice architecture by creating a “source of truth” with a central location for configuration.
Bookmark these resources to learn about software development and ongoing updates about Compass