比如:
location / {
if(百分之一几率){
return 200 'lucky!';
}
return 200 '...';
}
这个“百分之一几率”的判断怎么写?
location / {
if(百分之一几率){
return 200 'lucky!';
}
return 200 '...';
}
这个“百分之一几率”的判断怎么写?
|
1
http://nginx.org/en/docs/http/ngx_http_split_clients_module.html
有找到 A/B 测试用的,但是这里的 Example 是根据 IP 地址来区分的。 |
|
2
给 nginx 安装一个 lua 扩展,然后用 Lua 写随机
|
|
3
$request_id 勉强算随机
|
|
annoy1309Jan 29, 2020
4
取几个种子(时间+ip+盐之类)多次(大于 5 ) sha256 以后,勉强可以算弱随机?
|
|
5
@optional
$request_id unique request identifier generated from 16 random bytes, in hexadecimal 是一个 16 进制随机 ID,如何用这个 ID 实现例如几分之一的随机呢?谢谢 |
|
6
@nikoo 最靠谱的还是上面说的来个扩展搞定问题,非要使用$request_id 不如从正则表达式下手, 比如 a 开头是 1/16,aa 开头是 1/256
|