Picture this- your enterprise is building a brand new web or mobile application. What is one of the first things on your checklist that you need to get done with? It is naturally architecting its back-end. The conventional approach of building the backend of an application was a monolithic one. Historically, (mind you, in terms of software, historically means just a decade or two ago) developers preferred the monolithic architecture patterns to implement applications. However, these later became problematic since applications started getting larger and more complex.
Fast forward to 2021, developers are swiftly turning to microservices software development architecture patterns for their application development needs. In this approach, a monolithic application is broken down into smaller services that are bundled and deployed independently. This makes applications simpler to build, easier to expand, and easier to scale.
With this blog series, I am going to help you take a closer look at Microservices and its architectural patterns. My first blog of the series answers the following questions:
- What is Microservices?
- Why do we need Microservices?
- What are the top attributes of a Microservice Architecture?
What is Microservices?
Microservices is an architectural approach of building an application as a small suite of services, each running in its process. It uses mechanisms like HTTP APIs or message brokers that allows process to communicate with each other.
With Microservices, you can build fully automated and independently deployable applications using diﬀerent data storage technologies, all while having minimum centralized management (orchestration) of services.
Why do we need Microservices?
With the rapidly changing business environment, the last two decades have seen a massive advancement in the adoption of technology. The last decade particularly brought forth a unique challenge for organizations, i.e., to scale.
Businesses today want to expand their reach in order to grow. To maintain a competitive edge, they need to come up with new features quickly. At the same time, their application also needs to adhere to the basic requirements like availability, reliability, and better performance (low latency).
Typically, we observe the following two-front challenges-
- Business Challenge: Plan and roll new features continuously to achieve a robust application for your users
- Technical Challenge: Design an application that will help the business achieve its goal for which, the application needs to be scalable, loosely coupled, reliable, and available, and still have better performance.
Building Microservices can help enterprises overcome these challenges. Let us now look around the unique characteristics & attributes of Microservices that make it possible to build a scalable architecture of any application.
What are the top 6 attributes of Microservices?
Microservices are typically characterized with their top 6 fundamental yet interesting attributes like:
1. Cohesive Functionality
Each service in the microservice ecosystem should be ﬁne-grained with a well-deﬁned service boundary. It is a practice of deﬁning a service boundary based on the domain/sub-domain of an application. Additionally, it should also be noted that services should not be overly ﬁne-grained as it may lead to an operational nightmare.
2. Independent Codebase
Each service should have its codebase and to select the technology of implementation as per its need. With an independent code base, each service can be built and tested independently, which not only simplifies the deployment but also makes it easier to modify the code base when the application needs to updated.
3. Private Data / Database per Service
Each monolith application has a centralized database at the center of its functionalities. A centralized database often becomes a scaling bottleneck. Moreover, the same database is often used for various activities like Create-Read-Update-Delete (CRUD) operations, reporting, logging, etc. Typically, the application may need various databases based on its use case. The core of microservice architecture revolves around the principle of “You Build You Maintain”.
This essentially means each service should have its own separate database. The data exchange across diﬀerent services takes place either through HTTP (REST/SOAP) or Service Brokers.
4. Loosely Coupled
Each team can build its technology stack, deﬁne its development roadmap, release cycle, etc. using the “You Build You Maintain” principle. It overall aims for all services to be loosely coupled with each other and have no overlap or tight integration.
5. Independently Deployable
Each service can be deployed independently, making it possible to roll out changes without aﬀecting the existing clients or other services. Having a well-deﬁned versioning pattern is required to keep the clients compatible and to provide a smooth migration to the desired version of the service.
6. Stateless and Self-Bootable
Each Microservice should be able to boot itself into a valid state at any time without having tight dependencies on other services or to past data. Microservices should be able to scale out horizontally at all times based on processing needs. Therefore, it is recommended to avoid having a locally stored state such as local ﬁle stores, local DB, caching, etc. Instead, you can store any state in a centrally managed data store to ensure any state is consistently shared between load-balance and auto-scaling setup.
Implementing a Microservice architecture can be very complex if it is not properly designed. Incorrect/ faulty design is a single point of a disaster of Microservice Architecture. And, with this blog, I have tried to walk you through the various tiers of Microservices Architecture, its attributes, implementation options, and a brief on tools and patterns that can be used to deploy a scalable architecture.
Now that you are acquainted with the modern software wonder that is microservices, you will be pleased to know that many organizations such as Netﬂix, Uber, Spotify, etc. have successfully implemented this technology and it has given them great ﬂexibility to roll out new features quickly. Hopefully, this helps my endeavor to get you onboard the microservices bandwagon.
In my next blog, we will dive deep into the above-mentioned tools and patterns that can help you build a robust Microservice architecture. I hope you found this blog useful.
|So, you have read everything there is to read about microservices. Take this short survey to understand where you stand with it.||Take Survey|