Blockchain companies use sharding to partition databases and increase scalability, allowing them to process more transactions per second. Sharding is a key mechanism underneath the Ethereum Blockchain and one of its critical components. Indeed, sharding enables Blockchain protocols to overcome the Scalability Trilemma (as a Blockchain grows, it stays scalable, secure, and decentralized).
Understanding sharding
The Scalability Trilemma (Image Credit: vitalik.cal).
Blockchain is now used in everything from supply chain management to cross-border financial transactions.
While extremely versatile, one critical issue remains: scalability. This issue is already prevalent with cryptocurrencies such as Bitcoin and Ether where more computers joining a peer-to-peer network cause the entire system to degrade.
For fintech companies that must compete with rapid payment networks, a lack of scalability is a particular concern. How can Blockchain be a viable solution in this industry? How can scalability and throughput be increased to address latency concerns?
Developers think sharding is the answer. To increase transactional throughput, sharding describes the partitioning of computational and storage workload across a P2P network. This avoids a situation where a single node is responsible for processing the entire transactional load of a network.
Sharding can help Blockchain provide all three (scalability, security and decentralization).
How is the workload partitioned?
Sharding uses horizontal partitioning, a database architecture enabling businesses to scale their databases dynamically.
Each database table is separated into multiple tables by partitioning its rows. Data held in each partition is independent of other partitions and is unique, but the schema and columns of each partition remain the same.
Individual partitions are called logical shards, which are distributed across separate database nodes called physical shards. Each physical shard can hold multiple logical shards. Collectively, the shards comprise an entire logical dataset.
It’s important to note that database shards typify a shared-nothing architecture. Shards are autonomous in the sense that they do not share computing resources or the same data with other shards. However, shards can share information with other nodes if required. This maintains a decentralized ledger where all ledger entries can be viewed without every shard having to process and store all information.
Strengths and weaknesses of sharding
Strengths
- Sharding allows horizontal scaling, or the act of adding machines to a stack to spread out the load and improve processing times. This method of scaling is preferable to vertical scaling, which involves adding more CPU or RAM to an existing server. In theory, horizontal scaling allows the network to be scaled up indefinitely. On the other hand, vertical scaling is inevitably constrained by the capabilities of the server.
- Sharding also decreases query response times. Non-sharded database queries have to search through every row in the table to find the result. This process can become extremely slow in large, monolithic applications. Through horizontal partitioning, queries search fewer rows and results are returned more quickly.
Weaknesses
- Implementing a sharded database architecture is quite complex. Mistakes during implementation can lead to corrupted tables and loss of data. Even when implemented successfully, sharding can be disruptive to some teams. Instead of managing data from a single entry point, individuals must manage data across several locations.
- Sharded databases are almost impossible to return to an unsharded state. Backups of the database made before sharding won’t include any data written after partitioning. Returning to an unsharded architecture involves the combining of partitioned data with older backups or creating a single database from many partitioned databases. Both are expensive and time-consuming operations.
Key takeaways:
- Sharding is the process of increasing the scalability of blockchain networks.
- Sharding separates database tables into horizontal partitions called logical shards. These shards are autonomous and do not share resources or data. Collectively, they comprise an entire data set and can share uncommon information when required.
- Sharding enables computing power to be increased by adding more machines to a stack. Partitioning also increases query response times as fewer rows need to be searched. However, implementing a sharded database is complex and is difficult to reverse.
Related Blockchain Business Frameworks
Proof of Work vs. Proof of Stake
Blockchain Business Model Framework
Read Next: Proof-of-stake, Proof-of-work, Bitcoin, Ethereum, Blockchain.
Main Free Guides: