Scaling Databases (Sharding)

đź’ś DAY4 -> Scaling Databases (Sharding) đź’ś

As in my previous blogs, We talked about replication of databases. In this We will talk about Sharding.

👉 What is Sharding?

Sharding is simply dividing DB mutually exclusive, so data is divided.
In simple…


This content originally appeared on DEV Community and was authored by Tanisk Annpurna

đź’ś DAY4 -> Scaling Databases (Sharding) đź’ś

As in my previous blogs, We talked about replication of databases. In this We will talk about Sharding.

👉 What is Sharding?

  • Sharding is simply dividing DB mutually exclusive, so data is divided.

  • In simple word, you divide data in smaller chunks called as shards because as data becomes huge the performance also decreases, but having smaller data does not impact performance that much.

*Real life example : *

  • Let's say we have a huge list of names stored on db.
  • Now we can divide db into 3 shards like shard1 will store names starting 'A' to 'J', shard2 -> 'K' to 'T' and shard3 -> 'U' to 'Z'.
  • When request comes to store new names in db, we can simply check first character and point it to proper shard for storing data.
  • When GET request comes, then also we will be able to decide which shard would hold data.

API to shards

-> Remember Image shown above as different shards is not different database but its a single database which has 3 nodes.

SQL vs NO-SQL

  • Both dbs has inbuilt sharding features.
  • SQL follows ACID properties but NO-SQL doesn't. So if there is any update that have to be run on multiple shards, SQL will either perform operations on all shards or none shards at all. but NO-SQL can give intermediate results.

BENEFITS

  • Improved Scalability: It allows Dbs to handle more capacity in much better way.
  • Increased Performance: Any operation that works on only one shard, will achieve result much faster as data is less, so performance is more.
  • Fault Tolerance: If one fails, the others can continue to serve the requests. So, not complete outbreak.
  • Reduced Costs: Vertical Scaling is costly thus sharding allows horizontal scaling.

Why is sharding not used by default

  • The reason for this is very simple, Its very costly as well as time consuming for 2 shards to communicate with each other even though they belong to same DB. So it becomes absolute important to select such data on which sharding is done, so that there is none to minimum communication requirement between shards.


This content originally appeared on DEV Community and was authored by Tanisk Annpurna


Print Share Comment Cite Upload Translate Updates
APA

Tanisk Annpurna | Sciencx (2024-06-24T12:11:01+00:00) Scaling Databases (Sharding). Retrieved from https://www.scien.cx/2024/06/24/scaling-databases-sharding/

MLA
" » Scaling Databases (Sharding)." Tanisk Annpurna | Sciencx - Monday June 24, 2024, https://www.scien.cx/2024/06/24/scaling-databases-sharding/
HARVARD
Tanisk Annpurna | Sciencx Monday June 24, 2024 » Scaling Databases (Sharding)., viewed ,<https://www.scien.cx/2024/06/24/scaling-databases-sharding/>
VANCOUVER
Tanisk Annpurna | Sciencx - » Scaling Databases (Sharding). [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/06/24/scaling-databases-sharding/
CHICAGO
" » Scaling Databases (Sharding)." Tanisk Annpurna | Sciencx - Accessed . https://www.scien.cx/2024/06/24/scaling-databases-sharding/
IEEE
" » Scaling Databases (Sharding)." Tanisk Annpurna | Sciencx [Online]. Available: https://www.scien.cx/2024/06/24/scaling-databases-sharding/. [Accessed: ]
rf:citation
» Scaling Databases (Sharding) | Tanisk Annpurna | Sciencx | https://www.scien.cx/2024/06/24/scaling-databases-sharding/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.