request help: High cpu & network traffic triggered when batch processing router rules with large number of rules
Issue description
We use apisix-gw as the traffic entrance of the development environment in k8s. APISIX-gw runs in containers. At present, apisix has more than 7000 router rules. In the past two days, it was discovered that the CPU and network traffic of apisix-gw will become high when the rules are batched. We suspect that apisix reads etcd data and generates a lot of network traffic when reloading etcd data, which leads to a rise in CPU. We are not sure if it is a problem with the v2 protocol.
Is there any good way to solve this problem?

Environment
- apisix version (cmd:
apisix version): 1.5 - OS: apisix-gw pod in K8S
https://github.com/apache/apisix/blob/master/apisix/http/router/radixtree_uri.lua#L83
we can cache the radixtree object by lrucache, for example 5 seconds.
@souzens would like to submit a PR to fix this issue? if you need any help, please let us know
@souzens

800m -> 800 millicpu
@souzens need you to provide more information, eg: The number of routes inserted in batches and examples of routes.
many thx
@membphis The readdir (in terms of etcd v3, Range Request) is expensive and maybe we can limit the number of records in one call and roundtrip several times to reduce the bandwidth peak, just like pagination.
See https://github.com/etcd-io/etcd/issues/11001 and https://github.com/etcd-io/etcd/blob/master/api/etcdserverpb/rpc.proto#L426 for more details.
I will try to observe these overheads in my own development environment and do some benchmarks.
https://github.com/apache/apisix/blob/master/apisix/http/router/radixtree_uri.lua#L83
we can cache the
radixtreeobject by lrucache, for example 5 seconds.
ignore this message, not this problem
maybe we can limit the number of records in one call and roundtrip several times to reduce the bandwidth peak, just like pagination.
we need it, this is useful for us
maybe we can limit the number of records in one call and roundtrip several times to reduce the bandwidth peak, just like pagination.
we need it, this is useful for us
I have submitted it in https://github.com/apache/apisix/issues/2853. It was registered into my TODO list, or if someone is interested in it, feel free to pick it!
Maybe it's also a good idea to support range request for GET too, like kebernetes api @tokers @moonming