> For the complete documentation index, see [llms.txt](https://www.0x1.academy/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.0x1.academy/gei-kai-fa-zhe-de-zhi-nan/public-chain/fen-pian.md).

# 分片

### 分片（Sharding）是一種將區塊鏈「切割」成多個小塊的擴容技術。每個小塊（分片）可以同時處理不同的交易，大幅提升整體吞吐量。

***

## 為什麼需要分片？

想像一家銀行只有一個櫃檯。不管多少客人，都要排同一隊。這就是傳統區塊鏈的困境——所有交易都要由所有節點依序處理。

分片就像是開設多個櫃檯。客人可以分流到不同櫃檯，效率大幅提升。

| 模式     | 類比   | 處理方式          |
| ------ | ---- | ------------- |
| 傳統區塊鏈  | 單一櫃檯 | 所有交易依序處理      |
| **分片** | 多個櫃檯 | 交易分配到不同分片並行處理 |

***

## 分片如何運作？

### 基本原理

1. **網路分割**：將節點分成多個群組（分片）
2. **狀態分割**：每個分片只負責部分資料
3. **並行處理**：多個分片同時處理各自的交易
4. **跨分片通訊**：分片之間透過特定協議同步

### 舉例

假設有 1000 筆交易，分成 10 個分片：

* 傳統方式：1000 筆依序處理
* 分片方式：每個分片處理 100 筆，同時進行

理論上，10 個分片可以帶來 10 倍的吞吐量提升。

***

## 分片的挑戰

### 1. 安全性

每個分片的節點較少，可能更容易被攻擊。

### 2. 跨分片交易

如果交易涉及多個分片，處理變得複雜。

### 3. 資料可用性

如何確保每個分片的資料都是可驗證的？

{% hint style="info" %}
**以太坊的分片計劃**

以太坊原本計劃實施分片，但後來策略改變，改為透過 Layer 2（Rollup）來擴容，並用「Danksharding」來優化資料可用性。
{% endhint %}

***

## 分片 vs 其他擴容方案

| 方案      | 原理      | 例子                |
| ------- | ------- | ----------------- |
| **分片**  | 並行處理    | Near、Harmony      |
| Layer 2 | 鏈下處理    | Optimism、Arbitrum |
| 側鏈      | 獨立鏈     | Polygon PoS       |
| 更大區塊    | 提高單區塊容量 | Bitcoin Cash      |

***

## 延伸閱讀

* [創世區塊](/gei-kai-fa-zhe-de-zhi-nan/public-chain/genesis-block.md) — 區塊鏈的起點
* [隔離見證](/gei-kai-fa-zhe-de-zhi-nan/public-chain/ge.md) — 比特幣的擴容方案
* [Layer 2 總覽](/jie-jue-qu-kuai-lian-de-xiao-neng-ping-jing/layer2.md) — 另一種擴容思路

***

#### 參考資料

* [Sharding - Ethereum](https://ethereum.org/en/developers/docs/scaling/#sharding)
* [Danksharding](https://ethereum.org/en/roadmap/danksharding/)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.0x1.academy/gei-kai-fa-zhe-de-zhi-nan/public-chain/fen-pian.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
