Manage shards

Updated at:
Copy as MD

Simple Log Service (SLS) uses shards to control read and write throughput for Logstores, Eventstores, and Metricstores. Split or merge shards to adjust the active shard count and total throughput — splitting can be automatic, but merging is manual only.

Key concepts

Shard range

Each shard covers a left-closed, right-open MD5 hash range: [BeginKey,EndKey). Ranges do not overlap and collectively span the entire MD5 space: [00000000000000000000000000000000,ffffffffffffffffffffffffffffffff). When you create a Logstore or Metricstore, SLS divides the MD5 range equally among the specified number of shards.

  • BeginKey: The start of the shard range. This value is inclusive.

  • EndKey: The end of the shard range. This value is exclusive.

For example, Logstore A has four shards with the following ranges:

Table 1. Example shard ranges

Shard ID

Range

Shard0

[00000000000000000000000000000000,40000000000000000000000000000000)

Shard1

[40000000000000000000000000000000,80000000000000000000000000000000)

Shard2

[80000000000000000000000000000000,c0000000000000000000000000000000)

Shard3

[c0000000000000000000000000000000,ffffffffffffffffffffffffffffffff)

Reading data requires specifying a shard ID. Writing data supports two modes:

  • Load balancing mode: Each data packet is randomly written to an available shard.

    Recommended when write traffic exceeds a single shard's capacity.

  • Hash key routing mode: You specify an MD5 key, and the data is written to the shard whose range contains the key.

    For example, based on the shard range example, if you write data with an MD5 key of 5F, the data is written to Shard1. If you use a key of 8C, the data is written to Shard2.

Shard read and write capacity

Each shard has specific read and write capacity limits. For more information, see Data reads and writes.

Plan shard count based on actual data traffic. Split shards when traffic exceeds capacity; merge shards when traffic is well below capacity to reduce active shard count and cost.

Important
  • If write API calls persistently return 403 or 500 errors, check traffic and status codes in Cloud Monitor to determine whether you need more shards.

  • If requests exceed a shard's capacity, SLS processes them on a best-effort basis without guaranteeing service quality.

Shard status

Shard status can be readwrite or readonly.

New shards start as readwrite. After a split or merge, original shards become readonly and new readwrite shards are created. Status does not affect read performance. readwrite shards guarantee write performance, while readonly shards do not accept new writes.

Split and merge

You can adjust active shard count in two ways:

  • A split divides one shard into two new readwrite shards placed after the original. Their combined MD5 range equals the original shard's range.

    Only readwrite shards can be split. After splitting, the original shard becomes readonly — you can still consume its data but cannot write new data to it.

  • A merge combines two adjacent shards into one new readwrite shard placed after them. Its MD5 range covers the combined range of the two originals.

    Select a readwrite shard that is not the last in the sequence. SLS automatically merges it with the adjacent shard to its right. Both original shards become readonly — you can still consume their data but cannot write new data.

Split shard

Plan shard count based on your data traffic. Each shard supports write throughput of 5 MB/s or 500 requests/s and read throughput of 10 MB/s or 100 requests/s. These are not hard limits — if exceeded, SLS handles requests on a best-effort basis. Split shards when throughput is insufficient.

Note

If write API calls persistently return 403 or 500 errors, check traffic and status codes in Cloud Monitor to determine whether you need more shards.

Console operations

  1. Log on to the Simple Log Service console.

  2. In the Projects section, click the one you want.

    image

  3. In the left-side navigation pane, choose imageLog Storage > Logstores. On the Logstores page, hover over the target logstore and choose Modify Logstore > Modify.

  4. On the Logstore Attributes page, click Modify.

  5. Select a shard to split and click Split.

    Important

    Only readwrite shards can be split.

    On the Shard Management page, find the readwrite shard to split, and click Split in the Actions column.

  6. In the dialog box that appears, select the number of new shards and click OK.

  7. Click Save.

View shards

Console operations

  1. Log on to the Simple Log Service console.

  2. In the Projects section, click the one you want.

    image

  3. In the left-side navigation pane, choose imageLog Storage > Logstores. On the Logstores page, hover over the target logstore and choose Modify Logstore > Modify.

  4. On the Logstore Attributes page, view the shard list for the logstore.

    This page displays the Total Shards (including the number of readwrite and readonly shards), and details for each shard, including its Id, Status, BeginKey/EndKey, and Creation Time.

Automatic shard splitting

SLS automatically splits a shard when all of the following conditions are met:

  • The Auto Split Shard switch is enabled.

  • The write traffic to the shard has exceeded its write capacity for more than five minutes.

  • The number of readwrite shards in the logstore is less than the configured Maximum Shards value.

Note

Shards created by a split within the last 15 minutes are not eligible for automatic splitting.

Enable automatic shard splitting and set the Maximum Shards value when you create or modify a Logstore.

  • Auto Split Shard

    For example, if you have four shards, SLS evaluates each shard independently. It splits any shard that meets the conditions, provided the total shard count does not exceed the configured maximum.

  • Maximum Shards

    The upper limit on total shards after automatic splitting. Maximum supported value: 256 readwrite shards.

Merge shards

When data traffic is well below shard capacity, merge shards to reduce active shard count and cost. A merge combines a shard with its right-adjacent shard. Merging is manual only.

Important

To merge shards, you must specify a shard that is in the readwrite status and is not the last readwrite shard in the sequence.

  1. In the left-side navigation pane, choose imageLog Storage > Logstores. On the Logstores page, hover over the target logstore and choose Modify Logstore > Modify.

  2. On the Logstore Attributes page, click Modify.

  3. Select a shard to merge and click Merge.

    The Shard Management page lists all shards with their details. The Actions column provides Split or Merge options for readwrite shards. No actions are available for readonly shards.

  4. Click Save.

    After the merge, the two original shards become readonly. A new readwrite shard is created with an MD5 range that covers the combined range of the original two.

Delete shard

Warning

Deleted shards cannot be restored. Proceed with caution.

  • Automatic deletion

    If you set a data retention period for the logstore, SLS automatically deletes shards and their data when the period expires.

  • Manual deletion

    If you enabled permanent storage, delete the entire Logstore to remove its shards and data. Stop billing/Delete logstore.

API reference

Actions

API

Split a shard

SplitShard

Merge shards

MergeShard

List shards

ListShards