You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by "jiangdongzi (via GitHub)" <gi...@apache.org> on 2024/12/02 12:01:10 UTC

[I] bug: Performance degradation (~7%) on unrelated routes when using CIDR in remote_addrs [apisix]

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: notifications-unsubscribe@apisix.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] bug: Performance degradation (~7%) on unrelated routes when using CIDR in remote_addrs [apisix]

Posted by "Baoyuantop (via GitHub)" <gi...@apache.org>.
Baoyuantop commented on issue #11803:
URL: https://github.com/apache/apisix/issues/11803#issuecomment-4043657249

   The core issue is that `remote_addrs` (especially CIDR) introduces additional condition matching costs, which can translate into a decrease in overall throughput under high-pressure scenarios. However, due to the lack of key environment and evidence of reproduction in the issue, it is impossible to determine whether "implementation defects cause an abnormal 7% regression" or "known architectural costs are amplified." The value 192.168.1.2:16 in `remote_addrs` does not conform to the schema; its actual effectiveness should be verified first.


-- 
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


Re: [I] bug: Performance degradation (~7%) on unrelated routes when using CIDR in remote_addrs [apisix]

Posted by "Baoyuantop (via GitHub)" <gi...@apache.org>.
Baoyuantop commented on issue #11803:
URL: https://github.com/apache/apisix/issues/11803#issuecomment-4043657915

   If there is still a problem, please open it again.


-- 
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


Re: [I] bug: Performance degradation (~7%) on unrelated routes when using CIDR in remote_addrs [apisix]

Posted by "Baoyuantop (via GitHub)" <gi...@apache.org>.
Baoyuantop closed issue #11803: bug: Performance degradation (~7%) on unrelated routes when using CIDR in remote_addrs
URL: https://github.com/apache/apisix/issues/11803


-- 
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