Keycloak on ROSA 基準測試主要結果
這總結了在 2024 年 5 月執行的 Keycloak 25 發布候選版本的基準測試。將此作為起點來計算 Keycloak 環境的需求。使用它們在您的環境中執行負載測試。
目前,收集刷新令牌的 CPU 使用率是手動執行的,預計在不久的將來會自動化(keycloak/keycloak-benchmark#517)。 |
設定
此設定會每日在 GitHub 動作排程上執行
-
OpenShift 4.15.x 透過 ROSA 部署在 AWS 上,在 AWS 單一區域中有兩個 AWS 可用區域。
-
使用
m5.2xlarge
實例的機器集區。 -
Keycloak 25 發布候選版本使用 Operator 部署,每個站點有 3 個 Pod 作為主動/被動設定,以及連接兩個站點的 Infinispan。
-
預設使用者密碼雜湊使用 Argon2 和 5 次雜湊迭代,以及最小記憶體大小 7 MiB,根據 OWASP 的建議。
-
資料庫已播種 100,000 名使用者和 100,000 個客戶端。
-
Infinispan 快取預設為 10,000 個條目,因此並非所有客戶端和使用者都適合快取,有些請求需要從資料庫中提取資料。
-
所有會話都按照預設在分散式快取中,每個條目有兩個擁有者,允許一個 Pod 失敗而不會遺失資料。
-
資料庫 Amazon Aurora PostgreSQL 採用多可用區域設定,寫入器實例位於主要站點的可用區域中。
結果
請參閱主要 Keycloak 文件中的concepts-memory-and-cpu-sizing,了解有關最新版本的結果、計算範例、觀察和建議。有關即將發布版本的更新資訊可在GitHub 儲存庫的主分支中找到。
執行的測試
每個測試運行 10 分鐘。
-
按照預設設定 ROSA 叢集。
-
部署 Keycloak 和監控
cd provision/openshift task task monitoring
-
建立資料集
task dataset-import -- -a create-realms -u 100000 # wait for first task to complete task dataset-import -- -a create-clients -c 100000 -n realm-0
-
準備透過 Ansible 執行基準測試的環境
有關詳細資訊,請參閱透過 Ansible 和 EC2 執行基準測試。
此處使用的env.yml
內容cluster_size: 5 instance_type: t4g.small instance_volume_size: 30 kcb_zip: ../benchmark/target/keycloak-benchmark-0.14-SNAPSHOT.zip kcb_heap_size: 1G
-
建立負載執行器
cd ../../ansible ./aws_ec2.sh start <region of ROSA cluster>
-
執行不同的負載測試
-
測試建立會話的記憶體
./benchmark.sh eu-west-1 \ --scenario=keycloak.scenario.authentication.AuthorizationCode \ --server-url=${KEYCLOAK_URL} \ --realm-name=realm-0 \ --users-per-sec=<number of users per second> \ --ramp-up=20 \ --logout-percentage=0 \ --measurement=600 \ --users-per-realm=100000 \ --log-http-on-failure
-
測試使用者登入的 CPU 使用率
./benchmark.sh eu-west-1 \ --scenario=keycloak.scenario.authentication.AuthorizationCode \ --server-url=${KEYCLOAK_URL} \ --realm-name=realm-0 \ --users-per-sec=<number of users per second> \ --ramp-up=20 \ --logout-percentage=100 \ --measurement=600 \ --users-per-realm=100000 \ --log-http-on-failure
-
測試登入和刷新令牌的 CPU 使用率,刷新與登入的比率為 10 比 1。使用先前的測試來扣除僅登入的 CPU 使用率,以獲得令牌刷新的 CPU 使用率。
./benchmark.sh eu-west-1 \ --scenario=keycloak.scenario.authentication.AuthorizationCode \ --server-url=${KEYCLOAK_URL} \ --realm-name=realm-0 \ --users-per-sec=<number of users per second> \ --ramp-up=20 \ --logout-percentage=100 \ --refresh-token-count=10 \ --measurement=600 \ --users-per-realm=100000 \ --log-http-on-failure
-
測試客戶端憑證授權的 CPU 使用率
./benchmark.sh eu-west-1 \ --scenario=keycloak.scenario.authentication.ClientSecret \ --server-url=${KEYCLOAK_URL} \ --realm-name=realm-0 \ --users-per-sec=<number of clients per second> \ --ramp-up=20 \ --logout-percentage=100 \ --measurement=600 \ --users-per-realm=100000 \ --log-http-on-failure
-