Commit 009b57c2 authored by TousakaRin's avatar TousakaRin

Add doc for auto_concurrency_limiter

parent 6c220435
This diff is collapsed.
...@@ -587,8 +587,6 @@ QPS是一个秒级的指标,无法很好地控制瞬间的流量爆发。而 ...@@ -587,8 +587,6 @@ QPS是一个秒级的指标,无法很好地控制瞬间的流量爆发。而
设置ServerOptions.max_concurrency,默认值0代表不限制。访问内置服务不受此选项限制。 设置ServerOptions.max_concurrency,默认值0代表不限制。访问内置服务不受此选项限制。
Server.ResetMaxConcurrency()可在server启动后动态修改server级别的max_concurrency。
### 限制method级别并发度 ### 限制method级别并发度
server.MaxConcurrencyOf("...") = ...可设置method级别的max_concurrency。可能的设置方法有: server.MaxConcurrencyOf("...") = ...可设置method级别的max_concurrency。可能的设置方法有:
...@@ -605,6 +603,19 @@ server.MaxConcurrencyOf(&service, "Echo") = 10; ...@@ -605,6 +603,19 @@ server.MaxConcurrencyOf(&service, "Echo") = 10;
注意:没有service级别的max_concurrency。 注意:没有service级别的max_concurrency。
### 使用自适应限流算法
实际生产环境中,最大并发并不一定是一成不变的。这个时候可以在Server级别使用自适应限流算法,同时将Method级别设置为不限制并发(即默认值):
```c++
brpc::Server server;
brpc::ServerOptions options;
options.max_concurrency = "auto"; // auto concurrency limiter
```
使用自适应限流的算法需要保证:
1. 客户端开启了重试
2. 服务端有多个节点,当一个节点返回过载时,客户端可以向其他节点发起重试
更多细节可以看[这里]()
## pthread模式 ## pthread模式
用户代码(客户端的done,服务器端的CallMethod)默认在栈为1MB的bthread中运行。但有些用户代码无法在bthread中运行,比如: 用户代码(客户端的done,服务器端的CallMethod)默认在栈为1MB的bthread中运行。但有些用户代码无法在bthread中运行,比如:
......
...@@ -588,8 +588,6 @@ PeakQPS and AverageLatency are queries-per-second and latencies measured in a se ...@@ -588,8 +588,6 @@ PeakQPS and AverageLatency are queries-per-second and latencies measured in a se
Set ServerOptions.max_concurrency. Default value is 0 which means not limited. Accesses to builtin services are not limited by this option. Set ServerOptions.max_concurrency. Default value is 0 which means not limited. Accesses to builtin services are not limited by this option.
Call Server.ResetMaxConcurrency() to modify max_concurrency of the server after starting.
### Limit method-level concurrency ### Limit method-level concurrency
server.MaxConcurrencyOf("...") = … sets max_concurrency of the method. Possible settings: server.MaxConcurrencyOf("...") = … sets max_concurrency of the method. Possible settings:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment