4.5.5 · HinglishSoftware Engineering

Software architecture — layered, MVC, event-driven, microservices, serverless

2,433 words11 min readRead in English

4.5.5 · Coding › Software Engineering


WHY architecture matter karti hai

Figure — Software architecture — layered, MVC, event-driven, microservices, serverless

1. Layered (n-tier) architecture

WHY yeh shape? Kyunki concerns alag-alag rates par change hote hain. UI baar-baar change hoti hai; database schema bahut kam. Inhe separate karke, ek UI redesign persistence code ko touch nahi karta.

HOW rule kaam karta hai: dependencies sirf neeche ki taraf point karti hain. Presentation, Service ke baare mein jaanti hai; Service, Data ke baare mein; Data, apne upar kisi ke baare mein nahi. Yeh "closed layers" hai — aap koi layer skip nahi kar sakte.


2. MVC (Model–View–Controller)


3. Event-driven architecture


4. Microservices

Monolith Microservices
Deploy unit ek kai
Database shared per-service
Failure all-or-nothing isolated
Complexity code mein network/ops mein

5. Serverless (FaaS + managed backends)


Sab kuch saath — Forecast-then-Verify


Recall

Recall Active recall — answers dhako
  • Kaunse do metrics ko SAARI architecture optimize karne ki koshish karti hai? ::: low coupling, high cohesion.
  • Layered mein, dependencies kis direction mein point kar sakti hain? ::: sirf neeche ki taraf.
  • MVC mein, kaun sa component business rules hold karta hai? ::: Model.
  • Event-driven connections ko kya bana deta hai? ::: broker ke zariye .
  • Microservice boundaries kis ke around draw ki jaati hain? ::: business capabilities ke, har ek ka apna database hota hai.
  • Serverless idle cost approximately kitna hota hai? ::: zero (pay per invocation).
Recall Feynman: 12-saal ke bacche ko samjhao

LEGO se build karna imagine karo. Layered ek cake hai — har floor neeche wale par baithti hai aur sirf apne neighbour se baat karta hai. MVC ek puppet show hai: puppet (Model) asli cheez hai, stage (View) use dikhata hai, puppeteer (Controller) audience ke reactions par react karta hai. Event-driven ek school bell hai: yeh bajti hai, aur jo bhi care karta hai (lunch lady, teacher) react karta hai — bell nahi jaanti kaun sun raha hai. Microservices ek badi kitchen ki jagah kai chhote food stalls hain — har ek ek dish banata hai aur apne aap khul/band ho sakta hai. Serverless ek kitchen ko minute ke hisaab se rent karna hai: aap sirf tab khaana banate ho jab order aata hai, sirf un minutes ke liye pay karte ho, aur koi aur clean up karta hai.


Flashcards

Software architecture fundamentally kya decide karti hai?
Boundaries kahan jaayenge — kaun se modules kaun par depend kar sakte hain — system ko changeable, testable, scalable rakhne ke liye.
Coupling aur cohesion define karo aur har ek ka goal batao.
Coupling = inter-module dependence (low chahiye); cohesion = intra-module relatedness (high chahiye).
Layered architecture mein dependency rule kya hai?
Har layer sirf apne seedhe neeche wali layer ko call karti hai; dependencies sirf neeche point karti hain.
Ek layered app aksar scale karna mushkil kyun hota hai?
Yeh typically ek process (monolith) ke roop mein deploy hota hai; aap poora stack replicate karte ho, ek layer nahi.
MVC ke teen components aur unke kaam kya hain?
Model = data+rules, View = render karta hai, Controller = input handle karta hai aur orchestrate karta hai.
"Fat controller" anti-pattern kya hai aur iska fix kya hai?
Business logic controller mein daalna; fix hai controllers ko thin rakhna aur logic Model/Service mein daalna.
Event-driven architecture connection complexity kaise reduce karta hai?
O(n·m) direct links se O(n+m) ho jaata hai broker ke through route karke; producers/consumers ek doosre ko nahi jaante.
Event-driven architecture kaun si mushkil problem introduce karta hai?
Temporal coupling: eventual consistency, ordering, duplicates, mushkil distributed debugging.
Microservice boundaries kis ke around draw ki jaani chahiye?
Business capabilities ke, har ek apna database own karta hai — technical layers ke nahi.
Microservices ke monolith se compare karte waqt do costs batao.
Network latency + distributed transactions, aur kai services deploy/monitor karne ka operational cost.
Microservices se pehle recommended starting point kya hai?
Ek modular monolith; ek service tab hi split karo jab ek boundary ko truly independent scaling/deployment chahiye ho.
Serverless (FaaS) kya automate karta hai aur iska billing kaise hota hai?
Functions ko demand par zero se auto-scale karta hai; per invocation × duration (GB-seconds) bill hota hai.
Serverless ki teen real limits batao.
Cold-start latency, execution time caps / statelessness, aur vendor lock-in.
Serverless cost reserved server se kab better hoti hai?
Bursty/low-volume workloads ke liye jahan idle cost (≈0) dominant ho; steady high volume ke liye reserved servers better hain.

Connections

  • Coupling and Cohesion
  • Monolith vs Microservices
  • Message Queues and Brokers
  • Eventual Consistency
  • Conway's Law
  • Design Patterns — MVC, Observer
  • Scalability — Horizontal vs Vertical
  • Cloud Computing — IaaS PaaS FaaS

Concept Map

goal

lowers

raises

cost

style

style

rule

usually deploys as

separates

separates

separates

updates

selects

Software Architecture

Boundaries between code

Coupling low

Cohesion high

Indirection overhead

Layered n-tier

MVC pattern

Dependencies point down only

Monolith one process

Model data + rules

View renders UI

Controller handles input