أنماط العمارة الموزّعة
في هذه الصفحة 9 موضوعات
نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.
نظرة عامة
الموضوعات
- CQRS
- التزويد بالأحداث (event sourcing)
- Sagas
- التنسيق (orchestration)
- العروض المادية (materialized views)
تعلّم أولًا
4.5 ساعة تدريب (تقدير)
مخرجات التعلم
- Apply full CQRS with separate write and read models, and say when CQRS-lite is enough.
- Explain event sourcing (event store, projections, snapshots, upcasting) and its operational costs.
- Build materialized views across service boundaries and manage their staleness.
- Choose between orchestration engines (e.g., Temporal, Camunda) and hand-built sagas.
الدروس
- 01الأنماط كمفاضلات وليست ترقيات
- 02CQRS بالتفصيل
- 03Event sourcing
- 04الإسقاطات (Projections) واللقطات (Snapshots) والترقية (Upcasting)
- 05العروض المادية عبر الخدمات
- 06محركات سير العمل مقابل Sagas المبنية يدويًا
- 07عرض عملي: نمذجة تتبع الشحنات مع Event sourcing وبدونه
- 08عرض عملي: إعادة بناء إسقاط معطوب من مخزن الأحداث
المختبر والتمارين
Lab
SRB-001-LAB1 · Shipment tracking design
Outcomes: 1, 2, 3, 4 · Time: ~4.5 h
- List FulfillCo's shipment tracking requirements (status, history, corrections, partner feed, audit).
- Design option A: event-sourced; option B: state plus outbox.
- Estimate replay time, schema evolution effort, and storage for each at expected volume.
- Write an ADR with the decision, rejected option, and revisit triggers.
Acceptance: operational costs (replay time, schema evolution, storage) estimated for both options; ADR records the decision.
Exercises
| ID | Outcome | Task |
|---|---|---|
| SRB-001-EX01 | 1 | Your read screens need a different shape but load is light. Choose CQRS-lite or full CQRS and justify. |
| SRB-001-EX02 | 2 | List three costs of event sourcing for shipment tracking that a state table would not have. |
| SRB-001-EX03 | 2 | A v1 event lacks a field the new projection needs. Describe the upcasting approach. |
| SRB-001-EX04 | 3 | Shop shows carrier status from FulfillCo. Define acceptable staleness and the reconciliation job. |
| SRB-001-EX05 | 4 | Three workflows exist, each two steps with no timers. Engine or hand-built saga? Argue. |
| SRB-001-EX06 | 1 | Review a proposal to event-source the product catalog. Write a five-line critique. |
أظهر الحلول
- EX01 CQRS-lite: SQL views or separate read classes on the same database; full CQRS adds a second store and lag for no needed gain.
- EX02 Replay time for rebuilds, permanent event schema and upcasting work, harder ad hoc queries and deletion of personal data.
- EX03 Add an upcaster mapping v1 to v2 with a default or derived value on read; do not rewrite history unless unavoidable.
- EX04 e.g. status within 30 s of the event, timestamp shown; a nightly job compares counts per status and repairs gaps by re-consuming.
- EX05 Hand-built with an outbox and state table: small, short, no timers; revisit if workflows grow.
- EX06 Catalog history is rarely business-critical, reads dominate, edits are simple; an audit history table suffices; propose a spike measuring need first.
Workplace evidence: a design where you chose a simpler pattern over a fashionable one and could show why.
الاختبار
Outcomes: O1 CQRS · O2 event sourcing · O3 materialized views · O4 orchestration choice.
اختبار ذاتي لك: لا توجد درجات، ولا يُحفظ أو يُرسل أي شيء. اختر إجابة ثم تحقق منها، ويمكنك المحاولة مرة أخرى كما تشاء.
الجزء العملي
Pattern-selection defense: present the ADR from SRB-001-LAB1 and defend it against challenges. Pass: 70% on the quiz and an ADR with costs estimated for both options.
أخطاء شائعة
Event sourcing everything; projections nobody can rebuild; workflow engines adopted for one saga.
التقييم
Pattern-selection defense.
دليل من بيئة العمل
A design where you chose a simpler pattern over a fashionable one and could show why.
الصلة بالمسار الوظيفي
Architecture at scale (SRA-001).