-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Quarkus OIDC makes first request very slow #41452
Comments
/cc @pedroigor (oidc), @sberyozkin (oidc) |
Any chance you could get some profiling done? We have some guidance here: https://github.com/quarkusio/quarkus/blob/main/TROUBLESHOOTING.md . |
I do not have the time right now to do any profiling, maybe these CloudWatch logs give you some insights? |
My "main" question right now is (as a quick hack): How can i manually initialize the OIDC client so it is ready for my first request (via a healthcheck or something). |
So https://quarkus.io/guides/lifecycle#startup_annotation is what should be used to execute something at startup but I have no idea what you should initialize. Question for @michalvavrik or @sberyozkin . |
@wesleysalimansdvb Hi, Why do you think that disabling the discovery postpones pulling the keys until the 1st request's time ? It only skips a step which involves fetching the discovery metadata doc pointing to the JWKS, etc endpoint, but JWKS, by default, will be fetched immediately: https://github.com/quarkusio/quarkus/blob/main/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/OidcRecorder.java#L404 I wonder if As a side note, you may want to experiment with https://quarkus.io/version/main/guides/security-openid-connect-multitenancy#issuer-based-tenant-resolver, to avoid having to create a custom resolver above which parses the token itself... |
After enabling this property those exceptions are gone. Thanks for the sidenote, this is something we will definitely try out! |
@wesleysalimansdvb |
IMHO it is about your dev env's setup than anything else, a lot of users have the discovery disabled for endpoints, most of the OAuth2 social providers don't support it. Please prove it otherwise with the profiling if you'd like to have some progress on this issue |
Sure, give it a try please and let Michal and myself know how it goes |
@wesleysalimansdvb Can you temporarily register a test client application and share the details with me offline (at Zulip, or post them to sbiarozk at redhat dot com with CC to someone else in your team) ? I can try it from my laptop to check what is going on there. I'd be worried even about 2 secs if I ever saw it happening in such cases, but I did not see it... |
Hi @sberyozkin, I want to give you a headsup that @wesleysalimansdvb is out of office until next week. He will come back to you when he returns. |
Hi @bartm-dvb, thanks for the heads up, sure, lets continue next week or so and see what we can realistically do at the Quakus level |
Is there anything new regarding this issue? |
I understood further communication is happening through Zulip for now |
We have touched on it with @wesleysalimansdvb who spent more time on looking at the issue and could confirm about 4 secs are spent. However, what I said to @wesleysalimansdvb, that we can't fix anything with the images like the one attached to this issue. So, there are two things Quarkus OIDC does when the discovery is disabled but the JWK endpoint is configured directly:
The team assumes Quarkus OIDC spends this time on step 2. My bet is, given that you had to enable the blocking DNS to overcome a slow DNS resolution, it is spent on step 1, which is I believe is in fact confirmed by the stackstrace @wesleysalimansdvb pasted above, where, without this option, Quarkus times out after 3.16 secs and the actual time required to perform the networking op is higher. I'd like to encourage you to run I also suggested @wesleysalimansdvb to have a breakpoint set in IMHO this issue is not really a Quarkus issue and I'd not mind closing it. But I know this is an important one for you so let's keep discussing what can be done about it. Thanks |
FYI, I am trying out the quarkus-quickstarts to reproduce the issue. I'll be back with my findings later |
@sberyozkin So what seems to most time in step 2 (It process this key set) is initialising jose4j. Both in the profiling output and logs, it seems to take a lot of time. On my local machine it takes 64ms, in the logs @wesleysalimansdvb attached it takes 298ms. Is initialising jose4j something that could be moved to build time?
|
@sberyozkin could you please look at this thread? |
@wesleysalimansdvb @bartm-dvb Sure, we can try to do that. Even in the worst case though, |
@wesleysalimansdvb @bartm-dvb, in general the OIDC provider initialization must be runtime as the keys are fetched at runtime. But having some neutral Jose call which can be recorded can certainly be done. For example, Let me know if you'll be up to it |
Hi @sberyozkin, we will be proposing a PR any of these days :) |
Hi @wesleysalimansdvb, thanks very much, I just thought I'd create a quick one today, #42765, as I got a few minutes, I did not notice your comment today. I'm sure there will be more opportunities for OIDC PRs :-) Note I've marked #42765 to close this issue, I know it might not answer all your questions, but I feel we should rather focus on more specific issues related to possible first slow requests, if you notice them. Please create them as necessary going forward |
Hahah thanks @sberyozkin for your help & proposing a fix :) |
Hi @wesleysalimansdvb There is a Thanks to you and @bartm-dvb, cheers |
@sberyozkin With the 3.16-RC1 I am seeing a ~30% improvement in first request latency with the oidc quick-start, thanks for your work! |
Describe the bug
Hi,
We use Quarkus OIDC for multi tenancy. We do not use Keycloak, we use our own authentication system. Therefore we set
quarkus.oidc.discovery-enabled
to false, which results in our OIDC config not getting loaded on startup, but on the first request. This makes the first request that gets done to our container (512 vCPU, 1024 memory) very slow (around 4 seconds).Is there a way to make a healthcheck manually load the OIDC providers before the first request gets done to the container? Or could there be added a new configuration property to load the providers on startup (such as proposed in #34890)
We also have our own TenantResolverConfig, to get the tenant config based on the tenant:
Expected behavior
All the fields in our config for our OIDC tenants are "deterministic" as in, they could easily be loaded on startup. So initializing them on startup would be our expected behavior
Actual behavior
The OIDC config does not get loaded on startup, resulting in intializing all OIDC classes etc on the first request, which makes the first request very slow.
How to Reproduce?
No response
Output of
uname -a
orver
AWS ECS Fargate container
Output of
java -version
openjdk 21.0.1 2023-10-17 LTS OpenJDK Runtime Environment Corretto-21.0.1.12.1 (build 21.0.1+12-LTS) OpenJDK 64-Bit Server VM Corretto-21.0.1.12.1 (build 21.0.1+12-LTS, mixed mode, sharing)
Quarkus version or git rev
3.11.0
Build tool (ie. output of
mvnw --version
orgradlew --version
)docker
Additional information
No response
The text was updated successfully, but these errors were encountered: