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

الاتساق الموزّع

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

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

نظرة عامة

الموضوعات

  • الاتساق القوي مقابل الاتساق النهائي
  • CAP وPACELC
  • مقايضات الاتساق

تعلّم أولًا

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

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

  1. Distinguish strong, eventual, causal, and read-your-writes consistency with examples.
  2. Explain CAP and PACELC accurately, including what they do not say.
  3. Choose a consistency level per use case and design the user experience for eventual consistency.

الدروس

  1. 01نماذج الاتساق
  2. 02CAP بشكل صحيح
  3. 03PACELC
  4. 04التصميم للاتساق النهائي
  5. 05عرض عملي: قراءة ما كتبته عبر الخدمات (read-your-writes)

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

Lab

MID-030-LAB1 · Consistency budget

Outcomes: 1–3 · Time: ~2 h List every Shop operation (browse catalog, search, add to cart, place order, pay, reserve stock, order history, admin price change, stock display). For each, specify the required consistency model, acceptable staleness, and how the UI behaves during lag (for example "order pending"). Get the table reviewed and apply it to the API: status fields, 202 responses, and read paths.

Acceptance: reviewed table applied to the API; each row maps to a concrete endpoint behavior.

Exercises (assessment: scenario quiz)

IDOutcomeTask
MID-030-EX011Give one Shop example each for strong, eventual, causal, and read-your-writes consistency.
MID-030-EX021A user changes their address and sees the old one on refresh. Name the missing guarantee and two ways to provide it.
MID-030-EX032A colleague says "Kafka is AP, so we have no consistency problems to design for." Correct the statement.
MID-030-EX042Explain PACELC in four sentences using sync vs async replication.
MID-030-EX053Choose the consistency level for: last-item stock reservation, product reviews count, payment status. Justify each.
MID-030-EX063Redesign "place order" so the UI is honest about asynchronous steps: statuses and endpoints.
أظهر الحلول
  • EX01 Strong: reserving the last unit. Eventual: view counters. Causal: a review reply after its review. Read-your-writes: my order list after checkout.
  • EX02 Read-your-writes. Return the updated resource in the write response; read from the primary right after a write; wait for a version.
  • EX03 AP/CP describes behavior during a partition for a specific operation and configuration; consumers still see lag, duplicates, and reordering, so consistency must be designed per use case.
  • EX04 During a partition choose availability or consistency. Otherwise choose latency or consistency. Sync replication waits for replicas: consistent, slower. Async replication returns early: faster, stale reads possible.
  • EX05 Stock: strong (one owner, transactional decrement). Review count: eventual. Payment status: strong at the payment service, shown to users as eventual with explicit states.
  • EX06 POST /orders returns 202 and Location; statuses PENDING, CONFIRMED, REJECTED; GET /orders/{id} shows status; UI polls or subscribes.

Outcome 2 is also covered by quiz Q04 to Q07; the lab covers outcome 3 at API level.

الاختبار

Outcomes: O1 consistency models · O2 CAP and PACELC · O3 choosing and designing.

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

  1. 1Every read sees the latest completed write. This is:O1
  2. 2A reply must never appear before its question. The needed model is:O1
  3. 3After you post a comment you cannot see it, but others can. Missing:O1
  4. 4CAP's trade-off applies:O2
  5. 5The "C" in CAP means:O2
  6. 6PACELC adds, for normal operation, a trade-off between:O2
  7. 7"Our whole system is AP" is:O2
  8. 8Best model for decrementing the last unit of stock:O3
  9. 9Best response for an order finishing asynchronously:O3
  10. 10Which hides eventual consistency badly?O3

الجزء العملي

Six exercises MID-030-EX01 to EX06 plus the consistency-budget lab. Pass: at least five exercises, 8 of 10 quiz answers, and a reviewed table applied to the API.

أخطاء شائعة

"we chose AP" as a system-wide statement; hiding eventual consistency from users.

التقييم

Scenario quiz.

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

Distributed data (SRB-003).

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