-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDBMS2_6.html
More file actions
80 lines (72 loc) · 6.35 KB
/
Copy pathDBMS2_6.html
File metadata and controls
80 lines (72 loc) · 6.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<article>
<h1>DBMS II: Page 6 - Data Scaling: Distributed Databases & Sharding</h1>
<section>
<h2>Scaling Beyond One Server</h2>
<p>A single database server, no matter how powerful, has a physical limit. It can only handle so many queries per second and store so many terabytes of data. For global platforms like Amazon or Google, a single server is impossible. They use <strong>Distributed Databases</strong>, where data is spread across multiple physical locations. This provides <strong>Fault Tolerance</strong> (if one server burns down, the app stays up) and <strong>Extreme Scalability</strong>. This page explores the three primary techniques for spreading data: Fragmentation, Replication, and the modern standard of Sharding.</p>
</section>
<section>
<h2>1. Fragmentation: Slicing the Tables</h2>
<p>Fragmentation is the process of breaking a single table into smaller "Fragments" and storing them on different servers.</p>
<ul>
<li><strong>Horizontal Fragmentation (Sharding):</strong> Slicing the table by <strong>Rows</strong>. (e.g., Users 1-1,000,000 on Server A, Users 1,000,001+ on Server B).</li>
<li><strong>Vertical Fragmentation:</strong> Slicing the table by <strong>Columns</strong>. (e.g., Public profiles on Server A, private billing info on a high-security Server B).</li>
</ul>
</section>
<section>
<h2>2. Replication: Copying the Data</h2>
<p>Replication is the process of storing the exact same data on multiple servers. This is mainly used for <strong>Availability</strong> and <strong>Read Performance</strong>.</p>
<ul>
<li><strong>Master-Slave Replication:</strong> All "Writes" (Updates) go to the Master server. The Master then "pushes" the changes to multiple Slaves. Read requests are spread across all the Slaves.</li>
<li><strong>Master-Master Replication:</strong> Every server can handle both reads and writes. This is more complex because you must handle "Conflicts" if two people update the same record on different servers simultaneously.</li>
</ul>
</section>
<section>
<h2>3. Sharding: The Modern Standard</h2>
<p>Sharding is a specific type of horizontal partitioning. You choose a <strong>Shard Key</strong> (like <code>user_id</code> or <code>country</code>). The database uses a mathematical formula (Hashing) on that key to decide which server a piece of data belongs to. This allows you to add 1,000 servers and spread the load perfectly across them.</p>
<div style="text-align: center; margin: 20px 0;">
<div style="display: inline-block; padding: 20px; border: 2px solid #ddd; background: #f9f9f9; border-radius: 8px;">
<img src="https://images.unsplash.com/photo-1633412802994-5c058f151b66?q=80&w=800&auto=format&fit=crop" alt="Abstract representation of distributed database sharding and server clusters">
</div>
</div>
</section>
<section>
<h2>Visual Learning: Video Tutorials</h2>
<p>Master the architecture of large-scale data with these three videos:</p>
<div style="display: flex; gap: 20px; flex-wrap: wrap; margin-top: 20px;">
<div style="flex: 1; min-width: 250px; background: #eee; padding: 15px; border-radius: 8px;">
<strong>1. Database Sharding Explained</strong><br>
<a href="https://www.youtube.com/watch?v=50vJ96K_xoc" target="_blank">Watch on YouTube →</a>
<p><small>The most clear guide to horizontal scaling.</small></p>
</div>
<div style="flex: 1; min-width: 250px; background: #eee; padding: 15px; border-radius: 8px;">
<strong>2. Replication in Distributed Systems</strong><br>
<a href="https://www.youtube.com/watch?v=ScUJx4adZ_Y" target="_blank">Watch on YouTube →</a>
<p><small>Learn how Master-Slave setups keep your app fast.</small></p>
</div>
<div style="flex: 1; min-width: 250px; background: #eee; padding: 15px; border-radius: 8px;">
<strong>3. Distributed Transaction Management</strong><br>
<a href="https://www.youtube.com/watch?v=f-Kov0XwY_8" target="_blank">Watch on YouTube →</a>
<p><small>How to maintain ACID properties across 100 servers.</small></p>
</div>
</div>
</section>
<section>
<h2>Real-World Relationship: The Encyclopedia and the Chain Restaurant</h2>
<p>Think of <strong>Sharding</strong> like a <strong>Set of Encyclopedias</strong>. You have 26 books (the Shards). If you want to find "Zebra," you don't look through 25 other books; you go straight to the "Z" book. This allows 26 people to look up words at the exact same time without fighting over one book. Think of <strong>Replication</strong> like a <strong>Chain Restaurant (McDonald's)</strong>. They have the exact same menu and ingredients (Data) at 30,000 locations. If the McDonald's in your town is closed for repairs (Server Failure), you can just go to the next town over and get the same burger. The "System" is always available because the data is replicated everywhere.</p>
</section>
<section>
<h2>References & Additional Learning</h2>
<ul>
<li><a href="https://en.wikipedia.org/wiki/Shard_(database_architecture)" target="_blank">Wikipedia: Database Sharding</a></li>
<li><a href="https://www.baeldung.com/cs/database-sharding" target="_blank">Baeldung: Guide to Database Sharding</a></li>
<li><a href="https://www.geeksforgeeks.org/distributed-database-system/" target="_blank">GeeksforGeeks: Distributed DBMS Overview</a></li>
<li><a href="https://pythontutorial.net/advanced-python/python-distributed-databases/" target="_blank">Python Tutorial: Connecting to Sharded Clusters</a></li>
</ul>
</section>
<footer style="margin-top: 40px; padding: 20px; background: #f8f9fa; border-top: 1px solid #dee2e6;">
<div style="display: flex; justify-content: space-between;">
<a href="#" data-file="DBMS2_5.html" style="text-decoration: none; color: #6c757d;">← Previous: NoSQL: Column & Graph</a>
<a href="#" data-file="DBMS2_7.html" style="font-weight: bold; text-decoration: none; color: #007bff;">Next: Query Optimization →</a>
</div>
</footer>
</article>