You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brpc.apache.org by GitBox <gi...@apache.org> on 2022/04/22 08:34:35 UTC

[GitHub] [incubator-brpc] blueszhangsh opened a new issue, #1747: 增加关于自适应限流的算法描述

blueszhangsh opened a new issue, #1747:
URL: https://github.com/apache/incubator-brpc/issues/1747

   ``` 
       int32_t total_succ_req = _total_succ_req.load(butil::memory_order_relaxed);
       double failed_punish = _sw.total_failed_us * FLAGS_auto_cl_fail_punish_ratio;
       int64_t avg_latency = 
           std::ceil((failed_punish + _sw.total_succ_us) / _sw.succ_count);
       double qps = 1000000.0 * total_succ_req / (sampling_time_us - _sw.start_time_us);
       UpdateMinLatency(avg_latency);
       UpdateQps(qps);
   
       int next_max_concurrency = 0;
       // Remeasure min_latency at regular intervals
       if (_remeasure_start_us <= sampling_time_us) {
           const double reduce_ratio = FLAGS_auto_cl_reduce_ratio_while_remeasure;
           _reset_latency_us = sampling_time_us + avg_latency * 2;
           next_max_concurrency = 
               std::ceil(_ema_max_qps * _min_latency_us / 1000000 * reduce_ratio);
       } else {
           const double change_step = FLAGS_auto_cl_change_rate_of_explore_ratio;
           const double max_explore_ratio = FLAGS_auto_cl_max_explore_ratio;
           const double min_explore_ratio = FLAGS_auto_cl_min_explore_ratio;
           const double correction_factor = FLAGS_auto_cl_latency_fluctuation_correction_factor;
           if (avg_latency <= _min_latency_us * (1.0 + min_explore_ratio * correction_factor) || 
               qps <= _ema_max_qps / (1.0 + min_explore_ratio)) {
               _explore_ratio  = std::min(max_explore_ratio, _explore_ratio + change_step); 
           } else {
               _explore_ratio = std::max(min_explore_ratio, _explore_ratio - change_step);
           }
           next_max_concurrency = 
               _min_latency_us * _ema_max_qps / 1000000 *  (1 + _explore_ratio);
       }
   ```
   这处的算法和文档中描述的```max_concurrency = max_qps * ((2+alpha) * min_latency - latency)```有所不同。可否详细解释一下master分支的这套算法呢?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


[GitHub] [incubator-brpc] blueszhangsh commented on issue #1747: 增加关于自适应限流的算法描述

Posted by GitBox <gi...@apache.org>.
blueszhangsh commented on issue #1747:
URL: https://github.com/apache/incubator-brpc/issues/1747#issuecomment-1109482234

   @TousakaRin @zyearn 谢谢各位。麻烦补充到文档里吧。便于大家的理解


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


[GitHub] [incubator-brpc] TousakaRin commented on issue #1747: 增加关于自适应限流的算法描述

Posted by GitBox <gi...@apache.org>.
TousakaRin commented on issue #1747:
URL: https://github.com/apache/incubator-brpc/issues/1747#issuecomment-1107791909

   这里是为了让最大并发的变化更平滑
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


[GitHub] [incubator-brpc] zyearn commented on issue #1747: 增加关于自适应限流的算法描述

Posted by GitBox <gi...@apache.org>.
zyearn commented on issue #1747:
URL: https://github.com/apache/incubator-brpc/issues/1747#issuecomment-1107898075

   @TousakaRin 我们可以把这点补充到文档里么?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


[GitHub] [incubator-brpc] TousakaRin closed issue #1747: 增加关于自适应限流的算法描述

Posted by GitBox <gi...@apache.org>.
TousakaRin closed issue #1747: 增加关于自适应限流的算法描述
URL: https://github.com/apache/incubator-brpc/issues/1747


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org