Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using the radixtree.new() method in a similar way has a performance difference of ten times #149

Open
dayongi opened this issue Aug 13, 2024 · 2 comments

Comments

@dayongi
Copy link

dayongi commented Aug 13, 2024

Environment

  • APISIX 3.9.1
  • CentOS Stream release 9

Description

I added a custom logic to the _M.match method in radixtree_host_uri.lua in APISIX to simulate how long it takes to build a radix tree with 1000 routes. At the same time, I used Python to call the Admin API of APISIX and added 1000 routes. When I executed curl -X GET http://localhost:9080/foo, I was surprised to find that with the same number of routes, when using a similar method to call radixtree.new to build a radixtree, the performance difference between the two was as much as ten times. Why is this?

  • Use python to call the Admin API of APISIX and added routes.
    image

  • Added custom logic of radixtree_host_uri.match()
    image

  • Test
    企业微信截图_0c63daae-f47d-45fc-9fb0-7e3eb138bf61
    企业微信截图_67025e58-4cc7-4161-9b33-0438af73d216

@haoyang1994
Copy link
Contributor

Could you modify the URIs in both scenarios to be identical and try again? When the URIs are the same, there will be conflicts in the router's hash table, and this involves a lot of element movement operations. I think this is the reason.

@dayongi
Copy link
Author

dayongi commented Aug 13, 2024

I think you're right

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants