Categories
Software Architecture

๐—ช๐—ต๐—ฎ๐˜ ๐—ถ๐˜€ ๐—ฑ๐—ฎ๐˜๐—ฎ๐—ฏ๐—ฎ๐˜€๐—ฒ ๐˜€๐—ต๐—ฎ๐—ฟ๐—ฑ๐—ถ๐—ป๐—ด?

It is a technique used to scale a database by horizontally partitioning the data across multiple servers, or shards. The goal of sharding is to distribute the data and workload across multiple servers, so that each server can handle a smaller portion of the overall data and workload. This can help improve the performance and scalability of the database, as each server can process queries and updates more efficiently when it is working with a smaller amount of data.

๐—ช๐—ต๐—ฎ๐˜ ๐—ฎ๐—ฟ๐—ฒ ๐˜๐—ต๐—ฒ ๐—บ๐—ผ๐˜€๐˜ ๐—ฐ๐—ผ๐—บ๐—บ๐—ผ๐—ป ๐—บ๐—ฒ๐˜๐—ต๐—ผ๐—ฑ๐˜€ ๐—ณ๐—ผ๐—ฟ ๐—ถ๐—บ๐—ฝ๐—น๐—ฒ๐—บ๐—ฒ๐—ป๐˜๐—ถ๐—ป๐—ด ๐—ฑ๐—ฎ๐˜๐—ฎ๐—ฏ๐—ฎ๐˜€๐—ฒ ๐˜€๐—ต๐—ฎ๐—ฟ๐—ฑ๐—ถ๐—ป๐—ด?

๐—ฅ๐—ฎ๐—ป๐—ด๐—ฒ-๐—ฏ๐—ฎ๐˜€๐—ฒ๐—ฑ ๐˜€๐—ต๐—ฎ๐—ฟ๐—ฑ๐—ถ๐—ป๐—ด: In this approach, the data is partitioned based on a key value, such as a user ID or a timestamp, and the data is distributed across the shards based on the range of the key value. For example, all user IDs in the range of 1-1000 might be stored on one shard, while user IDs in the range of 1001-2000 might be stored on another shard.

๐—›๐—ฎ๐˜€๐—ต-๐—ฏ๐—ฎ๐˜€๐—ฒ๐—ฑ ๐˜€๐—ต๐—ฎ๐—ฟ๐—ฑ๐—ถ๐—ป๐—ด: In this approach, a hash function is used to distribute the data across the shards based on the key value. For example, all data with a user ID of 123 might be stored on one shard, while data with a user ID of 456 might be stored on another shard.

๐——๐—ถ๐—ฟ๐—ฒ๐—ฐ๐˜๐—ผ๐—ฟ๐˜†-๐—ฏ๐—ฎ๐˜€๐—ฒ๐—ฑ ๐˜€๐—ต๐—ฎ๐—ฟ๐—ฑ๐—ถ๐—ป๐—ด In this approach, a central directory is used to map the key values to the specific shard where the data is stored. The directory can be used to determine which shard a piece of data belongs to, and the data can be retrieved from the appropriate shard.

๐—–๐˜‚๐˜€๐˜๐—ผ๐—บ ๐˜€๐—ต๐—ฎ๐—ฟ๐—ฑ๐—ถ๐—ป๐—ด: In some cases, it may be necessary to implement a custom sharding strategy that is specific to the needs and requirements of the database and the applications that are using it. This can involve a combination of different sharding methods, or a completely unique approach.

Ref:
โœ… ๐—š๐—ฟ๐—ผ๐—ธ๐—ธ๐—ถ๐—ป๐—ด ๐˜๐—ต๐—ฒ ๐—ฆ๐˜†๐˜€๐˜๐—ฒ๐—บ ๐——๐—ฒ๐˜€๐—ถ๐—ด๐—ป ๐—œ๐—ป๐˜๐—ฒ๐—ฟ๐˜ƒ๐—ถ๐—ฒ๐˜„: https://lnkd.in/g4Wii9r7
โœ… ๐—š๐—ฟ๐—ผ๐—ธ๐—ธ๐—ถ๐—ป๐—ด ๐˜๐—ต๐—ฒ ๐—”๐—ฑ๐˜ƒ๐—ฎ๐—ป๐—ฐ๐—ฒ๐—ฑ ๐—ฆ๐˜†๐˜€๐˜๐—ฒ๐—บ ๐——๐—ฒ๐˜€๐—ถ๐—ด๐—ป ๐—œ๐—ป๐˜๐—ฒ๐—ฟ๐˜ƒ๐—ถ๐—ฒ๐˜„:ย  https://lnkd.in/dyCRtiec

#databaseย #shardingย #systemdesignย #faangย #interview

Leave a Reply Cancel reply