Why the Fuss About Microservices?

Everyone seems to be talking about "microservices" and how they will revolutionize the world. But what are they, and what benefits do they bring?

Microservice architectures were developed in response to the drawbacks of the "monolithic" software. In monolithic software, a single process or service contains all the modules that define the application. For example, consider a very basic venue booking web application:

monolith.jpeg

An architecture based on microservices, on the other hand, is quite simply one organized as a collection of independent, loosely coupled, programs or services. If we were to design the above application as using microservices, it would look like this:

microservices.jpeg

This brings many benefits over the monolithic style.

Independence and Agility

A large development team working on a monolithic code-base will constantly be treading on each other's toes and getting in each other's way. Deployments will be slower, requiring changes to be batched up and released together, which will create a backlog of work that cannot be done while it waits for other changes to be released. This will create a chronic slow-down of the release cycle, stunting the agility of the business and affecting it's ability to react to change.

A microservices architecture, on the other hand, will have small agile teams focused on working on just one service. They can, therefore, concentrate on understanding that service really well, making it the best it can be, and releasing as often as necessary, without worrying about the cadence of other teams. This greatly increases the productivity, quality, and innovation of the organization.

More Effective Code Reuse

In monolithic architectures, it is too easy to write inflexible code that is very specific to a particular requirement. This leads to a situation where there are very similar components being created and used throughout the application, when a little bit of planning and foresight could have created a single reusable component that could have been used in all of those places instead.

Developing an application as a series of small, narrowly focused microservices enforces a level of flexibility and generalization in the design, thus allowing the service to be reused in different scenarios. This leads to an eventual increase in productivity due to code reuse.

One well-known example of this is the "Unix philosophy", where a collection of small, tightly focused command-line tools that do one thing and one thing well, can be combined together to achieve a wild variety of tasks.

Faster and More Cost-Effective Scaling

If one component of a monolithic application is receiving more throughput than others (for example, if the article rendering component of a blog receives 99% of the traffic while the user sign-up component receives the remaining 1%), the entire application still has to be deployed to multiple servers, and the size of the server has to be able to contain the entire application, not just the one component that needs scaling. This is a huge waste when the application has to be scaled up. A large application also takes longer to start up, making scaling slower.

With microservices, the articles service would scale independently of the user service. Thus it would need smaller, cheaper servers to run. The smaller application would also be launched much faster due to it's smaller size and thus could respond to changes in traffic much more quickly, leading to a much more responsive experience for the user.

Resilience

If a monolithic application has a problem in one component, the entire service goes down. If a microservice has an issue, then other services will keep running and have an opportunity to still supply some functionality. Netflix's video streaming service is the most well-known example of this resilience - when large parts of the internet went down due to AWS S3 becoming unavailable temporarily, Netflix were still able to stream their video at a reduced video quality.

Summary

Using microservices brings many benefits, at the expense of some overhead, compared to monolithic applications. However, when done correctly, they accelerate development and innovation and thus are worth it. There are some hurdles that would have to be crossed when using microservices architecture, however serverless computing helps to overcome these with unprecedented ease. This follow-up article explains more about this.