gpt4 book ai didi

nginx split_clients configuration does not split traffic to multiple upstreams(nginxsplit_clients配置不将流量拆分为多个上行流)

转载 作者:bug小助手 更新时间:2023-10-22 18:05:07 32 4
gpt4 key购买 nike



I want to test split traffic with nginx to 2 hosts (run as docker containers).

我想测试nginx到2个主机的分流流量(作为docker容器运行)。


I have the following nginx configuration:

我有以下nginx配置:


upstream exercim {
server host.docker.internal:8081;
}

upstream nutshell {
server host.docker.internal:8082;
}

split_clients "${remote_addr}" $backend {
50% exercim;
* nutshell;
}

server {
listen 80 default_server;
listen [::]:80;
server_name localhost;

#access_log /var/log/nginx/host.access.log main;

location /exercim/ {
proxy_pass http://$backend;
}

location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
}

$remote_addr contains an IP address.

$remote_addr包含一个IP地址。


Still the traffic is not split. Always th upstream exercim is used. Does anyone have an idea what could be the problem?

交通仍然没有分流。总是使用上行双工器。有人知道问题出在哪里吗?


更多回答

How are you testing it? How many remote addresses are you using?

你是如何测试的?你使用了多少个远程地址?

I'm testing with one client, making subsequent calls. I expected, that every other call should go to the second upstream (in average :D)

我正在用一个客户端进行测试,并进行后续调用。我预计,每隔一个呼叫都应该转到第二个上游(平均值:D)

That's not what split clients is trying to achieve. If you had 100 clients, you would expect half of them to go to each upstream. But each individual client would always use the same upstream, selected based on the hash of their IP address.

这不是拆分客户想要实现的。如果你有100个客户,你预计其中一半会流向上游。但每个单独的客户端总是使用相同的上游,根据其IP地址的哈希进行选择。

优秀答案推荐
更多回答

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com