kc_version,cpus,cache,requests,ok,ko,mean_ms,p50_ms,p75_ms,p95_ms,p99_ms,max_ms,req_per_sec,sla_pass
24.0.5,1,cold,8372,8372,0,3,3,3,5,28,58,279.07,true
24.0.5,1,warm,10506,10506,0,2,2,3,4,7,47,338.9,true
24.0.5,2,cold,7326,7326,0,3,3,4,6,8,56,236.32,true
24.0.5,2,warm,8746,8746,0,3,3,3,5,8,46,282.13,true
24.0.5,4,cold,7522,7522,0,3,3,4,6,8,37,242.65,true
24.0.5,4,warm,9398,9398,0,3,3,3,4,7,26,303.16,true
25.0.6,1,cold,6280,6280,0,4,3,4,7,28,54,202.58,true
25.0.6,1,warm,9234,9234,0,3,3,3,4,9,45,307.8,true
25.0.6,2,cold,9776,9776,0,3,3,3,5,6,31,325.87,true
25.0.6,2,warm,13190,13190,0,2,2,3,3,5,28,439.67,true
25.0.6,4,cold,9718,9718,0,3,3,3,5,6,50,323.93,true
25.0.6,4,warm,13462,13462,0,2,2,3,3,4,22,448.73,true
26.0.8,1,cold,7720,7720,0,3,3,4,5,29,68,257.33,true
26.0.8,1,warm,11932,11932,0,2,2,3,3,5,49,397.73,true
26.0.8,2,cold,9232,9232,0,3,3,3,5,7,36,297.81,true
26.0.8,2,warm,12764,12764,0,2,2,3,3,5,25,411.74,true
26.0.8,4,cold,8988,8988,0,3,3,3,5,7,37,289.94,true
26.0.8,4,warm,13082,13082,0,2,2,3,3,4,31,436.07,true
26.1.5,1,cold,7442,7442,0,4,3,4,5,31,77,240.06,true
26.1.5,1,warm,9988,9988,0,3,3,3,4,6,47,322.19,true
26.1.5,2,cold,9308,9308,0,3,3,3,5,6,43,300.26,true
26.1.5,2,warm,12900,12900,0,2,2,3,3,4,22,430,true
26.1.5,4,cold,9308,9308,0,3,3,3,5,7,41,310.27,true
26.1.5,4,warm,13062,13062,0,2,2,3,3,4,23,421.35,true
26.2.5,1,cold,7544,7544,0,4,3,4,5,30,86,243.35,true
26.2.5,1,warm,11768,11768,0,2,2,3,3,5,50,392.27,true
26.2.5,2,cold,9306,9306,0,3,3,3,5,7,35,300.19,true
26.2.5,2,warm,12788,12788,0,2,2,3,3,4,19,426.27,true
26.2.5,4,cold,9036,9036,0,3,3,3,5,7,52,291.48,true
26.2.5,4,warm,12722,12722,0,2,2,3,3,4,54,410.39,true
26.3.5,1,cold,482,482,0,61,53,66,116,300,6976,15.55,true
26.3.5,1,warm,804,804,0,36,42,63,80,102,168,25.94,true
26.3.5,2,cold,680,680,0,43,45,63,79,116,4165,21.94,true
26.3.5,2,warm,848,848,0,34,19,62,67,80,104,27.35,true
26.3.5,4,cold,656,656,0,44,50,65,85,118,4304,21.16,true
26.3.5,4,warm,842,842,0,34,30,62,68,82,115,27.16,true
26.4.7,1,cold,522,522,0,55,58,65,107,268,5410,16.84,true
26.4.7,1,warm,720,720,0,40,57,68,95,113,160,23.23,true
26.4.7,2,cold,626,626,0,46,55,68,90,119,3459,20.19,true
26.4.7,2,warm,748,748,0,38,36,67,77,113,129,24.13,true
26.4.7,4,cold,580,580,0,49,46,70,105,150,3880,18.71,true
26.4.7,4,warm,730,730,0,39,32,67,92,111,128,23.55,true
26.5.7,1,cold,484,484,0,60,59,68,126,295,5800,15.61,true
26.5.7,1,warm,720,720,0,40,56,67,93,111,129,23.23,true
26.5.7,2,cold,578,578,0,49,53,71,111,144,3393,19.27,true
26.5.7,2,warm,782,782,0,36,41,64,74,93,109,25.23,true
26.5.7,4,cold,678,678,0,43,42,65,83,123,3274,21.87,true
26.5.7,4,warm,796,796,0,36,33,64,76,84,102,25.68,true
26.6.1,1,cold,458,458,0,64,62,77,179,276,5468,14.77,true
26.6.1,1,warm,714,714,0,41,40,70,95,115,201,23.03,true
26.6.1,2,cold,578,578,0,50,53,73,104,142,3306,18.65,true
26.6.1,2,warm,704,704,0,41,52,71,94,115,159,22.71,true
26.6.1,4,cold,676,676,0,43,58,64,87,129,3220,21.81,true
26.6.1,4,warm,664,664,0,43,54,68,109,157,312,21.42,true
Warning
edit: The original benchmark run did not take the keycloak version - benchmark tool compatibility into account and runs on versions before 26.3 were silently failing creating the users, effectively running on an empty realm.
For the corrected measurements see #48480 (comment)
Before reporting an issue
Area
admin/api
Describe the bug
Context
After upgrading from 25.0.4 to 26.5.5 the admin api users endpoint reponse time on cold cache went from few seconds to 2+ mins with low number of users (1-2k)
Endpoint and params
/admin/realms/{realm}/users?briefRepresentation=false&first=0&max=-1&q=The setup uses fgap v1, 20+ custom user attributes, brute force detection with permanent lockout.
To identify the issue without the effects of that specific realm setup, I've ran the official benchmarks on the base keycloak images without any customisations.
Benchmarks
list of versions
test run command
java -Xmx1G \ -Drealm-name=test-realm \ -Dclient-secret=gatling-secret \ -Dusers-per-realm=1000 \ -Duser-page-size=1000 \ -Duser-number-of-pages=1 \ -Dusers-per-sec=10 \ -Dmeasurement=30 \ -cp "$FAT_JAR" \ io.gatling.app.Gatling \ -s "keycloak.scenario.admin.UserCrawl"docker compose
Initial results
Warning
edit: The measurements for versions before 26.3 are not correct, see #48480 (comment)
Version 26.3.5 shows a 3-4x performance degradation
csv data
Something is clearly going on, claude checking the list of commits between the two versions flagged
as the possible culprit. Built a local image from a400057 but it turned out to be still good.
Bisect - 1st performance bump
Warning
edit: These findings are invalid, see #48480 (comment)
To find the offending commit, followed this workflow:
git bisect
csv data
The offending commit was 24910d9 (#37926), based on the changes EntityManagerProxy wrapper seemed as something that would affect database operations.For testing the hypotesis, I've asked claude to revert the EntityManagerProxy related change only (see zaenk@14cb345), and run the test one more time.Removing the EntityManagerProxy restored the performance for this test.The linked commit zaenk@14cb345 is not a proposed fix, it was just testing the effect of EntityManagerProxy on the perfomrance of the admin api users endpoint.The reports also show another degradation step between 5386b06 and 26.3.5,but I have not investigated that yet (maybe #46681 related?)see below.Claude's original tip, FGAP partial evaluation, has a slight effect on the number, but not that dramatic - it was introduced sometimes after d7966c0.Bisect - 2nd performance bump
Warning
edit: This finding is valid, though, less dramatic then what was initially implied by the issue, see #48480 (comment)
The issue identified does not reach the level of slowdown that was measured in 26.3.5, so in another session ran the same load tests for the remaining part of the git history
csv data
Commit 34ad280 (#39598) introduced a refactor to use user profile provider when mapping user representation on admin api endpoints.
Reverting to user model based only based mapping in the code path (zaenk@add978f) of the benchmark restores the performance to the previous level.
csv data
Version
26.5.5
Regression
Expected behavior
maintained req/sec and response time performance of admin api between releases
Actual behavior
for some my setup, admin api users single page can take more than 60s-120s
if the api call took 10-20 sec previously (which would be still fine) now it takes 60+ sec with this rate of degradation.
How to Reproduce?
I don't have a reproducer yet for the extreme low response rate, but I provided the description with load test results, git bisect investigation that pinpoints an issue that caused a performance degradation in keycloak admin api.
Anything else?
After looking into 34ad280, noticed
@BatchSize(20)for UserEntity.attributes - as I have 20+ attributes per user I speculate this also have a multiplier effect in my setup, but I still need to look into it with jfr/cryostat....edit: added bisect 2 section, added 'anything else' answer
edit2: summary table, and making clear that the attribute fetch is a speculation
edit3: turns out the initial benchmark setup had an error. the data here is misleading, see #48480 (comment) for the corrected measurements_