> For the complete documentation index, see [llms.txt](https://docshome.gitbook.io/nginx-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docshome.gitbook.io/nginx-docs/he-xin-gong-neng/stream/ngx_stream_split_clients_module.md).

# ngx\_stream\_split\_clients\_module

* [示例配置](/nginx-docs/he-xin-gong-neng/stream/ngx_stream_split_clients_module.md#example_configuration)
* [指令](/nginx-docs/he-xin-gong-neng/stream/ngx_stream_split_clients_module.md#directives)
  * [split\_clients](/nginx-docs/he-xin-gong-neng/stream/ngx_stream_split_clients_module.md#split_clients)

`ngx_stream_split_clients_module` 模块（1.11.3）创建适用于 A/B 测试的变量，也称为拆分测试。

## 示例配置 <a href="#example_configuration" id="example_configuration"></a>

```
stream {
    ...
    split_clients "${remote_addr}AAA" $upstream {
                  0.5%                feature_test1;
                  2.0%                feature_test2;
                  *                   production;
    }

    server {
        ...
        proxy_pass $upstream;
    }
}
```

## 指令 <a href="#directives" id="directives"></a>

### split\_clients

|       - | 说明                                            |
| ------: | --------------------------------------------- |
|  **语法** | **split\_clients** `string $variable { ... }` |
|  **默认** | ——                                            |
| **上下文** | stream                                        |

为 A/B 测试创建一个变量，例如：

```
split_clients "${remote_addr}AAA" $variant {
               0.5%               .one;
               2.0%               .two;
               *                  "";
}
```

使用 MurmurHash2 对原始字符串的值进行哈希处理。在给出的例子中，从 0 到 21474835 （0.5％）的哈希值对应于 `$variant` 变量的值 `.one`，从 21474836 到 107374180 （2％）的哈希值对应于值 `.two`，哈希值从 107374181 到 4294967295 对应于值 `""`（空字符串）。

## 原文档

<http://nginx.org/en/docs/stream/ngx_stream_split_clients_module.html>
