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

[gateway] Inefficient and Arbitrary selection of API in DefaultReactorHandlerResolver #1445

Closed
briankrug opened this issue Aug 23, 2018 · 3 comments

Comments

@briankrug
Copy link

commented Aug 23, 2018

When DefaultReactorHandlerResolver figures out which API to route a request to, it iterates through the context paths from it's hash map (so entries are ordered by a mod of the hash code) and finds the first one whose value starts with the request path. This is both inefficient (when a large number of APIs are defined) and arbitrary (if there is a context path that is the prefix of another, it is difficult to know which one will be chosen).

Expected Behavior

Instead, the longest context path that starts the request path should be chosen and it should do so efficiently.

Possible Solution

Using a sorted map or checking for exact match of the request path (removing the latest path segment each iteration until matched) are two different ways to implement this more efficiently.

Context

We anticipate our customers will have a growing number of APIs and we are concerned for the additional latency that might incur if the routing logic is not efficient.

Your Environment

  • Version used: 1.18.0
@brasseld

This comment has been minimized.

Copy link
Member

commented Aug 23, 2018

Hi @briankrug

You're absolutely right !

We do not consider to work on such performance for the reactor since we are looking to implement virtual-hosting per API.
See #503 (comment)

Implementing this new feature will be the good moment to work on such performance / benchmark.

I hope being able to work on virtual hosting for 1.20 (mid-october).

@brasseld

This comment has been minimized.

Copy link
Member

commented Oct 19, 2018

Looking into this issue while working on virtual-hosting for 1.21

@brasseld brasseld changed the title Inefficient and Arbitrary selection of API in DefaultReactorHandlerResolver [gateway] Inefficient and Arbitrary selection of API in DefaultReactorHandlerResolver Oct 19, 2018
@brasseld brasseld self-assigned this Aug 29, 2019
@brasseld brasseld added this to the APIM - 1.29.0 milestone Aug 29, 2019
@brasseld

This comment has been minimized.

Copy link
Member

commented Aug 29, 2019

Closed by #1594

@brasseld brasseld closed this Aug 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
API Management
Awaiting triage
2 participants
You can’t perform that action at this time.