jiangdongzi opened a new issue, #11803:
URL: https://github.com/apache/apisix/issues/11803

   ### Current Behavior
   
   I've noticed an unexpected performance issue in APISIX. When configuring a 
route with a CIDR notation in remote_addrs, it appears to cause performance 
degradation on completely unrelated routes.
   Here's the specific scenario:
   {
       "name": "demo_inner_dev",
       "status": 1,
       "create_time": 1666335277,
       "uris": ["/inner/demo/*"],
       "upstream_id": "978966929",
       "update_time": 1668767623,
       "hosts": ["api-dev-internal.micoworld.net"],
       "remote_addrs": ["192.168.1.2/16"],
       "id": "579299854"
   }
   
   Observed behavior:
   
   
   When this route is added with remote_addrs using CIDR notation 
(192.168.1.2/16), there's approximately 7% performance degradation on other 
routes (e.g., /Greeter/xxx)
   When changing remote_addrs to use a specific IP:port format 
(192.168.1.2:16), the performance impact disappears
   The affected routes are completely different paths that shouldn't intersect 
in the radix tree matching
   
   This behavior is unexpected because:
   
   APISIX uses radix tree for route matching
   Different URI paths (like /Greeter/xxx and /inner/demo/*) should be on 
different branches of the radix tree
   The performance impact shouldn't propagate to unrelated routes
   
   Why does a CIDR in remote_addrs affect the performance of unrelated routes?
   Is this an expected behavior or a potential issue in the route matching 
implementation?
   
   
   
   ### Expected Behavior
   
   _No response_
   
   ### Error Logs
   
   _No response_
   
   ### Steps to Reproduce
   
   Configure a route in etcd with:
   etcdctl put '/apisix/routes/579299854' 
'{"name":"demo_inner_dev","status":1,"create_time":1666335277,"uris":["/inner/demo/*"],"upstream_id":"978966929","update_time":1668767623,"hosts":["api-dev-internal.micoworld.net"],"remote_addrs":["192.168.1.2/16"],"id":"579299854"}'
   
   Set up a benchmark test for an unrelated route (e.g., /Greeter/xxx)
   Run performance test with the above configuration
   
   Record the performance metrics
   
   
   Modify the route by changing remote_addrs from 192.168.1.2/16 to 
192.168.1.2:16
   
   etcdctl put '/apisix/routes/579299854' 
'{"name":"demo_inner_dev","status":1,"create_time":1666335277,"uris":["/inner/demo/*"],"upstream_id":"978966929","update_time":1668767623,"hosts":["api-dev-internal.micoworld.net"],"remote_addrs":["192.168.1.2:16"],"id":"579299854"}'
   
   Run the same performance test again
   
   Observe approximately 7% performance improvement on the unrelated route
   
   
   
   Actual Result:
   
   With CIDR notation (192.168.1.2/16), unrelated routes show ~7% performance 
degradation
   The performance impact affects routes that don't match the configured URI 
pattern
   
   Expected Result:
   
   Route performance should not be affected by unrelated routes' CIDR 
configuration
   CIDR matching in remote_addrs should only impact the performance of requests 
matching that specific route
   
   
   ### Environment
   
   - APISIX version (run `apisix version`):3.11.0
   - Operating system (run `uname -a`):centos7
   - OpenResty / Nginx version (run `openresty -V` or `nginx -V`):
   - 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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to