# 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[​](#parameters "Direct link to Parameters")

See plugin [common configurations](https://docs.api7.ai/apisix/reference/plugin-common-configurations.md) for configuration options available to all plugins.

* rules

  array\[object]

  ***

  An array of one or more pairs of matching conditions and actions to be executed.

  * match

    array\[object]

    ***

    Rules to match for conditional traffic split.

    * vars

      array\[array]

      ***

      An array of one or more matching conditions in the form of [APISIX expressions](https://docs.api7.ai/apisix/reference/apisix-expressions.md) to conditionally execute the plugin.

  * weighted\_upstreams

    array\[object]

    ***

    List of upstream configurations.

    * upstream\_id

      string or integer

      ***

      ID of the configured upstream object.

    * weight

      integer

      default: `1`

      ***

      Relative share of traffic sent to this entry in `weighted_upstreams`.

    * upstream

      object

      ***

      Inline upstream configuration. APISIX 3.20.0 and later apply `tls` and `keepalive_pool` in 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](https://docs.api7.ai/apisix/reference/admin-api.md#tag/Upstream/paths/~1apisix~1admin~1upstreams/post), or the same upstream configuration across routes, create an upstream object and set `upstream_id`.

      * type

        string

        default: `roundrobin`

        valid value:

        `roundrobin`, `chash`, `ewma`, or `least_conn`

        ***

        Load-balancing algorithm used to select a node within this inline upstream. Use `roundrobin` for weighted round robin, `chash` for consistent hashing, `ewma` for exponential weighted moving average, and `least_conn` for least connections. The parent `weight` field controls the traffic share assigned to this upstream.

      * hash\_on

        string

        default: `vars`

        valid value:

        `vars`, `header`, `cookie`, `consumer`, or `vars_combinations`

        ***

        Used when `type` is `chash`. Support hashing on [built-in variables](https://docs.api7.ai/apisix/reference/built-in-variables.md), header, cookie, consumer, or a combination of [built-in variables](https://docs.api7.ai/apisix/reference/built-in-variables.md).

      * key

        string

        ***

        Used when `type` is `chash`. When `hash_on` is set to `header` or `cookie`, `key` is required. When `hash_on` is set to `consumer`, `key` is not required as the consumer name will be used as the key automatically.

      * scheme

        string

        default: `http`

        valid value:

        API7 Gateway: `http` or `https`

        <br />

        APISIX: `http` or `https`; APISIX 3.19.0 and later also support `ws` and `wss`

        ***

        Protocol used to communicate with the inline upstream. To use another protocol, create an upstream object and set `upstream_id`.

      * nodes

        object

        ***

        Addresses of the upstream nodes.

      * timeout

        object

        ***

        Timeout in seconds for connecting, sending and receiving messages.

      * pass\_host

        string

        default: `pass`

        valid value:

        `pass`, `node`, or `rewrite`

        ***

        Mode deciding how the host name is passed. `pass` passes the client's host name to the upstream. `node` passes the host configured in the node of the upstream. `rewrite` passes the value configured in `upstream_host`.

      * upstream\_host

        string

        ***

        Used when `pass_host` is `rewrite`. Host name of the upstream.

      * name

        string

        ***

        Identifier for the upstream for specifying service name, usage scenarios, and so on.

      * tls

        object

        ***

        TLS settings for this inline upstream. Applied in APISIX 3.20.0 and later.

        * verify

          boolean

          ***

          Whether to verify the upstream certificate. If omitted, the upstream follows the NGINX verification setting.

        * ca\_certs

          array\[string]

          valid value:

          at least one PEM-encoded CA certificate

          ***

          CA 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 `ws` or `wss` upstreams, which use the shared trust store.

        * client\_cert

          string

          ***

          PEM-encoded client certificate presented to the upstream. Requires `client_key`.

        * client\_key

          string

          ***

          PEM-encoded private key for `client_cert`. Requires `client_cert`.

        * client\_cert\_id

          string or integer

          ***

          ID of a client SSL object. Do not configure this field together with `client_cert` and `client_key`.

      * keepalive\_pool

        object

        ***

        Connection pool settings for this inline upstream. Applied in APISIX 3.20.0 and later.

        * size

          integer

          default: `320`

          valid value:

          greater than or equal to 1

          ***

          Maximum number of idle connections kept in the pool for each worker.

        * idle\_timeout

          number

          default: `60`

          valid value:

          greater than or equal to 0

          ***

          Seconds an idle connection can remain in the pool.

        * requests

          integer

          default: `1000`

          valid value:

          greater than or equal to 1

          ***

          Maximum requests served through one connection before it is closed.
