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

Change the default HTTP router from radixtree_uri to radixtree_host_uri #8354

Closed
3 tasks
tokers opened this issue Nov 18, 2022 · 3 comments · Fixed by #9047
Closed
3 tasks

Change the default HTTP router from radixtree_uri to radixtree_host_uri #8354

tokers opened this issue Nov 18, 2022 · 3 comments · Fixed by #9047
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@tokers
Copy link
Contributor

tokers commented Nov 18, 2022

Description

Hi, community,

We talked about changing the default HTTP router from radixtree_uri to radixtree_host_uri in the [mailing list]
(https://lists.apache.org/thread/6kkrdk2bkxmccwho3lk5jz5lrsvbsxgt).

I'll show the content here again:

Let me just explain the differences between them. The radixtree_uri
router matches API requests with the existing route tree by URI path,
While the radixtree_host_uri matches the HTTP host and then matches
the URI path.

So when Apache APISIX uses radixtree_uri as the default HTTP router,
there is a confusing scenario (even we can say it's a bug): Let's say
we have two routes, the first one requires the host matches
*.example.com, and the URI path is /anything, And the second one needs
the host matches foo.example.com exactly, and the URI path is also
/anything. In such a case, if we send an API request, we may hit the
first route, which is counterintuitive.

We also have a lot of voices from the community that users have been
in trouble since they think Apache APISIX will consider the HTTP host
match by default. However, it's not the case. So I'm here to propose
changing the default HTTP router to radixtree_host_uri.

I know this is a broken change, so we may have to do this in 3.x
releases and may not back it port to the 2.15 LTS version.

By the way, the radixtree_uri may have better performance than
radixtree_host_uri, so if we really change the default HTTP router, we
also need to give users a hint that: if they want better performance
or you are making a stress test, you may change the HTTP router back
to the radixtree_uri.

I think to implement the change, we need to close the tasks below:

  • Coding for changing the default URI, making all the test cases passed
  • Write docs for claiming the broken change
  • Write docs for giving users a hint about the performance difference between radixtree_host_uri and radixtree_uri, give them some advice about the performance tuning
@tokers tokers added good first issue Good for newcomers enhancement New feature or request labels Nov 18, 2022
@XFarooqi
Copy link
Contributor

XFarooqi commented Dec 2, 2022

Hi @tokers
I am wokring on the issue.

As per the investigation, it is found that the possible changes will be in _M.http_init_worker()

Can you please guide me in testing stuff, as I am finding it difficult to understand the test cases?
Where do I have to update the doc for the changes?

@tokers
Copy link
Contributor Author

tokers commented Dec 2, 2022

Hi @tokers I am wokring on the issue.

As per the investigation, it is found that the possible changes will be in _M.http_init_worker()

Can you please guide me in testing stuff, as I am finding it difficult to understand the test cases? Where do I have to update the doc for the changes?

@XFarooqi Actually, just change the default value for the setting "http.router" in config-default.yaml, and run all the test cases, fix the failed ones.

@tokers
Copy link
Contributor Author

tokers commented Dec 2, 2022

As for the doc, write some hints in https://apisix.apache.org/docs/apisix/terminology/router/.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
2 participants