What is a Microservice?

Aditi Chaudhry
3 min readJul 14, 2017

--

Microservices are becoming a very popular architecture design for application design. But every time someone tries to explain what a microservice is to me, I have the same question: what exactly is a microservice and how is it different than an API (if it even is different)?

Last week I described an API as an interface that allows software applications to communicate with each other. A microservice on the other hand, is a small component of a large application. The API is the interface to expose the functionality in the components (aka microservices). APIs are not microservices and microservices are not the implementation of an API. They are related, but not the same.

But what’s the need for microservices, why aren’t APIs good enough? Applications tend to grow overtime, becoming monolithic beasts. In these situations, the complexity of the application increases to the point where a single developer cannot fully understand the whole code base. Thus, bug fixes and implementing new features becomes more difficult and time consuming. What’s worse is that these new changes may not even be made correctly because of the complexity of the application.

Another problem with monolithic applications is that they are difficult to continuously deploy because you have to deploy the whole application for one change, even if it’s a small one. The time it takes to re-deploy and start-up the application cuts into valuable time, thus decreasing productivity. Additionally, these huge applications are not resilient because one bug can bring down the whole application since it is all running in one process.

Microservices solve these problems through the idea that you should break your large application into small, decoupled, independent systems that connect back together to make your application work. The total functionality remains unchanged, but the application has been broken into manageable chunks. Each chunk is a service that can be developed independently by a team focused on that service. This means that the team actually understands the code base! Thus they can write, deploy and test faster, increasing productivity. The team can choose the language they want to write in or the newest technology that they want to use without being held back by the rest of the application.

Another benefit of microservices is that each service can be deployed independently. This feature is beneficial because now development teams can use the hardware that best matches each service’s resource requirements instead of having to compromise on the hardware. Independent deployments leads to scalability because each component can be scaled appropriately, enabling efficient use of resources due to changes in demand. Additionally, the microservice architecture is resilient because one component failing will not take down the whole application as the containers are independently deployed.

However, microservices are not the silver bullet to software development architecture. Like all technologies, microservices have their drawbacks as well. Microservices can become very complex due to the distributed system. Integration, deployment, testing and management of the application becomes complicated when there is an increased number of services. For example, making a change across multiple services can be a challenge because of the dependencies between the services. In a monolithic application, you can change the modules, integrate the changes and deploy in one step. Testing is also simpler because you can launch an end-to-end test with minimal effort.

In a microservice architecture however, you have to coordinate the changes between services and plan out the deployment to roll out the changes. To test your change, you have to ensure that all the dependent services are working including the service you made the change in.

Additionally, in a microservice architecture, developers have to implement some type of communication mechanism between the services. This adds overhead to the application increasing the complexity.

To summarize, the microservice architecture enforces modularity which leads to individual services that can be faster to deploy and easier to understand and maintain. As with all technologies, microservices have their disadvantages as outlined above. As a developer/architect, it’s important to understand which architecture is best for your project as sometimes a monolithic infrastructure will be the right idea and other times microservices will be the answer.

--

--

Aditi Chaudhry

I majored in Computer Engineering at UVA (Wahoowa!) and now work as a CyberSecurity Engineer! Follow me @aditichaudhry92