Knowledge / Computer Science and Engineering / Software architecture: monoliths and microservices

Software architecture: monoliths and microservices

Computer Science and Engineering (B.E./B.Tech) · Software engineering · free study notes for exams, placements and interviews

In short

Software architecture is the set of high-level structural decisions about a system - how it is split into parts, how those parts talk to each other, and which qualities (scalability, availability, maintainability) the split is meant to buy. A monolith deploys the whole application as one unit; microservices split it into many small, independently deployable services, each owning its data and communicating over the network. The choice governs everything downstream: deployment, database design, testing, team structure and failure behaviour. It is examined in Software Engineering and Distributed Systems papers (architectural styles, coupling and cohesion, quality attributes) and is almost guaranteed in system-design rounds at Indian employers - Flipkart, Swiggy, Zomato, Razorpay, PhonePe, Zerodha, Paytm, Ola, Infosys/TCS/Wipro digital units - because every large Indian consumer platform has lived through this migration.

Explained

What architecture is, and what it is judged by

The monolith

Microservices

Communication, data and distributed-data patterns

Choosing, and migrating

Indian context, compliance and practice

Key points

Formulas and examples

Availability of a synchronous chain: A_chain = A₁ × A₂ × … × Aₙ (Aᵢ = availability of service i, a fraction; multiply because every hop must be up)
Availability with R redundant instances (independent failures): A = 1 − (1 − Aᵢ)R
Downtime per year = (1 − A) × 8,760 h; per month = (1 − A) × 730 h
Latency of a synchronous chain: L_total = Σ Lᵢ + Σ (network RTT per hop); parallel fan-out: L = max(Lᵢ) + overhead
Little's Law: L = λ × W (L = concurrent requests in system, λ = arrival rate in req/s, W = mean response time in s)
Instances needed: N = ceil(λ × W / c) = ceil(λ / (c/W)), where c = concurrent requests one instance handles
Utilisation and queueing (M/M/1): ρ = λ/μ; W = 1/(μ − λ) (μ = service rate, req/s; valid only for ρ < 1)
Cost comparison: Cost = Σ (instances_i × size_i × rate per unit per hour × hours)

Example 1 - availability of a chain versus redundancy. A checkout request passes through gateway → order → payment → inventory, each 99.9% available (A = 0.999).

Example 2 - targeted scaling saves money. A monolith runs on 20 instances at ₹8/hour each. Profiling shows the search module consumes 70% of CPU, everything else 30%.

Example 3 - sizing with Little's Law. An order service must serve λ = 1,200 req/s with mean response time W = 150 ms; one instance handles c = 60 concurrent requests.

Example 4 - latency amplification. A mobile screen needs profile, orders, recommendations and offers. Each service takes 40 ms; network RTT is 10 ms per hop.

Example 5 - saga with compensation. Order ₹4,500: (1) Order service creates order PENDING; (2) Payment service debits ₹4,500; (3) Inventory service reserves stock - fails, out of stock.

DimensionMonolithMicroservices
Deployable units1N (one per service)
DatabaseUsually one shared schemaOne per service
TransactionsACID, single commitSaga + eventual consistency
Inter-module callIn-process, ~nanosecondsNetwork, ~0.5-50 ms
ScalingWhole applicationPer service
TechnologySingle stackPolyglot
Fault isolationPoor (one crash, all down)Good, if async and redundant
TestingEasy end-to-endUnit easy, integration hard (contract tests, Testcontainers)
DebuggingOne stack traceDistributed tracing needed
Team fit1 small teamMany autonomous teams
Infra and ops costLowHigh (gateway, broker, orchestration, per-service CI/CD)
Best forNew products, modest load, small teamsLarge skewed load, many teams, well-understood domain
AspectSOAMicroservices
GranularityCoarse, enterprise-wide servicesFine, business-capability sized
IntegrationESB with orchestration logicSmart endpoints, dumb pipes
DataOften shared enterprise databaseDatabase per service
ProtocolsSOAP/WSDL, XMLREST/JSON, gRPC, messaging
GovernanceCentralisedDecentralised per team

Where it is used

Interview questions

Common mistakes

Related topics

Open in the Knowledge reader →Find jobs →