keycloak / keycloak-benchmark

Keycloak Benchmark
https://www.keycloak.org/keycloak-benchmark/
Apache License 2.0
130 stars 72 forks source link

Too long time to create 10 lakh users for keycloak through benchmark data generator. #745

Closed Tejasbglr closed 5 months ago

Tejasbglr commented 7 months ago

Describe the bug

Hi team,

We are running performance test for the keycloak server ( keycloak version - 21.1.1).

We are following this document for the performance test https://www.keycloak.org/keycloak-benchmark/.

As part of the test we are populating the database with 10 lakh user entries for a single keycloak realm. But for creating the 10 lakh users it's taking about 4 hours.

Is there a way to speed up the user creation process?

Version

21.1.1

Expected behavior

No response

Actual behavior

No response

How to Reproduce?

No response

Anything else?

No response

ahus1 commented 7 months ago

Thank you for reaching out.

To double check (I assume you are already doing this): When using KC21.1, please use the code in the Branch 0.9-SNAPSHOT, see also https://github.com/keycloak/keycloak-benchmark/releases/tag/0.9-SNAPSHOT

When creating new users, the hashing of the user's password is usually the bottleneck, at it takes a lot of CPU. If you see a high CPU usage, try adding more CPU resources. You could also temporarily reduce the number of hash iterations, but beware that you'll then see in the load test later also a lower CPU usage than with the real load.

If you don't see a high CPU usage, something is off with your setup, and you'll need to analyze your setup / system for possible bottlenecks.

kami619 commented 7 months ago

@Tejasbglr with using Keycloak main branch code, thats a candidate for Keycloak 25 release (which uses a new default user password hashing algorithm Argon2 with 5 hashing iterations), I was able to generate the 10 Lakhs(1 million) users in 2.37 hrs. So it definitely is proportional to the hashing algorithm and hashing iterations as @ahus1 pointed out earlier.

{"timestamp":"2024-03-28T15:25:00.327252386Z","sequence":63032,"loggerClassName":"org.jboss.logging.Logger","loggerName":"org.keycloak.benchmark.dataset.DatasetResourceProvider",
"level":"INFO","message":"Created all 1000000 users in realm realm-2,
Time since start of the task 'Creation of 1000000 users in the realm realm-2': 8544827 ms",
"threadName":"Thread-44","threadId":145,"mdc":{},"ndc":"","hostName":"keycloak-2","processName":"QuarkusEntryPoint","processId":1}
ahus1 commented 5 months ago

Closing issue as there was no reply, assuming the issue is resolved. Please open a new issue if the problem persists, or comment here to have this issue re-opened.