PAU OJ Online Judge
ProblemsLearnStudy plansContestsSubmissionsRank

Updates

Announcements and upcoming contests

Loading announcements…
Sign in for personal alertsBrowse contests
Log inSign up

PAU OJ

PrimeAsia University Online Judge

A real online judge for programming practice, university contests and coding assessments. Write code in your browser, get sandboxed verdicts, and track your progress.

Platform

  • Problems
  • Contests
  • Submissions
  • Ranking
  • Reviewers

Resources

  • User guide
  • Changelog
  • How judging works
  • System health
  • Create an account

© 2026 PrimeAsia University Online Judge. All rights reserved.

v0.9.0

  1. All tracks
  2. Master class
  3. Redundancy & Failover

Redundancy & Failover

রিডান্ডেন্সি ও ফেইলওভার

Topic 25 of 41Story · visual · design practice

In this lesson

  • Story & concept
    • কেন দরকার
    • মূল ধারণা
    • কোডে দেখি
    • ধাপে ধাপে
    • সাধারণ ভুল
      • ল্যাব: SPOF ম্যাপ
      • চিট শিট
      • প্রোডাকশন নোট
  • Visual story
  • Design practice
  • Checkpoint
  • Discussion
Back to track

0/0 solved

active-passive/active-active, quorum, health check আর graceful degradation।

In this lesson

  • Story & concept
  • Visual story
  • Design practice
  • Checkpoint
  • Discussion
01

Step 1: Story & concept

Start with the production incident, then the design decision that fixes it.

কেন দরকার

চলো-র প্রথম architecture-এ একটাই load balancer ছিল। রবিবার সন্ধ্যায় সেটার process OOM-এ মারা গেল—পেছনের ৬টা API সার্ভার সব সুস্থ, কিন্তু কোনো traffic পৌঁছাল না। ২৫ মিনিট outage। মাহিন বলল, "তোমার redundancy শুধু app tier-এ ছিল; entry door-টা single point of failure।"

Redundancy মানে প্রতিটা critical component-এর বিকল্প; failover মানে একটা মরলে traffic অন্যটায় যাওয়া। কিন্তু শুধু দুটো instance রাখলেই redundancy হয় না—health check, shared state, quorum, failover automation আর blast radius সব লাগে। দুটো instance একই rack/power/region-এ থাকলে সেটা redundancy নয়, মিথ্যানিরাপত্তা।

মূল ধারণা

Active-passive। একটাই traffic নেয়, অন্যটা standby; heartbeat fail হলে VIP/DNS switch। সহজ, কিন্তু standby idle cost; failover time।

Active-active। দুটোই traffic নেয়, LB ভাগ করে; capacity বেশি, কিন্তু shared state/consistency জটিল। Stateless app + replicated DB-তে ভালো।

Health check। শুধু process নয়, dependency (DB/Redis/queue) দেখে; deep vs shallow। Fail threshold/debounce; flap এড়াও।

Quorum। ৩/৫ node majority; split brain আটকায়। Stateful service-এ quorum ছাড়া active-active নয়।

Blast radius। Rack/AZ/region আলাদা করো; একই power/network switch/DB-তে দুটো replica রাখলে redundancy নেই। Cell-based architecture-ও ভাবো।

Graceful degradation। Recommendation service down হলে feed চলুক without it; payment down হলে queue/retry, read-only mode। প্রায়ই "সব বা কিছু না" এর চেয়ে আংশিক ভালো।

ধরণFailoverCostConsistency
Active-passiveswitchstandby idleসহজ
Active-activeautomaticcapacity efficientকঠিন
Quorumelection৩/৫ nodestrong-ish
Degradedfeature offকমআংশিক

কোডে দেখি

Health-check + failover-এর সরল pseudo:

def healthy(node):
    try:
        r = requests.get(f"http://{node}/health", timeout=1)
        return r.status_code == 200 and r.json().get("db") is True
    except Exception:
        return False

def pick():
    for node in sorted(nodes, key=lambda n: n.priority):
        if healthy(node):
            return node
    raise Unavailable("no healthy node")
# nginx active-passive upstream
upstream api {
  server 10.0.0.11:3000 max_fails=3 fail_timeout=10s;
  server 10.0.0.12:3000 backup;
}

backup শুধু primary ব্যর্থ হলে traffic পায়; health check dependency দেখলে ভুয়া 200 এড়ানো যায়।

ধাপে ধাপে

১. SPOF তালিকা করো। LB, DNS, DB primary, Redis, queue, object storage, auth—প্রতিটা কীভাবে fail করে?

