Skip to content

Commit 8d267e2

Browse files
committed
Sharding config
1 parent ef6a997 commit 8d267e2

File tree

8 files changed

+331
-288
lines changed

8 files changed

+331
-288
lines changed

doc/book/admin/vshard_admin.rst

Lines changed: 266 additions & 217 deletions
Large diffs are not rendered by default.

doc/code_snippets/snippets/sharding/instances.enabled/sharded_cluster/storage.lua

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
box.schema.create_space('bands', {
2-
format = {
3-
{ name = 'id', type = 'unsigned' },
4-
{ name = 'bucket_id', type = 'unsigned' },
5-
{ name = 'band_name', type = 'string' },
6-
{ name = 'year', type = 'unsigned' }
7-
},
8-
if_not_exists = true
9-
})
10-
box.space.bands:create_index('id', { parts = { 'id' }, if_not_exists = true })
11-
box.space.bands:create_index('bucket_id', { parts = { 'bucket_id' }, unique = false, if_not_exists = true })
1+
box.once('bands', function()
2+
box.schema.create_space('bands', {
3+
format = {
4+
{ name = 'id', type = 'unsigned' },
5+
{ name = 'bucket_id', type = 'unsigned' },
6+
{ name = 'band_name', type = 'string' },
7+
{ name = 'year', type = 'unsigned' }
8+
},
9+
if_not_exists = true
10+
})
11+
box.space.bands:create_index('id', { parts = { 'id' }, if_not_exists = true })
12+
box.space.bands:create_index('bucket_id', { parts = { 'bucket_id' }, unique = false, if_not_exists = true })
13+
end)
1214

1315
function insert_band(id, bucket_id, band_name, year)
1416
box.space.bands:insert({ id, bucket_id, band_name, year })

doc/how-to/vshard_quick.rst

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -217,34 +217,28 @@ The resulting ``config.yaml`` file should look as follows:
217217
Adding storage code
218218
~~~~~~~~~~~~~~~~~~~
219219

220-
1. Open the ``storage.lua`` file and create a space using the :ref:`box.schema.space.create() <box_schema-space_create>` function:
220+
1. Open the ``storage.lua`` file and define a space and indexes inside :ref:`box.once() <box-once>`:
221221

