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/09/01 03:25:30 UTC
[GitHub] [apisix] yongboy opened a new issue, #7834: bug: A large number of nodes nodes in service discovery issue higher CPU usage
yongboy opened a new issue, #7834:
URL: https://github.com/apache/apisix/issues/7834
### Current Behavior
When your high-traffic services lie on serivce discovery in Apisix such as `consul_kv` or other, with hundreds and thousands upstream nodes, maybe issue the higher CPU usage twice or more than using nginx online.
The Apisix is 2.3 our using, with the help of CPU flame graph above, you can find the `upstream_util.compare_upstream_node` function covers a lot CPU.
![image](https://user-images.githubusercontent.com/548385/187825141-da580a1d-e1f8-485b-ac1b-83d241600ad9.png)
When one request arrives, the route's upstream configed with service name, need to execute one comparison, as below.
```lua
if up_conf.service_name then
......
local dis = discovery[up_conf.discovery_type]
......
local new_nodes = dis.nodes(up_conf.service_name)
local same = upstream_util.compare_upstream_node(up_conf.nodes, new_nodes)
if not same then
......
end
end
```
Our radical way, saves one comparison computation:
First, import a version for `nodes()`:
```lua
function _M.nodes(service_name)
......
local obj = applications[service_name]
local resp_list = obj and obj.nodes
......
local resp_ver = obj.ver or 0
......
return resp_list, resp_ver
end
```
Second, compare the nodes version:
```lua
if up_conf.service_name then
......
local dis = discovery[up_conf.discovery_type]
......
local new_nodes, nodes_ver = dis.nodes(up_conf.service_name)
local same = up_conf.nodes_ver == nodes_ver
if not same then
up_conf.nodes_ver = nodes_ver
......
end
end
```
After appling these changes, the Apisix's CPU uage is close to the nginx now.
### Expected Behavior
_No response_
### Error Logs
_No response_
### Steps to Reproduce
Run Apisix online
### Environment
- APISIX version 2.*
--
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] github-actions[bot] commented on issue #7834: performance: A large number of nodes in service discovery issue higher CPU usage
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on issue #7834:
URL: https://github.com/apache/apisix/issues/7834#issuecomment-1706322389
This issue has been marked as stale due to 350 days of inactivity. It will be closed in 2 weeks if no further activity occurs. If this issue is still relevant, please simply write any comment. Even if closed, you can still revive the issue at any time or discuss it on the dev@apisix.apache.org list. Thank you for your contributions.
--
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] github-actions[bot] closed issue #7834: performance: A large number of nodes in service discovery issue higher CPU usage
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed issue #7834: performance: A large number of nodes in service discovery issue higher CPU usage
URL: https://github.com/apache/apisix/issues/7834
--
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] github-actions[bot] commented on issue #7834: performance: A large number of nodes in service discovery issue higher CPU usage
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on issue #7834:
URL: https://github.com/apache/apisix/issues/7834#issuecomment-1727396661
This issue has been closed due to lack of activity. If you think that is incorrect, or the issue requires additional review, you can revive the issue at any time.
--
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