8000 Implement load shedding by vmuzikar · Pull Request #24684 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

Implement load shedding - #24684

Merged
ahus1 merged 1 commit into
keycloak:mainfrom
vmuzikar:load-shedding
Nov 21, 2023
Merged

ahus1 merged 1 commit into
keycloak:mainfrom
vmuzikar:load-shedding

Conversation

@vmuzikar
@vmuzikar vmuzikar commented Nov 10, 2023 •
Copy link
Copy Markdown
Contributor

Closes #23340

Requires: #24639

With the recent fixes in Quarkus, we can rely with load shedding on their implementation with high enough confidence.

This PR also includes a small smoke test to at least check the option is mapped properly. It does not aim to perform full verification of this feature as it's implemented in Quarkus.

@vmuzikar
vmuzikar force-pushed the load-shedding branch 2 times, most recently from 9f3d2e9 to 2f25f61 Compare November 10, 2023 16:06
@ahus1
ahus1 self-requested a review November 13, 2023 09:09
@ahus1 ahus1 left a comment
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @vmuzikar for this change. The parameter is still called http-max-concurrent-requests while it sets the quarkus.thread-pool.queue-size which is different: The original PR assumed that concurrent was by using a sempaphore "running plus queued", while the new implementation set the only the "queued". So I'd argue "concurrent" is misleading here.

So I suggest to rename this to http-max-queued-requests. We would also like to change the thread pool size as well, so we might need another parameter like http-max-running-requests. While this could be added in another PR, we should be at least sure about its name to avoid renaming the first one.

@vmuzikar
Copy link
Copy Markdown
Contributor Author

@ahus1 Thanks for the review!

Renamed http-max-concurrent-requests to http-max-queued-requests, updated the docs as well.

We would also like to change the thread pool size as well, so we might need another parameter like http-max-running-requests. While this could be added in another PR, we should be at least sure about its name to avoid renaming the first one.

I'd rather address this in a separate PR. If I understand correctly, the thread pool is adjusted automatically based on number of CPUs available. Not sure we really need to support overriding this unless there's a specific and common enough use case for it.

@ahus1
ahus1 commented Nov 13, 2023
Copy link
Copy Markdown
Member

If I understand correctly, the thread pool is adjusted automatically based on number of CPUs available. Not sure we really need to support overriding this unless there's a specific and common enough use case for it.

The default thread pool size is per default 200 or even more depending on the number of CPUs. When running load tests, we found that this default regularly exceeds the capacity of the JGroup thread pool for Infinispan. For a three-pod Keycloak deployment, we actually recommend to reduce the number of Quarkus threads to 66. See https://www.keycloak.org/keycloak-benchmark/kubernetes-guide/latest/running/keycloak-deployment

I still agree that this should be a separate PR.

@ahus1
ahus1 self-requested a review November 13, 2023 10:54
ahus1
ahus1 previously approved these changes Nov 13, 2023
@ahus1 ahus1 left a comment
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the changes. The docs and the CLI option looks now good to me.

@mabartos
Copy link
Copy Markdown
Member

@vmuzikar I assume this PR is ready to review, right? I'd prefer to put the status/hold label and make the PR ready to be notified about it in cases like this as we're blocked by some issue/PR. WDYT?

@vmuzikar I'll check it today.

@vmuzikar
Copy link
Copy Markdown
Contributor Author

@ahus1 Thanks, created a follow-up: #24704

I assume this PR is ready to review, right? I'd prefer to put the status/hold label and make the PR ready to be notified about it in cases like this as we're blocked by some issue/PR. WDYT?

@mabartos I don't consider a PR fully ready for review until tests are passing. Which currently can't be as we're missing the Quarkus upgrade. But it's up to discussion. ;)

@vmuzikar
vmuzikar marked this pull request as ready for review November 20, 2023 13:31
@vmuzikar
vmuzikar requested review from a team as code owners November 20, 2023 13:31
@vmuzikar
Copy link
Copy Markdown
Contributor Author

This is now ready for review, Quarkus upgrade was merged.

@mabartos mabartos left a comment
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, nice job!

Closes keycloak#23340

Co-authored-by: Alexander Schwartz <aschwart@redhat.com>
Signed-off-by: Václav Muzikář <vmuzikar@redhat.com>
@vmuzikar
Copy link
Copy Markdown
Contributor Author

@ahus1 Do you want to give it another look? There should be no real changes, just a rebase with resolved conflicts.

@ghost
ghost commented Nov 20, 2023
Copy link
Copy Markdown

Unreported flaky test detected

If the below flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR.

org.keycloak.testsuite.account.AccountRestServiceTest#updateConsentForClientWithPut

Keycloak CI - Java Distribution IT (windows-latest - temurin - 19)

java.lang.AssertionError
	at org.junit.Assert.fail(Assert.java:87)
	at org.junit.Assert.assertTrue(Assert.java:42)
	at org.junit.Assert.assertTrue(Assert.java:53)
	at org.keycloak.testsuite.account.AccountRestServiceTest.updateConsentForClientWithPut(AccountRestServiceTest.java:1377)
...

Report flaky test

org.keycloak.testsuite.account.AccountRestServiceTest#createConsentForClientWithPut

Keycloak CI - Java Distribution IT (windows-latest - temurin - 19)

java.lang.AssertionError: 
type
Expected: is "GRANT_CONSENT"
     but: was "UPDATE_CONSENT"
	at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
...

Report flaky test

org.keycloak.testsuite.account.AccountRestServiceTest#createConsentForClient

Keycloak CI - Java Distribution IT (windows-latest - temurin - 19)

java.lang.AssertionError: 
type
Expected: is "GRANT_CONSENT"
     but: was "UPDATE_CONSENT"
	at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
...

Report flaky test

@ghost ghost left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unreported flaky test detected, please review

@ahus1 ahus1 left a comment
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the change. I tested it locally and it works as expected: Once the queue size is exceeded, Keycloak responds with a 503.

As we have a workaround for the liveness probe, this will still return 200 in this case. The readiness probe will fail if it needs to access the DB connection and can't determine the status of the database from the connection metrics. The overall health check fails as it is still blocking. All of this is expected.

Approving!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement load shedding for RESTEasy reactive

3 participants

0