222222
.. literalinclude:: /code_snippets/snippets/sharding/instances.enabled/sharded_cluster/storage.lua
223223
:language: lua
224-
:start-at: box.schema.create_space
225-
:end-before: box.space.bands:create_index('id'
224+
:start-at: box.once
225+
:end-before: function insert_band
226226
:dedent:
227227

228-
Note that the created ``bands`` spaces includes the ``bucket_id`` field.
229-
This field represents a sharding key used to partition a dataset across different storage instances.
228+
* The :ref:`box.schema.create_space() <box_schema-space_create>` function is used to create a space.
229+
Note that the created ``bands`` spaces includes the ``bucket_id`` field.
230+
This field represents a sharding key used to partition a dataset across different storage instances.
231+
* :ref:`space_object:create_index() <box_space-create_index>` is used to create two indexes based on the ``id`` and ``bucket_id`` fields.
230232

231-
2. Create two indexes based on the ``id`` and ``bucket_id`` fields:
232-
233-
.. literalinclude:: /code_snippets/snippets/sharding/instances.enabled/sharded_cluster/storage.lua
234-
:language: lua
235-
:start-at: box.space.bands:create_index('id'
236-
:end-at: box.space.bands:create_index('bucket_id'
237-
:dedent:
238-
239-
3. Define the ``insert_band`` function that inserts a tuple into the created space:
233+
2. Define the ``insert_band`` function that inserts a tuple into the created space:
240234

241235
.. literalinclude:: /code_snippets/snippets/sharding/instances.enabled/sharded_cluster/storage.lua
242236
:language: lua
243237
:start-at: function insert_band
244238
:end-before: function get_band
245239
:dedent:
246240

247-
4. Define the ``get_band`` function that returns data without the ``bucket_id`` value:
241+
3. Define the ``get_band`` function that returns data without the ``bucket_id`` value:
248242

249243
.. literalinclude:: /code_snippets/snippets/sharding/instances.enabled/sharded_cluster/storage.lua
250244
:language: lua

doc/reference/configuration/configuration_reference.rst

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3039,11 +3039,13 @@ The ``sharding`` section defines configuration parameters related to :ref:`shard
30393039
- :ref:`sharding.rebalancer_disbalance_threshold <configuration_reference_sharding_rebalancer_disbalance_threshold>`
30403040
- :ref:`sharding.rebalancer_max_receiving <configuration_reference_sharding_rebalancer_max_receiving>`
30413041
- :ref:`sharding.rebalancer_max_sending <configuration_reference_sharding_rebalancer_max_sending>`
3042+
- :ref:`sharding.rebalancer_mode <configuration_reference_sharding_rebalancer_mode>`
30423043
- :ref:`sharding.roles <configuration_reference_sharding_roles>`
30433044
- :ref:`sharding.sched_move_quota <configuration_reference_sharding_sched_move_quota>`
30443045
- :ref:`sharding.sched_ref_quota <configuration_reference_sharding_sched_ref_quota>`
30453046
- :ref:`sharding.shard_index <configuration_reference_sharding_shard_index>`
30463047
- :ref:`sharding.sync_timeout <configuration_reference_sharding_sync_timeout>`
3048+
- :ref:`sharding.weight <configuration_reference_sharding_weight>`
30473049
- :ref:`sharding.zone <configuration_reference_sharding_zone>`
30483050

30493051

@@ -3053,14 +3055,7 @@ The ``sharding`` section defines configuration parameters related to :ref:`shard
30533055
.. confval:: sharding.bucket_count
30543056

30553057
The total number of buckets in a cluster.
3056-
3057-
``sharding.bucket_count`` should be several orders of magnitude larger than the potential number of cluster nodes, considering potential scaling out in the future.
3058-
3059-
If the estimated number of nodes in a cluster is M, then the data set should be divided into 100M or even 1000M buckets, depending on the planned scaling out.
3060-
This number is greater than the potential number of cluster nodes in the system being designed.
3061-
3062-
Keep in mind that too many buckets can cause a need to allocate more memory to store routing information.
3063-
On the other hand, an insufficient number of buckets can lead to decreased granularity when :ref:`rebalancing <vshard-rebalancing>`.
3058+
Learn more in :ref:`vshard-bucket-count`.
30643059

30653060
.. NOTE::
30663061

@@ -3079,22 +3074,6 @@ The ``sharding`` section defines configuration parameters related to :ref:`shard
30793074
| Default: 3000
30803075
| Environment variable: TT_SHARDING_BUCKET_COUNT
30813076
3082-
.. TODO: Remove - for internal use
3083-
.. _configuration_reference_sharding_connection_outdate_delay:
3084-
3085-
.. confval:: sharding.connection_outdate_delay
3086-
3087-
The delay (in seconds) to outdate old replica set and replica objects after reconfiguration.
3088-
3089-
.. NOTE::
3090-
3091-
This option should be defined at the :ref:`global level <configuration_scopes>`.
3092-
3093-
|
3094-
| Type: number
3095-
| Default: nil
3096-
| Environment variable: TT_SHARDING_CONNECTION_OUTDATE_DELAY
3097-
30983077

30993078
.. _configuration_reference_sharding_discovery_mode:
31003079

@@ -3211,25 +3190,27 @@ The ``sharding`` section defines configuration parameters related to :ref:`shard
32113190
| Maximum: 15
32123191
| Environment variable: TT_SHARDING_REBALANCER_MAX_SENDING
32133192
3214-
.. TODO: https://github.com/tarantool/doc/issues/3865
3215-
.. _configuration_reference_sharding_rebalancer_mode:
32163193

3217-
.. confval:: sharding.rebalancer_mode
3194+
.. _configuration_reference_sharding_rebalancer_mode:
32183195

3219-
[TODO] A rebalancer mode:
3196+
.. confval:: sharding.rebalancer_mode
32203197

3221-
* ``manual``
3222-
* ``auto``
3223-
* ``off``
3198+
**Since:** :doc:`3.1.0 </release/3.1.0>`.
32243199

3225-
.. NOTE::
3200+
Configure how a rebalancer is selected
32263201

3227-
This option should be defined at the :ref:`global level <configuration_scopes>`.
3202+
* ``auto`` (default): if there are no replica sets with the ``rebalancer`` sharding role (:ref:`sharding.roles <configuration_reference_sharding_roles>`), a replica set with the rebalancer is selected automatically among all replica sets.
3203+
* ``manual``: one of the replica sets should have the ``rebalancer`` sharding role. The rebalancer is in this replica set.
3204+
* ``off``: rebalancing is turned off regardless of whether a replica set with the ``rebalancer`` sharding role exists or not.
32283205

3229-
|
3230-
| Type: string
3231-
| Default: 'auto'
3232-
| Environment variable: TT_SHARDING_REBALANCER_MODE
3206+
.. NOTE::
3207+
3208+
This option should be defined at the :ref:`global level <configuration_scopes>`.
3209+
3210+
|
3211+
| Type: string
3212+
| Default: 'auto'
3213+
| Environment variable: TT_SHARDING_REBALANCER_MODE
32333214
32343215

32353216
.. _configuration_reference_sharding_roles:
@@ -3347,11 +3328,30 @@ The ``sharding`` section defines configuration parameters related to :ref:`shard
33473328
| Environment variable: TT_SHARDING_SYNC_TIMEOUT
33483329
33493330

3331+
.. _configuration_reference_sharding_weight:
3332+
3333+
.. confval:: sharding.weight
3334+
3335+
**Since:** :doc:`3.1.0 </release/3.1.0>`.
3336+
3337+
The relative amount of data that a replica set can store.
3338+
Learn more at :ref:`vshard-replica-set-weights`.
3339+
3340+
.. NOTE::
3341+
3342+
``sharding.weight`` can be specified at the :ref:`replica set level <configuration_scopes>`.
3343+
3344+
|
3345+
| Type: number
3346+
| Default: 1
3347+
| Environment variable: TT_SHARDING_WEIGHT
3348+
3349+
33503350
.. _configuration_reference_sharding_zone:
33513351

33523352
.. confval:: sharding.zone
33533353

3354-
A :ref:`zone <vshard-replica-weights>` that can be set for routers and replicas.
3354+
A zone that can be set for routers and replicas.
33553355
This allows sending read-only requests not only to a master instance but to any available replica that is the nearest to the router.
33563356

33573357
.. NOTE::

doc/reference/reference_lua/box_once.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
been executed before, nothing happens. If it has not been executed before,
1212
the function is invoked.
1313

14-
See an example of using ``box.once()`` while
15-
:ref:`bootstrapping a replica set <replication-bootstrap>`.
14+
See an example of using ``box.once()`` in :ref:`vshard-quick-start-storage-code`.
1615

1716
**Warning:** If an error occurs inside ``box.once()`` when initializing a
1817
database, you can re-execute the failed ``box.once()`` block without

doc/reference/reference_rock/vshard/vshard_ref.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Basic parameters
4343
.. confval:: weights
4444

4545
A field defining the configuration of relative weights for each zone pair in a
46-
replica set. See the :ref:`Replica weights <vshard-replica-weights>` section.
46+
replica set.
4747

4848
| Type: table
4949
| Default: false

locale/en/reference/reference_rock/vshard/vshard_ref.pot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ msgid "Dynamic: yes"
9696
msgstr ""
9797

9898
#: ../../doc/reference/reference_rock/vshard/vshard_ref.rst:39
99-
msgid "A field defining the configuration of relative weights for each zone pair in a replica set. See the :ref:`Replica weights <vshard-replica-weights>` section."
99+
msgid "A field defining the configuration of relative weights for each zone pair in a replica set."
100100
msgstr ""
101101

102102
#: ../../doc/reference/reference_rock/vshard/vshard_ref.rst:50

locale/ru/LC_MESSAGES/reference/reference_rock/vshard/vshard_ref.po

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,10 @@ msgstr "Динамический: да"
6363

6464
msgid ""
6565
"A field defining the configuration of relative weights for each zone pair in"
66-
" a replica set. See the :ref:`Replica weights <vshard-replica-weights>` "
67-
"section."
66+
" a replica set."
6867
msgstr ""
6968
"Поле, которое определяет конфигурацию относительного веса для каждой пары "
70-
"зон в наборе реплик. См. раздел :ref:`Вес реплики <vshard-replica-weights>`."
69+
"зон в наборе реплик."
7170

7271
msgid ""
7372
"Name or id of a TREE index over the :ref:`bucket id <vshard-vbuckets>`. "

0 commit comments

Comments
 (0)