Lesson 106 — Advanced

Reliability, Guardrails & Graceful Degradation

Model, provider, tool, retrieval — koi bhi ek pal mein fail ho sakta hai. Design ka kaam hai pehle se decide karna: timeout kahan, retry kis budget se, guardrail kis boundary par, aur system kitna chota hoke bhi useful rahe.

⏱ 20 min• Advanced• Caching Architecture

Failure matrix — kya toot sakta hai

WHAT

Reliability ka matlab: individual AI components fail karein tab bhi system useful rahe. Guardrails boundaries par deterministic checks hain; graceful degradation ek ladder hai jo har failure par kya chalega batati hai.

WHEN

Design review, launch se pehle, aur incident ke baad — har component par poochho "ye fail hua toh kya hoga". Production mein failure option nahi, schedule hai.

WHERE

Gateway layer (timeouts, retries, limits), app layer (validations, degradation ladder), pipeline boundaries (guardrails), aur runbook (human escalation + owners).

Matrix exercise: Ek table banao: component × failure × behaviour × owner. Jo cell khali hai wahi tumhara pehla incident hai — design time par sasta, production mein mehnga.

Timeouts, retries, breakers, queues

def call_with_policy(fn, budget):
    for attempt in range(budget.retries):
        if breaker.open:                     # provider ko chance hi mat do
            return fallback(fn)
        try:
            return fn(timeout=budget.timeout)  # har call ka apna timeout
        except (Timeout, RateLimited) as e:
            sleep_backoff(attempt, retry_after=getattr(e, "retry_after", None))
    return fallback(fn)                       # budget khatam -> degrade
Budget math: Per-call timeout × retries total latency se chhota hona chahiye — warna user ke budget se zyada tumhara retry loop khayega. Retry budget ko latency budget ke andar hi rakho.

Guardrails — boundaries par, model pe nahi

Gate vs nudge: Prompt ke andar likha rule ek nudge hai (model kabhi kabhi maanta nahi); boundary ka check ek gate hai (fail hua toh aage nahi jaayega). Safety-critical cheezein hamesha gate.

Graceful degradation — ladder pehle se likho

level 0 : full answer (normal path)
level 1 : cached / precomputed answer (L9.5)
level 2 : chhota model, reduced scope
level 3 : reduced features (summary only, koi action nahi)
level 4 : human escalation (ticket + context)
level 5 : explicit "abhi complete nahi ho sakta" (fake confidence nahi)
Explicit > fake: Sabse last level mein "na kar paana" bhi ek valid answer hai. Confident galat jawab se saaf "available nahi" hamesha better hai.

Human approval aur service-level expectations

Quality thodi alag hai: Latency/availability binary hain, quality distribution hai — isliye sampled evals (L7) chalate raho. Sirf uptime dashboards se quality kabhi nahi dikhti.

Exercise

Question: Fail karte hue provider ko thodi der block karne wala pattern — do shabd, English?

Question: Irreversible action se pehle aadmi se approval — do shabd, English?

Question: Failure par system ka dheere-dheere chota hota jaana — do shabd, English?

Question: Deri badha kar dobara try karna — ek shabd, English?

Common mistakes

Desi example: Generator aur inverter — degradation ladder ka desi analogy

Bijli gayi: inverter on (level 1), phir chhote appliances (level 2), phir sirf phone (level 3), bijli aane tak manual (level 4). Ladder pehle se decide hoti hai — mobile bhi band toh kya karna hai wahi:

text
normal    -> full power
power cut -> inverter (cache)
load zyada-> chhote appliances (chhota model)
last      -> "bijli aane tak ruko" (explicit inability)
Interview angle — yahan se sawaal aate hain
  • Q: AI system ke kaunse kaunse failures design karte ho? (provider, rate limit, malformed output, tool, retrieval, model quality)
  • Q: Circuit breaker kaise kaam karta hai? (failure threshold → call stop → probe → recover — aur fallback kab)
  • Q: Guardrails kahan lagti hain? (input/output/action boundaries par deterministic checks — model instruction nahi)
  • Q: Degradation ladder kaise banaoge aur kya triggers hain? (cache → small model → reduced → human → explicit inability, pre-written triggers)
Lesson complete?

Failure plan ready. Agla lesson — AI Pipeline Orchestration: in saare components ko ek coherent flow mein jodna.

Popular courses: Data Science Course in Lucknow · AI Course in Lucknow · Python Course in Lucknow · Power BI Course · Data Analytics Course