What is microservice?
· 2 min read
What is microservice?
Introduction
A microservice is an independently deployable software component that owns a specific business capability within a larger system. Unlike a traditional monolithic application, where all functionality is packaged and deployed together, a microservice architecture breaks the application into multiple services that can operate, evolve, and scale independently.
Each microservice is responsible for a clearly defined domain, maintains ownership of its own data, and communicates with other services through well-defined contracts such as HTTP APIs, gRPC, or messaging platforms like RabbitMQ.
Core Idea
The primary goal of microservices is to separate business concerns into independently manageable units. This enables organizations to develop, deploy, and scale different parts of their system without affecting the entire application.
Some of the key benefits include:
-
Efficient resource utilization
- Only the services experiencing high load need to be scaled.
- Resources are allocated based on demand rather than scaling the entire application.
-
Technology freedom
- Different services can use different technology stacks if appropriate.
- A team might build one service using C#, another using Java, and a machine-learning service using Python.
-
Independent deployments
- Changes to one service do not require redeploying the entire system.
- Teams can release features faster and more frequently.
-
Fault isolation
- A failure in one service does not necessarily bring down the entire application.
- Properly designed systems can continue operating in a degraded state while affected services recover.
-
Team autonomy
- Individual teams can own and maintain specific business domains.
- Development efforts become more parallel and less dependent on large coordinated releases.
Real Life Scenario
Imagine you have a banking application built in C#. The application handles customer accounts, transactions, statements, and payments through a single monolithic system.
Over time, the bank decides to introduce an advanced fraud detection capability. This new feature requires:
- Real-time analysis of transactions
- Machine learning models
- Frequent model updates
- High computational resources
- Specialized data scientists and engineers
Implementing all of this directly inside the existing banking application creates several challenges:
- The application becomes more complex.
- Every fraud detection update requires redeploying the entire banking system.
- The fraud detection logic may require libraries and tooling that differ from the rest of the application.
- Heavy fraud analysis workloads could affect transaction processing performance.
With a microservice architecture, the fraud detection capability can be extracted into its own service.
+-------------------+
| Banking Service |
+-------------------+
|
| TransactionCreated
v
+-------------------+
| Fraud Detection |
| Service |
+-------------------+
|
| FraudDetected
v
+-------------------+
| Notification |
| Service |
+-------------------+