Microservices and Software Design Principles
Micro services are small, autonomous services that work together. Software design principles abstraction, divide and conquer, modularity and separation of concerns, software design patterns, and processes help produce quality product. This post details benefits of Microservices and how Microservices relate to existing software design principles and processes and help improve software quality through combining these techniques.
What are Microservices?
Over the last few years, distributed systems have become more fine grained. From hard to manage monolithic applications, we are seeing benefits of smaller self contained service. These smaller, autonomous services which work together are referred as Microservices. Easier to change, deploy and if required retire. Many organizations have discovered that by using Microservices architecture, they can deliver software faster and embrace newer technologies. Microservices give significantly more freedom to allow greater maneuverability in making different decisions, allowing us to react faster to changes in technologies by using plug and play mechanism.
Fig 1. Monoliths and Microservices (http://martinfowler.com/articles/microservices.html)
Microservices offer many varied benefits, most of these benefits can be attributed to development in distributed systems architecture.
Microservice can be build using different technologies which are suited to achieve better performance for a particular service, providing benefit of Technology Heterogeneity. For example a social network store user interactions in a graph oriented database, but the posts could be stored in a document-oriented datastore.
Greater Resilience can be achieved with microservices. If one component of a system fails, problem can be isolated and the rest of the system can carry on working. While in a monolithic system, if the service fails everything stops working.
A monolithic system allows for scaling everything together, while Microservices provide greater opportunity with scaling individual services for better performance. This allows to control costs more effectively.
Even the smaller changes in long monolithic applications require the whole application to be deployed in order to release the changes, resulting in high impact greater risk deployment. With Microservices provide ease of deployment by making change to a single service and deploy it independently of the rest of the system.
Smaller teams working on smaller codebases tend to be more productive. This allows for better productive organizational alignment of teams.
With Microservice functionality of a service can be consumed in different ways for different purposes, allowing for reuse of functionality.
Replacing the functionality that is outdated results in huge costs to replace them with better functionality. Microservice provide optimized replaceability of a service at a smaller scale.
Design Principles and Microservices
Software design principles namely abstraction, divide and conquer, modularity and separation of concerns represent a set of guidelines that helps to avoid bad software designs. Robert Martin’s book “Agile Software Development: Principles, Patterns and Practices” talks about 3 important characteristics of a bad design that should be avoided:
- Rigidity - every change in design affects too many parts of the system.
- Fragility - unexpected parts of system break due to a change
- Immobility - hard to apply or reuse a part of the application
Microservices work specifically against these characteristics and can help improve overall software design and quality of system.
Microservices and Development Processes
Traditionally organizations split a large application into parts, development teams, UI teams, server side logic teams, and database teams. The Microservice split services organized around business capabilities. Each service team is responsible for building, testing and deploying it. Cross functional teams are responsible for building and operating each product and each product is split out into a number of individual services communicating to each other.
Software development processes like scrum defines "a flexible, holistic product development strategy where a development team works as a unit to reach a common goal" (http://en.wikipedia.org/wiki/Scrum_%28software_development%29 et a.l). This kind software development processes support Microservice architecture, where each team is responsible for building and running a product while supporting other teams and services.
Applications of Microservices
At my work we are working on a big enterprise product for managing Oracle Java distribution and deployment on thousands of systems. This system has many independent parts which are developed as big monolithic application (war file), every time there is a change, whole application has to be built deployed making the deployment process very hard and expensive. Microservices fit perfectly in this kind of process, each independent project can be build as a product, and put together to create the whole system.
Fig : Module deployment (http://martinfowler.com/articles/microservices.html)
Microservices provide many benefits to software development process and producing easily scalable services but also have many complexities similar to distribution services. Interservices communication get very complicated and network latency and overhead can cause issues.
- Newman, S. (2014), Building Microservices. O’Reilly Media Inc