২. Failure domain আলাদা করো। Rack/AZ/region; একই host-এ দুই replica নয়। Power/network independent।

৩. Health/failover। Deep health, threshold, debounce; active-passive switch test; DNS TTL কম।

৪. State/consistency। Stateless app, replicated DB, quorum; failover-এ split brain নয়।

৫. Degradation drill। Recommendation/payment/email বন্ধ করে দেখো app কী করে; read-only fallback।

সাধারণ ভুল

  • Duplicate instance-কে redundancy ভাবা। একই rack/power/DB-তে থাকলে একসাথে মরবে; failure domain আলাদা করো।
  • শুধু process health check। DB/Redis নিচে থাকলেও 200; deep health দরকার।
  • Failover rehearsal না করা। Automation প্রথমবার production-এ test নয়; মাসে একবার kill drill।
  • Active-active-তে conflict resolution না লেখা। Split brain-এ দুই দিকে write যাবে।
  • DNS failover-কে instant ভাবা। TTL/propagation মিনিট লাগে; LB/anycast ভাবো।
  • Degradation plan না থাকা। একটা service down-এ পুরো app বন্ধ না করে feature off করো।

ল্যাব: SPOF ম্যাপ

একটা request path আঁকো: DNS → LB → app → Redis → DB → queue। প্রতিটা component-এর পাশে লেখো: replica আছে? কোন AZ? failover automatic? একই rack? যে তিনটার উত্তর "না", সেগুলোই প্রথম কাজ।

চিট শিট

প্রোডাকশন নোট

Failover rehearsal না করলে automation বিশ্বাস করো না; মাসে একবার primary kill করে দেখো। DNS failover TTL/health propagation সময় ধরো। Active-active-তে conflict resolution লিখো; নাহলে split brain-এ data দুই দিকে যাবে।

02

Step 2: Visual story

See the mental model first — the animation and the steps below it say the same thing.

Concept visual

একটার মৃত্যুতে সিস্টেম থামে না

active-passive-এ standby অপেক্ষা করে, active-active-এ দুই দিকই কাজ নেয়—দুটোতেই প্রাণ health check।

tier 0

client
ক্লায়েন্ট

একই VIP

tier 1

LB active
edge

সব রিকোয়েস্ট

LB standby
edge

health fail হলে নেয়

tier 2

api AZ-a
সার্ভিস

active

api AZ-b
সার্ভিস

active

tier 3

Postgres
ডেটাবেস

primary আর standby

round robin · down বাদ
  1. 1single point খোঁজোLB, DB, DNS—তিন জায়গাতেই থাকে
  2. 2active-passive বসাওstandby সবসময় sync থাকে
  3. 3health check সত্যি হোক/health শুধু ২০০ নয়, DB আর cache-ও দেখে
  4. 4failover drill চালাওমাসে একবার primary মেরে দেখো
  5. 5blast radius ছোট রাখোএক AZ পড়লে সব না পড়ে
5টি ধাপে দেখা হচ্ছেগতি কমালে স্থির
03

Step 3: Design practice

Write a short design on paper or in a note, then compare it with the rubric. This is not a judge submission.

Design practice

Single load balancer

20 min

এক LB, ৬ API; LB OOM-এ ২৫ মিনিট outage।

তোমার কাজ

  1. 1SPOF map আঁকো।
  2. 2active-passive/active-active বাছো।
  3. 3failover drill লেখো।

ভালো উত্তরে কী থাকবে

  • SPOF চিহ্নিত
  • failure domain আলাদা
  • rehearsal plan
04

Step 4: Checkpoint

One timed attempt. Solve every problem to earn the module badge.

Final checkpoint

Ready to prove this module?

45 minutes3 problemsScale Architect badge
Go to checkpoint
05

Step 5: Discussion

Ask questions, share an approach or leave a study tip for this lesson.

Was this lesson helpful?

Your reaction helps other learners judge these notes.

Sign in to react

Discussion

0 comments

Sign in to ask a question or share an approach.

Sign in to comment

No comments yet

Be the first to ask a question or leave a study tip.

Topic 25 of 41

PreviousReal-time Updatesরিয়েল-টাইম আপডেটTopic 24 of 41
NextRate Limitingরেট লিমিটিংTopic 26 of 41
Back to track: System Design MasterclassAll learning tracks
প্রশ্নউত্তর
LB redundant?active-passive/managed
Health?deep + threshold
State?replicated/quorum
AZ?independent
Degrade?feature off