You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2021/06/07 03:15:15 UTC
[GitHub] [apisix] nanamikon opened a new issue #4382: request help: Will limit-req support nodelay and rate in minute
nanamikon opened a new issue #4382:
URL: https://github.com/apache/apisix/issues/4382
### Issue description
Will limit-req support nodelay and rate in minute?
If not, I find nodelay can be implemented by adding condition, but resty.limit.req only support rate in second, how can I implemnt rate in minute?
### Environment
Request help without environment information will be ignored or closed.
* apisix version (cmd: `apisix version`): 2.5
* OS (cmd: `uname -a`): ubuntu
* OpenResty / Nginx version (cmd: `nginx -V` or `openresty -V`):
* etcd version, if have (cmd: run `curl http://127.0.0.1:9090/v1/server_info` to get the info from server-info API):
* apisix-dashboard version, if have:
* luarocks version, if the issue is about installation (cmd: `luarocks --version`):
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] spacewander commented on issue #4382: request help: Will limit-req support nodelay and rate in minute
Posted by GitBox <gi...@apache.org>.
spacewander commented on issue #4382:
URL: https://github.com/apache/apisix/issues/4382#issuecomment-855555586
> I find nodelay can be implemented by adding condition
PR is welcome!
> how can I implemnt rate in minute
Divide the rate by 60 is already enough?
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] nanamikon commented on issue #4382: request help: Will limit-req support nodelay and rate in minute
Posted by GitBox <gi...@apache.org>.
nanamikon commented on issue #4382:
URL: https://github.com/apache/apisix/issues/4382#issuecomment-855622043
In my company, many users set 200 r/m on remote_address or even lower, If i divided by 60, 1r/s or 2r/s will be reached easily, because modern browser support http2, so one user visit one nignx over 1r/s is very common.
Now, we transfer this conf to apisix, some of them reach limit and delay request online。
I think we use nodelay in nginx conf while apisix only support delay cause this happen, maybe I can test it
```
The rate is specified in requests per second (r/s). If a rate of less than one request per second is desired, it is specified in request per minute (r/m). For example, half-request per second is 30r/m.
```
```
ctx->rate = rate * 1000 / scale;
```
Maybe multiply by 1000 is the key to solve the decimal point ?
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] nanamikon commented on issue #4382: request help: Will limit-req support nodelay and rate in minute
Posted by GitBox <gi...@apache.org>.
nanamikon commented on issue #4382:
URL: https://github.com/apache/apisix/issues/4382#issuecomment-855760216
Thanks for reply, after adding nodelay, we solve the online problem
> resty.limit.req does the same thing, see https://github.com/openresty/lua-resty-limit-traffic/blob/56b9a35a69117ed0e8a2e3b9a0866c426403e1b9/lib/resty/limit/req.lua#L144
So mayby rate should be float, but I think it is not the key point
>In this case we need a good burst and/or use delay.
I want to submit a pr to add nodelay function, a new param as follow
| Name | Type | Requirement | Default|
|--------|---------|-------------|---------|
|nodelay|boolean|optional|false|
Is it ok?
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] spacewander commented on issue #4382: request help: Will limit-req support nodelay and rate in minute
Posted by GitBox <gi...@apache.org>.
spacewander commented on issue #4382:
URL: https://github.com/apache/apisix/issues/4382#issuecomment-855668192
> In my company, many users set 200 r/m on remote_address or even lower, If it divided by 60, 1r/s or 2r/s will be reached easily,
It's how Nginx works too. Note that the r/m is the speed rate, it doesn't mean you can have 200 requests in a minute, it means you can't be faster than 200r/m. Drive a car in 36km/h is equal to 10m/s.
> because modern browser support http2, so one user visit one nignx over 1r/s is very common.
In this case we need a good burst and/or use delay.
> ctx->rate = rate * 1000 / scale;
`resty.limit.req` does the same thing, see https://github.com/openresty/lua-resty-limit-traffic/blob/56b9a35a69117ed0e8a2e3b9a0866c426403e1b9/lib/resty/limit/req.lua#L144
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] spacewander closed issue #4382: request help: Will limit-req support nodelay and rate in minute
Posted by GitBox <gi...@apache.org>.
spacewander closed issue #4382:
URL: https://github.com/apache/apisix/issues/4382
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] nanamikon edited a comment on issue #4382: request help: Will limit-req support nodelay and rate in minute
Posted by GitBox <gi...@apache.org>.
nanamikon edited a comment on issue #4382:
URL: https://github.com/apache/apisix/issues/4382#issuecomment-855622043
In my company, many users set 200 r/m on remote_address or even lower, If it divided by 60, 1r/s or 2r/s will be reached easily, because modern browser support http2, so one user visit one nignx over 1r/s is very common.
Now, we transfer this conf to apisix, some of them reach limit and delay request online。
I think we use nodelay in nginx conf while apisix only support delay cause this happen, because both of them reach the rate limit, but not over burst. I will test it
```
The rate is specified in requests per second (r/s). If a rate of less than one request per second is desired, it is specified in request per minute (r/m). For example, half-request per second is 30r/m.
```
```
ctx->rate = rate * 1000 / scale;
```
Maybe multiply by 1000 is the key to solve the decimal point ?
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] spacewander commented on issue #4382: request help: Will limit-req support nodelay and rate in minute
Posted by GitBox <gi...@apache.org>.
spacewander commented on issue #4382:
URL: https://github.com/apache/apisix/issues/4382#issuecomment-856357591
LGTM
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] spacewander edited a comment on issue #4382: request help: Will limit-req support nodelay and rate in minute
Posted by GitBox <gi...@apache.org>.
spacewander edited a comment on issue #4382:
URL: https://github.com/apache/apisix/issues/4382#issuecomment-855555586
> I find nodelay can be implemented by adding condition
PR is welcome!
> how can I implemnt rate in minute
Divide the rate by 60 is already enough? IMHO, there is no need to add a field. Since Nginx also does the same way: https://github.com/nginx/nginx/blob/5eadaf69e394c030056e4190d86dae0262f8617c/src/http/modules/ngx_http_limit_req_module.c#L913
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org