Rajendran Balakrishnan, Senior Manager-QA, Ness Digital Engineering, and Senior Developer Chandrakanth Puvvada provide insights into the key principles to remember while designing a microservices based enterprise application.
In the Enterprise application technology front we have multiple trends that are forcing application architectures to evolve. Application users expect a rich, interactive and dynamic user experience on a wide variety of services including mobile devices. Applications must be highly scalable, highly available and agile.
With the ever changing business models and services offerings, organizations often seek to roll out updates at regular frequency, sometimes even multiple times a day. This requirement for fast roll out of updates is not easy to be fulfilled with monolithic design which has tightly coupled infrastructure. Today, microservices architecture has emerged as a solution to have the desired changes rolled out to applications in terms of availability, scalability and agility.
‘Microservices’ describes a particular way of designing software applications as suites of independently deployable services. It has evolved from traditional service-oriented architecture (SOA) with loose coupling of components to decoupled service components and infrastructure. Microservices are built around business capabilities and are independently deployable by fully automated deployment machinery. The centralized management of these services is minimal, which may be written in different programming languages and might use different data storage technologies.
Microservice is distinct from a SOA. The latter aims at integrating various (business) applications; whereas several microservices belong to one application. In short, the microservice architectural style is an approach to develop 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.
Key design principles of microservices along with its advantages make it as a desired solution to have a scalable, easy to maintain enterprise application.
Following are key principles to remember while designing a microservices based enterprise application.
- Domain Driven Design
- Hide Implementation Details
- Failure Isolation
- Continuous Delivery through DevOps Culture
Domain Driven Design
Microservices provide the ability to separate system capability into different domains using Domain Driven Design principles. The primary objective of the domain driven design is to focus on the core domain and the associated logic. This minimizes possibilities of the application getting out of hand. It also nurtures creative collaboration between the DevOps and development teams as both should understand the domain for scaling up.
Hide Implementation Details
Microservices are small services with independent lifecycles that work together as a part of the whole application. However, each service can be independent when it has to be a part of the big structure. To enhance the ability of one service to scale independently of the others, it is important to hide each service implementation details. We could use REST protocol over HTTP and ensure services communicate with each other using a light-weight communication. Through this segregation of internal and external implementation, details can be achieved.
Monolithic implementations usually have a single logical database for persistent data across a range of applications. It becomes complex to changes over a period of time. With microservices, each service can manage its own database, either different instances of the same database technology, or entirely different database systems.
A microservice based structure is more resistant compared to the monolithic structure. For example, a malfunctioning microservice, such as with a memory leak or unclosed database connections, will only affect that service while other services continue to handle requests. In case of a monolithic application, one malfunctioning component can bring down the entire system.
Continuous Delivery through DevOps Culture
In classical monolith-based environments, there aren’t multiple separate release artifacts, so it’s relatively easy to maintain the Jenkins build jobs manually. In a microservice architecture, the number of deployment units increase and an automated solution is needed. This can be achieved through automating the build and deploy process through tools like Jenkins or CHEF by having a DevOps team. Microservices help to reduce the number of Jenkins jobs to one job for each release artifact, which is able to build, release and deploy the application / desired microservice.
Advantage of Microservices Architecture
- Each microservice is relatively small
- Easier for a developer to understand
- The IDE is faster, enhancing developer productivity
- The web container starts faster, making developers more productive, and speeding up deployments
- High rate of change
- Low cost of change
- Starts faster than a monolithic – scope is smaller than a monolithic. This leads to a smaller amount of written classes and third party libraries which must be archived. As a result, the deployment and the startup are faster.
- Scale Independently – A microservice can scale independently using X-axis cloning and Z-axis partitioning based upon their need. This is different from monolithicic applications that may have distinct requirements and yet must be deployed together.
- No long-term commitment to any stack – you can give greater flexibility to the definition of the language and stack that is best suited for a microservice. Even if you want to restrict the choice of technology, you’re not penalized because of past decisions. It enables rewriting the service using better languages and technologies.
- Independent and frequent Deployments – each microservice can be independently deployed and redeployed again, without impacting the overall system.
Today, microservices architecture has been successfully embraced by leading players in different domains and has been deployed for scaling their business and operations seamlessly. Many big names have evolved from a monolithic architecture to a microservices architecture.