Before microservices, engineers used to scale app infrastructure vertically by buying better servers, better cables, etc. The monolithic applications consisted of the web server itself & an embedded data storage system. They were just built & packaged into one or two binaries. These binaries were then uploaded to a server rack and run directly on the machine.
With the advancement of the internet, horizontal scaling was obvious. Although the earliest horizontal scaling was just running duplicates of the web server, with the advancement of the cloud, microservice architecture has rapidly begun to dominate the playground.
Today Google receives 3.5 billion search queries every day — no matter how big — will be able to handle that with the help of distributed systems.
The idea of microservices is to split up a huge application into individual components, called services, that perform a specialized task. So instead of having a single web server process, developers break the application into services like a user authenticator, page server, API server, database model service, etc.
Company Use Cases
Let’s hear from companies about their experiences on using microservices
Began its journey with a monolithic architecture, Uber initially was built for a single offering in a single city. As core domain models grew and new features were introduced, their components became tightly coupled, and enforcing encapsulation made separation of concerns difficult. They adopted microservices.
How to utilize microservice? Is it safe in terms of functionality? Is it resilient to fault tolerance?
- IDL & Apache Thrift tools adopted – Uber engineers used Interface Definition Language (IDL) that provides lots of pre-built tooling was ideal for them. Apache Thrift which is a set of libraries and tools for building scalable cross-language services met their requirements.
- Thrift guaranteed safety – services are bound to use strict contracts. The contract describes how to interact with that service including how to call service procedures, what inputs to provide, and what output to expect.
- Libraries created – they wrote libraries that ensure clients are able to deal with failure/latency scenarios successfully.
For the past 8 years, Netflix had been building and evolving a robust microservices in AWS. Their microservices decouple engineering teams from each other, allowing them to build, test and deploy their services as often as they want.
This flexibility enables teams to maximize their delivery velocity & reliability, which are paramount design considerations for any solution at Netflix.
Can they provide engineers at Netflix the benefits of a monorepo approach and still maintain the flexibility of distributed repositories?
- Publisher feedback – provide the owner of shared code fast feedback as to consumers, both direct and transitive. Allow teams to block releases based on downstream breakages.
- Managed source – provide consumers with a means to safely increment library versions automatically as new versions are released.
- Distributed refactoring – provide owners of shared code a means to quickly find and globally refactor consumers of their Java API via Git repositories containing consumer details.
From a tiny online bookstore, Amazon grew to one of the largest stores on earth. They have more than 55Mn active customer accounts, more than 1Mn active retail partners worldwide & between 100-150 services are accessed to build a page.
The big architectural change that Amazon made was to move from a two-tier monolith to a fully-distributed, decentralized, services platform serving many different applications to handle the traffic load.
Is the system tolerant to network partitions? Is it consistent? Does it ensure service availability?
- Overlap of availability & consistency – for scaling, they have to go for network partition, so they choose the right overlap of availability and consistency of services. Example – For the checkout process, they always want to honor requests to add items to a shopping cart because it’s revenue producing. In this case, they choose high availability. Errors are hidden from the customer and sorted out later.
– When a customer submits an order they favor consistency because several services–credit card processing, shipping, and handling, reporting–are simultaneously accessing the data.
- Need-based approach – specific approach based on the needs of the service is chosen.
To know more on other various companies experience on implementing microservices refer here.
Benefits of Using Microservices
Why these big-giants & other companies opted for deploying microservices in their infrastructure?
While doing my research, I came across a quite huge list of benefits microservices offer. Here I decided to cut it short & highlight the most important benefits of microservices.
Flexibility & Scalability: Microservices facilitates horizontal scaling of its components. You can simultaneously run many replicas of the same service if one service(such as neural net) is under heavy load.
Independent Services: Each component can be written in a different language like a database service might be written in C & the web server in Python. These services can be updated & modified as required.
Pluggability: A company does not even need to write all of its services. Third party applications like MySQL, Elasticsearch, Redis are all microservices that can be easily integrated into your system.
Fault Tolerance: For a properly designed architecture, the failure of one replica of a service should not cause your whole pipeline or even that service to fail. Similarly, a bug in a particular service does not impact the uptime of other non-related services.
Everything has a flip side, same for microservices. There is overhead and complexity involved in bouncing requests from one service to another.
The good news is there are a ton of researchers, corporations, and startups working on all aspects of solving these problems, the next step of what is called as Serverless and Function-as-a-service(FaaS).
Projects like Jenkins, Spinnaker, and Jaegertracing are among the most popular open source solutions today, with new innovations being made daily in the industry to match up with increasing customer demands.