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 2022/07/20 08:15:03 UTC
[GitHub] [apisix] jujiale opened a new issue, #7504: help request: how to open and close keepalive_pool only in one route
jujiale opened a new issue, #7504:
URL: https://github.com/apache/apisix/issues/7504
### Description
hello:
I use apisix-dashboard to config one route, it could config Keepalive Pool, such as:(the following config is in etcd)
`
{
"id": "414195977881125816",
"create_time": 1656409641,
"update_time": 1658299923,
"uri": "/get",
"name": "httpbin-test",
"methods": ["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS", "CONNECT", "TRACE"],
"upstream": {
"nodes": {
"httpbin.org:80": 1
},
"timeout": {
"connect": 6,
"send": 6,
"read": 6
},
"type": "roundrobin",
"scheme": "http",
"pass_host": "pass",
"keepalive_pool": {
"idle_timeout": 0,
"requests": 1000,
"size": 320
}
},
"status": 1
}
`
when I set idle_time is 0, according to [https://github.com/apache/apisix-dashboard/issues/2294](url), the keepalive should be closed, and when I set idle_time is 60s, I think it should open keep alive pool,but what I find is in following source code:
apisix/balancer.lua -> method:set_current_peer(server, ctx) [https://github.com/apache/apisix/blob/f5f402f4484dc09300860a1798e003410e1fb456/apisix/balancer.lua#L284](url)
`
function set_current_peer(server, ctx)
local up_conf = ctx.upstream_conf
local keepalive_pool = up_conf.keepalive_pool
if enable_keepalive then
if not keepalive_pool then
if not default_keepalive_pool then
`
I find whatever I set idle_time is 0 or 60s, the above **enable_keepalive** is also null, so keep_alive is closed, the **enable_keepalive** is set in front of balancer.lua
[https://github.com/apache/apisix/blob/f5f402f4484dc09300860a1798e003410e1fb456/apisix/balancer.lua#L20](url)
`
local balancer = require("ngx.balancer")
local enable_keepalive = balancer.enable_keepalive and is_http
`
so I want to know in what situation, the **enable_keepalive** cloud have value? because there is no way to config this property. and how can I close keep_alive in route, set idle_time is 0?
### Environment
- APISIX version (run `apisix version`): v2.11
- Operating system (run `uname -a`):linux 3.10.0-1160.36.2.el7.x86_64
- OpenResty / Nginx version (run `openresty -V` or `nginx -V`):openresty/1.19.9.1
- etcd version, if relevant (run `curl http://127.0.0.1:9090/v1/server_info`):
- APISIX Dashboard version, if relevant:
- Plugin runner version, for issues related to plugin runners:
- LuaRocks version, for installation issues (run `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.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] tzssangglass commented on issue #7504: help request: how to open and close keepalive_pool only in one route
Posted by GitBox <gi...@apache.org>.
tzssangglass commented on issue #7504:
URL: https://github.com/apache/apisix/issues/7504#issuecomment-1191310243
> I want to know we use apisix v2.12, if it running on apisix-base?
It's up to you to decide: https://github.com/apache/apisix/blob/master/docs/en/latest/FAQ.md#how-do-i-build-the-apisix-base-environment
--
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: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] jujiale commented on issue #7504: help request: how to open and close keepalive_pool only in one route
Posted by GitBox <gi...@apache.org>.
jujiale commented on issue #7504:
URL: https://github.com/apache/apisix/issues/7504#issuecomment-1191044175
> > because there is no way to config this property. and how can I close keep_alive in route, set idle_time is 0?
>
> just config upstream like:
>
> ```
> {
> "type":"roundrobin",
> "nodes":{
> "127.0.0.1:1980":1
> },
> "keepalive_pool":{
> "idle_timeout":0
> }
> }
> ```
>
> BTW, this feature requires APISIX to be running on apisix-base.
@tzssangglass
I want to know we use apisix v2.12, if it running on apisix-base?
--
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: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] jujiale commented on issue #7504: help request: how to open and close keepalive_pool only in one route
Posted by GitBox <gi...@apache.org>.
jujiale commented on issue #7504:
URL: https://github.com/apache/apisix/issues/7504#issuecomment-1190940928
> If you want to force APISIX to use short-connections, try to use `proxy-rewrite` plugin to set the `Connection` header to `Close`.
In other words, set idle_time is 0 cloud not close keep_alive?
--
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: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] tzssangglass commented on issue #7504: help request: how to open and close keepalive_pool only in one route
Posted by GitBox <gi...@apache.org>.
tzssangglass commented on issue #7504:
URL: https://github.com/apache/apisix/issues/7504#issuecomment-1191314839
> its mean that, this method that "closing keepalive pool" just can used from apisix admin api?
When you use a separate `keepalive_pool` for each upstream, yes. see: https://github.com/apache/apisix/blob/master/docs/en/latest/admin-api.md#request-body-parameters-3
--
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: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] jujiale closed issue #7504: help request: how to open and close keepalive_pool only in one route
Posted by GitBox <gi...@apache.org>.
jujiale closed issue #7504: help request: how to open and close keepalive_pool only in one route
URL: https://github.com/apache/apisix/issues/7504
--
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: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] tzssangglass commented on issue #7504: help request: how to open and close keepalive_pool only in one route
Posted by GitBox <gi...@apache.org>.
tzssangglass commented on issue #7504:
URL: https://github.com/apache/apisix/issues/7504#issuecomment-1191308413
> As you say above, "This is just test if enable_keepalive available:" but the real call "return balancer.enable_keepalive(idle_timeout, requests) " must need "if enable_keepalive then " return true that could arrive "return balancer.enable_keepalive(idle_timeout, requests) ", but I don't know how to make **enable_keepalive** is not null,also as I said above, whatever I set keepalive_pool in upstream conf, the "**enable_keepalive** " always is null, that means cloud not arrive in code "return balancer.enable_keepalive(idle_timeout, requests) "
Whether `enable_keepalive` is empty or not is not relevant to the `keepalive_pool` configuration. `enable_keepalive` is a function, null means you are not using apisix-base and cannot use this function.
--
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: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] tzssangglass commented on issue #7504: help request: how to open and close keepalive_pool only in one route
Posted by GitBox <gi...@apache.org>.
tzssangglass commented on issue #7504:
URL: https://github.com/apache/apisix/issues/7504#issuecomment-1191035197
`enable_keepalive` is a patch function of `ngx.balancer.lua` in `apisix-nginx-module`, see: https://github.com/api7/apisix-nginx-module/blob/main/patch/1.21.4/lua-resty-core-enable_keepalive.patch#L171-L208
This is just test if `enable_keepalive` available: https://github.com/apache/apisix/blob/6451dd6e9fc2e5161bd8d701cfa51016d73ccabe/apisix/balancer.lua#L284
Here is the real call: https://github.com/apache/apisix/blob/6451dd6e9fc2e5161bd8d701cfa51016d73ccabe/apisix/balancer.lua#L328
`idle_timeout` is from `keepalive_pool.idle_timeout`, and `keepalive_pool` is from `up_conf.keepalive_pool`, so `idle_timeout` is form upstream conf.
--
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: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] jujiale commented on issue #7504: help request: how to open and close keepalive_pool only in one route
Posted by GitBox <gi...@apache.org>.
jujiale commented on issue #7504:
URL: https://github.com/apache/apisix/issues/7504#issuecomment-1194928414
after use apisix-base instead of openresty,everything seems ok, resolved, thanks.
--
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: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] jujiale commented on issue #7504: help request: how to open and close keepalive_pool only in one route
Posted by GitBox <gi...@apache.org>.
jujiale commented on issue #7504:
URL: https://github.com/apache/apisix/issues/7504#issuecomment-1190953509
> I just checked the nginx source code and set it to `0` can also trigger the close.
@tokers
thank you. I also want to know as I subscribe above , in what situation, **enable_keepalive** has value, because whatever I set idle_time is 0 or not, **enable_keepalive** is always null
--
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: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] tokers commented on issue #7504: help request: how to open and close keepalive_pool only in one route
Posted by GitBox <gi...@apache.org>.
tokers commented on issue #7504:
URL: https://github.com/apache/apisix/issues/7504#issuecomment-1190947011
I just checked the nginx source code and set it to `0` can also trigger the close.
--
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: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] jacobslei commented on issue #7504: help request: how to open and close keepalive_pool only in one route
Posted by GitBox <gi...@apache.org>.
jacobslei commented on issue #7504:
URL: https://github.com/apache/apisix/issues/7504#issuecomment-1191120670
> > because there is no way to config this property. and how can I close keep_alive in route, set idle_time is 0?
>
> just config upstream like:
>
> ```
> {
> "type":"roundrobin",
> "nodes":{
> "127.0.0.1:1980":1
> },
> "keepalive_pool":{
> "idle_timeout":0
> }
> }
> ```
>
> BTW, this feature requires APISIX to be running on apisix-base.
its mean that, this method that "closing keepalive pool" just can used from apisix admin api?
--
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: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] jujiale commented on issue #7504: help request: how to open and close keepalive_pool only in one route
Posted by GitBox <gi...@apache.org>.
jujiale commented on issue #7504:
URL: https://github.com/apache/apisix/issues/7504#issuecomment-1191042621
> test if `enable_keepalive` available:
>
> [apisix/apisix/balancer.lua](https://github.com/apache/apisix/blob/6451dd6e9fc2e5161bd8d701cfa51016d73ccabe/apisix/balancer.lua#L284)
@tzssangglass thanks for your reply
As you say above, "This is just test if enable_keepalive available:" but the real call "return balancer.enable_keepalive(idle_timeout, requests) " must need "if enable_keepalive then " return true that could arrive "return balancer.enable_keepalive(idle_timeout, requests) ", but I don't know how to make **enable_keepalive** is not null,also as I said above, whatever I set keepalive_pool in upstream conf, the "**enable_keepalive** " always is null, that means cloud not arrive in code "return balancer.enable_keepalive(idle_timeout, requests) "
--
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: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] tzssangglass commented on issue #7504: help request: how to open and close keepalive_pool only in one route
Posted by GitBox <gi...@apache.org>.
tzssangglass commented on issue #7504:
URL: https://github.com/apache/apisix/issues/7504#issuecomment-1191039639
> because there is no way to config this property. and how can I close keep_alive in route, set idle_time is 0?
just config upstream like:
```
{
"type":"roundrobin",
"nodes":{
"127.0.0.1:1980":1
},
"keepalive_pool":{
"idle_timeout":0
}
}
```
BTW, this feature requires APISIX to be running on apisix-base.
--
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: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] tokers commented on issue #7504: help request: how to open and close keepalive_pool only in one route
Posted by GitBox <gi...@apache.org>.
tokers commented on issue #7504:
URL: https://github.com/apache/apisix/issues/7504#issuecomment-1190130955
If you want to force APISIX to use short-connections, try to use `proxy-rewrite` plugin to set the `Connection` header to `Close`.
--
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: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] jujiale commented on issue #7504: help request: how to open and close keepalive_pool only in one route
Posted by GitBox <gi...@apache.org>.
jujiale commented on issue #7504:
URL: https://github.com/apache/apisix/issues/7504#issuecomment-1192112309
> > I want to know we use apisix v2.12, if it running on apisix-base?
>
> It's up to you to decide: https://github.com/apache/apisix/blob/master/docs/en/latest/FAQ.md#how-do-i-build-the-apisix-base-environment
@tzssangglass
OK, I will have a look , thank you very much.
--
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: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org