انتقل إلى المحتوى
أمين أبوزيد
MID-033

المرونة (Resilience)

  • 8 درس
  • 3 ساعة تدريب (تقدير)
في هذه الصفحة 8 موضوعات

نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.

نظرة عامة

الموضوعات

  • المهلات
  • إعادة المحاولة مع التراجع التدريجي
  • قواطع الدارة (Circuit Breakers)
  • الحواجز (Bulkheads)

تعلّم أولًا

3 ساعة تدريب (تقدير)

مخرجات التعلم

  1. Set timeouts on every remote call from a latency budget.
  2. Retry with exponential backoff and jitter, only for idempotent, transient failures.
  3. Apply circuit breakers and bulkheads with Resilience4j.
  4. Design fallbacks and graceful degradation that are honest to the user.

الدروس

  1. 01كيف تتتالى الأعطال
  2. 02المهلات وميزانيات زمن الاستجابة
  3. 03إعادة المحاولة والتراجع التدريجي والعشوائية (Jitter)
  4. 04قواطع الدارة
  5. 05الحواجز (Bulkheads)
  6. 06البدائل الاحتياطية والتدهور المتدرّج
  7. 07عرض عملي: فشل متتالٍ ثم الإصلاح
  8. 08عرض عملي: عواصف إعادة المحاولة والعشوائية (Jitter)

المختبر والتمارين

Lab

MID-033-LAB1 · Resilient checkout

Outcomes: 1–4 · Time: ~3 h Protect orders calls to payments and inventory with explicit timeouts derived from a 1 s checkout budget, retries with exponential backoff and jitter (idempotent calls only), a circuit breaker, and a bulkhead (Resilience4j). Make product pages degrade when reviews is down. Use Toxiproxy to inject latency, errors, and outages.

Acceptance: Toxiproxy experiments show contained failures: product pages stay healthy while payments is slow, the breaker opens and recovers, and no non-idempotent request is retried.

Exercises (assessment: resilience design review)

IDOutcomeTask
MID-033-EX011Compute the latency budget for checkout (target 1 s) across inventory, payments, and own processing; state each timeout.
MID-033-EX022List which Shop calls are safe to retry and which are not; add idempotency keys where needed.
MID-033-EX032Compute backoff delays for 4 attempts with base 100 ms, factor 2, and describe where jitter goes.
MID-033-EX043Write the Resilience4j circuit-breaker configuration for payments and explain each value.
MID-033-EX053Choose bulkhead limits for payments, inventory, and reviews and justify them.
MID-033-EX064Specify fallbacks for reviews, recommendations, stock display, and payment: which degrade, which fail.
MID-033-EX071–4Review a given design (no timeouts, retry on POST, shared pool) and list five fixes by priority.
أظهر الحلول
  • EX01 Example: own work 150 ms, inventory 250 ms, payments 450 ms, margin 150 ms. Downstream timeouts below the caller's.
  • EX02 Safe: GET product, GET stock. Retry only with an idempotency key: POST /payments, reserve stock. Never blind-retry a plain POST.
  • EX03 Delays about 100, 200, 400 ms (for retries after attempts 1 to 3); apply jitter by multiplying each by a random factor (for example 0.5 to 1.5) or using "full jitter" (random from 0 to the delay).
  • EX04 Sliding window 20, failure rate 50%, slow-call threshold 500 ms, wait 10 s in open state, 3 permitted half-open calls; count timeouts and 5xx only.
  • EX05 Example: payments 20 concurrent, inventory 30, reviews 10 with zero wait; derive from expected concurrency (rate × latency) plus headroom.
  • EX06 Reviews and recommendations: empty with notice. Stock display: cached or "check at checkout". Payment: fail clearly or keep the order pending.
  • EX07 1 add timeouts; 2 remove blind POST retry or add idempotency key; 3 separate pools per dependency; 4 add breaker; 5 define honest fallbacks.

Outcome 4 is also covered by quiz Q09 and Q10.

الاختبار

Outcomes: O1 timeouts and budgets · O2 retries · O3 breakers and bulkheads · O4 fallbacks.

اختبار ذاتي لك: لا توجد درجات، ولا يُحفظ أو يُرسل أي شيء. اختر إجابة ثم تحقق منها، ويمكنك المحاولة مرة أخرى كما تشاء.

  1. 1A remote call without a timeout can:O1
  2. 2Downstream timeouts should be:O1
  3. 3A slow dependency harms unrelated endpoints mainly because:O1
  4. 4Retrying is appropriate for:O2
  5. 5Jitter is used to:O2
  6. 6Which is exponential backoff?O2
  7. 7An open circuit breaker:O3
  8. 8Circuit breakers should count as failures:O3
  9. 9A bulkhead limits:O3
  10. 10An honest fallback when reviews is down:O4

الجزء العملي

Seven exercises MID-033-EX01 to EX07, the resilience design review, and MID-033-LAB1. Pass: at least six exercises and Toxiproxy experiments showing contained failures with a breaker that opens and recovers.

أخطاء شائعة

Retries without timeouts; retrying non-idempotent POSTs; circuit breakers never tested.

التقييم

Resilience design review.

الصلة بالمسار الوظيفي

Failure-mode analysis (SRC-009) and high-availability design (SRB-005).

اكتب للبحث في المستويات والمراحل والوحدات والدروس.