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

توسيع قواعد البيانات

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

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

نظرة عامة

الموضوعات

  • نسخ القراءة (Read replicas)
  • التجزئة (partitioning)
  • التقسيم الأفقي (sharding)
  • الأقسام الساخنة (hot partitions)

تعلّم أولًا

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

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

  1. Scale reads with replicas while handling replication lag in application design.
  2. Choose between vertical scaling, partitioning, and sharding with evidence.
  3. Choose a shard key, predict hot partitions, and plan resharding.
  4. Evaluate managed distributed SQL options against operating sharded PostgreSQL.

الدروس

  1. 01سُلّم التوسع
  2. 02نسخ القراءة وتصميم يراعي التأخر (lag)
  3. 03العودة إلى التجزئة (Partitioning)
  4. 04التقسيم الأفقي (Sharding) ومفاتيح الشرائح
  5. 05الأقسام الساخنة
  6. 06إعادة التقسيم (Resharding)
  7. 07SQL الموزّع والخيارات المُدارة
  8. 08عرض عملي: اختيار مفتاح شريحة للطلبات
  9. 09عرض عملي: نسخ القراءة وخطأ القراءة القديمة الذي تسببه

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

Lab

SRC-007-LAB1 · Order data at 10×

Outcomes: 1–4 · Time: ~2.5 h

  1. Quantify the 10× need from SRC-004 (reads, writes, size) against the current single-primary limits.
  2. Walk the scaling ladder with evidence; decide among replicas, partitioning, sharding, or managed distributed SQL.
  3. If sharding, choose the key from real distribution data and quantify hot-partition risk.
  4. Write the ADR and a migration outline with resharding and rollback.

Acceptance: hot-partition risk quantified.

Exercises (shard-key scenarios plus ADR; six exercises)

IDOutcomeTask
SRC-007-EX011A "my orders" page shows missing orders after checkout when using replicas. Diagnose and design a lag-aware fix.
SRC-007-EX022Given measurements (CPU 85%, 90% reads, write rate 40% of limit), decide the next rung of the ladder and justify.
SRC-007-EX033Evaluate customer id, order id hash, and region as shard keys for the three main order queries.
SRC-007-EX043Top 1% of customers produce 30% of orders across 8 shards. Estimate hot-shard load and propose a mitigation.
SRC-007-EX053Outline a resharding plan from 4 to 8 servers.
SRC-007-EX064Compare managed distributed SQL with sharded PostgreSQL for the order database and name the proof-of-concept tests.
أظهر الحلول
  • EX01 Replica lag; route read-your-writes to the primary (or wait for LSN), monitor lag, fall back above a threshold, add a test.
  • EX02 Reads dominate, so read replicas plus caching; write headroom is fine; sharding is premature.
  • EX03 Customer id fits "my orders" and customer-scoped queries; order id hash spreads evenly but scatters customer queries; region is low cardinality. Choose customer id, with a lookup for order by id.
  • EX04 If the top 1% land in one shard that could mean 30% of load on a shard expected to take 12.5%, roughly 2.4x average; mitigate with salting, splitting large tenants, or extra capacity for that shard.
  • EX05 Use logical shards; create new servers, copy and replicate changes for moved logical shards, verify, cut over by updating the mapping, clean up; keep rollback until verified.
  • EX06 Test transaction latency, cross-shard joins, failover time, compatibility of queries and extensions, cost at 10x, migration effort; compare operating burden.

Workplace evidence: a database scaling change you designed or reviewed.

الاختبار

Outcomes: O1 replicas and lag · O2 scaling options with evidence · O3 shard keys, hot partitions, resharding · O4 managed distributed SQL.

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

  1. 1Read replicas primarily scale:O1
  2. 2Read-your-writes after replication requires:O1
  3. 3The right response to growing replica lag is:O1
  4. 4Reads are 90% of load and CPU is high with write headroom. The best next step:O2
  5. 5Partitioning within one server mainly helps:O2
  6. 6A good shard key:O3
  7. 7A time-based shard key causes:O3
  8. 8Resharding is easier when you use:O3
  9. 9A fair evaluation of distributed SQL uses:O4
  10. 10Hot-partition risk should be:O3

الجزء العملي

Six shard-key and scaling exercises SRC-007-EX01 to EX06 plus the lab ADR. Pass: quiz at least 8/10, at least five exercises correct, and an ADR with quantified hot-partition risk and a migration outline.

أخطاء شائعة

Sharding before exhausting simpler options; shard keys that break the most common query.

التقييم

Shard-key scenarios plus ADR.

دليل من بيئة العمل

A database scaling change you designed or reviewed.

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

Distributed data (SRB-003) and database architecture (ARC-016).

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