توسيع قواعد البيانات
في هذه الصفحة 9 موضوعات
نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.
نظرة عامة
الموضوعات
- نسخ القراءة (Read replicas)
- التجزئة (partitioning)
- التقسيم الأفقي (sharding)
- الأقسام الساخنة (hot partitions)
تعلّم أولًا
4.5 ساعة تدريب (تقدير)
مخرجات التعلم
- Scale reads with replicas while handling replication lag in application design.
- Choose between vertical scaling, partitioning, and sharding with evidence.
- Choose a shard key, predict hot partitions, and plan resharding.
- Evaluate managed distributed SQL options against operating sharded PostgreSQL.
الدروس
- 01سُلّم التوسع
- 02نسخ القراءة وتصميم يراعي التأخر (lag)
- 03العودة إلى التجزئة (Partitioning)
- 04التقسيم الأفقي (Sharding) ومفاتيح الشرائح
- 05الأقسام الساخنة
- 06إعادة التقسيم (Resharding)
- 07SQL الموزّع والخيارات المُدارة
- 08عرض عملي: اختيار مفتاح شريحة للطلبات
- 09عرض عملي: نسخ القراءة وخطأ القراءة القديمة الذي تسببه
المختبر والتمارين
Lab
SRC-007-LAB1 · Order data at 10×
Outcomes: 1–4 · Time: ~2.5 h
- Quantify the 10× need from SRC-004 (reads, writes, size) against the current single-primary limits.
- Walk the scaling ladder with evidence; decide among replicas, partitioning, sharding, or managed distributed SQL.
- If sharding, choose the key from real distribution data and quantify hot-partition risk.
- Write the ADR and a migration outline with resharding and rollback.
Acceptance: hot-partition risk quantified.
Exercises (shard-key scenarios plus ADR; six exercises)
| ID | Outcome | Task |
|---|---|---|
| SRC-007-EX01 | 1 | A "my orders" page shows missing orders after checkout when using replicas. Diagnose and design a lag-aware fix. |
| SRC-007-EX02 | 2 | Given measurements (CPU 85%, 90% reads, write rate 40% of limit), decide the next rung of the ladder and justify. |
| SRC-007-EX03 | 3 | Evaluate customer id, order id hash, and region as shard keys for the three main order queries. |
| SRC-007-EX04 | 3 | Top 1% of customers produce 30% of orders across 8 shards. Estimate hot-shard load and propose a mitigation. |
| SRC-007-EX05 | 3 | Outline a resharding plan from 4 to 8 servers. |
| SRC-007-EX06 | 4 | Compare 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.
اختبار ذاتي لك: لا توجد درجات، ولا يُحفظ أو يُرسل أي شيء. اختر إجابة ثم تحقق منها، ويمكنك المحاولة مرة أخرى كما تشاء.
الجزء العملي
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).