request-id
Create a route and enable the request-id plugin on the route:
The Snowflake algorithm is not enabled by default and needs to be configured in ‘conf/config.yaml’.
Configuration parameters
Name | Type | Requirement | Default | Valid | Description |
---|---|---|---|---|---|
enable | boolean | optional | false | When set it to true, enable the snowflake algorithm. | |
snowflake_epoc | integer | optional | 1609459200000 | Start timestamp (in milliseconds) | |
data_machine_bits | integer | optional | 12 | Maximum number of supported machines (processes) 1 << data_machine_bits | |
sequence_bits | integer | optional | 10 | Maximum number of generated ID per millisecond per node 1 << sequence_bits | |
data_machine_ttl | integer | optional | 30 | Valid time of registration of ‘data_machine’ in ‘etcd’ (unit: seconds) | |
data_machine_interval | integer | optional | 10 | Time between ‘data_machine’ renewal in ‘etcd’ (unit: seconds) |
snowflake_epoc
default start time is2021-01-01T00:00:00Z
, and it can support approximately to2090-09-0715:47:35Z
according to the default configuration- defaults to
10 bits
and each process generates up to1024
ID per millisecond.
example
- Snowflake original configuration
Remove the corresponding json configuration in the plugin configuration to disable the request-id
. APISIX plugins are hot-reloaded, therefore no need to restart APISIX.