Traffic Split Configuration
The traffic-split plugin directs traffic to multiple upstream services based on conditions or weights, providing a flexible approach for API release strategies and traffic management. Configuration covers plugin parameters.
Parameters
See plugin common configurations for configuration options available to all plugins.
rules
An array of one or more pairs of matching conditions and actions to be executed.
match
Rules to match for conditional traffic split.
vars
An array of one or more matching conditions in the form of APISIX expressions to conditionally execute the plugin.
weighted_upstreams
List of upstream configurations.
upstream_id
ID of the configured upstream object.
weight
Relative share of traffic sent to this entry in
weighted_upstreams.upstream
Inline upstream configuration. APISIX 3.20.0 and later apply
tlsandkeepalive_poolin addition to the other fields listed below. Earlier APISIX releases and API7 Enterprise 3.9.23 and 3.10.10 ignore those two settings on inline traffic-split upstreams.To use health checks, retries, warm-up, service discovery, other upstream options, or the same upstream configuration across routes, create an upstream object and set
upstream_id.type
valid value:
roundrobin,chash,ewma, orleast_connLoad-balancing algorithm used to select a node within this inline upstream. Use
roundrobinfor weighted round robin,chashfor consistent hashing,ewmafor exponential weighted moving average, andleast_connfor least connections. The parentweightfield controls the traffic share assigned to this upstream.hash_on
valid value:
vars,header,cookie,consumer, orvars_combinationsUsed when
typeischash. Support hashing on built-in variables, header, cookie, consumer, or a combination of built-in variables.key
Used when
typeischash. Whenhash_onis set toheaderorcookie,keyis required. Whenhash_onis set toconsumer,keyis not required as the consumer name will be used as the key automatically.scheme
valid value:
API7 Gateway:httporhttps
APISIX:httporhttps; APISIX 3.19.0 and later also supportwsandwssProtocol used to communicate with the inline upstream. To use another protocol, create an upstream object and set
upstream_id.nodes
Addresses of the upstream nodes.
timeout
Timeout in seconds for connecting, sending and receiving messages.
pass_host
valid value:
pass,node, orrewriteMode deciding how the host name is passed.
passpasses the client's host name to the upstream.nodepasses the host configured in the node of the upstream.rewritepasses the value configured inupstream_host.upstream_host
Used when
pass_hostisrewrite. Host name of the upstream.name
Identifier for the upstream for specifying service name, usage scenarios, and so on.
tls
TLS settings for this inline upstream. Applied in APISIX 3.20.0 and later.
verify
Whether to verify the upstream certificate. If omitted, the upstream follows the NGINX verification setting.
ca_certs
valid value:
at least one PEM-encoded CA certificateCA certificates used to verify the upstream certificate. When verification is enabled and this field is omitted, verification uses the shared CA store. This field is not supported by
wsorwssupstreams, which use the shared trust store.client_cert
PEM-encoded client certificate presented to the upstream. Requires
client_key.client_key
PEM-encoded private key for
client_cert. Requiresclient_cert.client_cert_id
ID of a client SSL object. Do not configure this field together with
client_certandclient_key.
keepalive_pool
Connection pool settings for this inline upstream. Applied in APISIX 3.20.0 and later.
size
valid value:
greater than or equal to 1Maximum number of idle connections kept in the pool for each worker.
idle_timeout
valid value:
greater than or equal to 0Seconds an idle connection can remain in the pool.
requests
valid value:
greater than or equal to 1Maximum requests served through one connection before it is closed.