What are Microservices?



2042 views Designing μ-services



Everyone’s talking about Microservices, but what exactly are they? Are they just a set of functions hosted over a network or something more?

Microservices in simple terms are like the regular functions from our programming language but just a more extensive set of responsibilities and served via a network.

So, you may have a microservice that handles everything related to Payments, a service that handles Notifications, and a service that deals with analytics. We see each service having focussed responsibility.

Microservices are no silver bullet, and they would not magically solve all the problems you have. It has its own fair share of drawbacks.

Monolith

Almost all products start monolith where every feature is put into a single codebase which is deployed as one artifact across all the servers. For example, the code handling payments, notifications, and analytics are all part of the same codebase deployed within the same binary.

Monoliths are always simple to build, develop, test, and scale. Given their simplicity, they are the go-to option for anyone starting up. With a lean team working on monolith would ensure very quick feature delivery.

Disadvantages of Monolith

  • monolith is tightly coupled
  • the deployment artifact - binary/JAR is bulky
  • the tech stack is homogeneous
  • bug in one module affects other modules
  • scaling one module requires scaling everything
  • large monolithic codebase is intimidating and it slows down delivery

Monolith to Microservices

Migrating from monolith to microservices is a slow process and to start you would club a related set of functions and fork out a service out of it. The process would be repeated for other sets of functions, eventually breaking the entire monolith.

Characteristics of Microservices

  • microservices are autonomous
  • microservices are focused and specialized
  • microservices are built around a business usecase/need

Advantages of Microservices

  • agility: small independent teams can move much faster
  • scaling: you can precisely scale one service as per the load
  • freedom: you can pick the best-suited tech stack for the service
  • given the scope is focused, a microservice is simple to understand
  • microservices can be reused across the platform
  • if a service goes down, it is easy to isolate it using a circuit breaker

Anti-patterns

  • do not start with microservices; start with a monolith
  • do not make services too small; they should a larger responsibility
  • don’t reinvent the wheel, use existing tooling as much as possible

Arpit Bhayani

Arpit's Newsletter

CS newsletter for the curious engineers

❤️ by 17000+ readers

If you like what you read subscribe you can always subscribe to my newsletter and get the post delivered straight to your inbox. I write essays on various engineering topics and share it through my weekly newsletter.




Other essays that you might like


BFF - Backend for Frontend - Pattern in Microservices

2225 views 114 likes 2022-07-04

As your application evolves, supporting multiple types of clients like Desktop, Mobile apps, etc becomes tricky. The bac...

Best practices that make microservices integration easy

850 views 50 likes 2022-06-27

Running microservices in isolation does not make any sense. To get something done, multiple microservices need to talk t...

Things to remember while building Microservices

856 views 35 likes 2022-06-20

An engineer working on Microservices should not only just focus on engineering; there are so many other aspects to look ...

Why should we have a standard way of building Microservices?

631 views 27 likes 2022-06-17

We all love creating microservices, but what if every team creates its own microservice uniquely and uses its own conven...


Be a better engineer

A set of courses designed to make you a better engineer and excel at your career; no-fluff, pure engineering.


System Design Masterclass

A masterclass that helps you become great at designing scalable, fault-tolerant, and highly available systems.

Enrolled by 700+ learners

Details →

Designing Microservices

A free course to help you understand Microservices and their high-level patterns in depth.

Enrolled by 17+ learners

Details →

GitHub Outage Dissections

A free course to help you learn core engineering from outages that happened at GitHub.

Enrolled by 67+ learners

Details →

Hash Table Internals

A free course to help you learn core engineering from outages that happened at GitHub.

Enrolled by 25+ learners

Details →

BitTorrent Internals

A free course to help you understand the algorithms and strategies that power P2P networks and BitTorrent.

Enrolled by 42+ learners

Details →

Topics I talk about

Being a passionate engineer, I love to talk about a wide range of topics, but these are my personal favourites.




Arpit's Newsletter read by 17000+ engineers

🔥 Thrice a week, in your inbox, an essay about system design, distributed systems, microservices, programming languages internals, or a deep dive on some super-clever algorithm, or just a few tips on building highly scalable distributed systems.



  • v12.4.4
  • © Arpit Bhayani, 2022

Powered by this tech stack.