diff --git a/docs/documentation/upgrading/topics/changes/changes-25_0_0.adoc b/docs/documentation/upgrading/topics/changes/changes-25_0_0.adoc index 08a6347cae..52e0993e48 100644 --- a/docs/documentation/upgrading/topics/changes/changes-25_0_0.adoc +++ b/docs/documentation/upgrading/topics/changes/changes-25_0_0.adoc @@ -87,4 +87,8 @@ Note that the `setSessionState()` method is also removed from the `IDToken` clas A new `Session State (session_state)` mapper is also included and can be assigned to client scopes (for instance `basic` client scope) to revert to the old behavior. -If an old version of the JS adapter is used, the `Session State (session_state)` mapper should also be used via client scopes as described above. \ No newline at end of file +If an old version of the JS adapter is used, the `Session State (session_state)` mapper should also be used via client scopes as described above. + += Default `http-pool-max-threads` reduced + +`http-pool-max-threads` if left unset will default to the greater of 50 or 4 x (available processors). Previously it defaulted to the greater of 200 or 8 x (available processors). Reducing the number or task threads for most usage scenarios will result in slightly higher performance due to less context switching among active threads. \ No newline at end of file diff --git a/quarkus/config-api/src/main/java/org/keycloak/config/HttpOptions.java b/quarkus/config-api/src/main/java/org/keycloak/config/HttpOptions.java index 17bbd440e9..7ac308c26a 100644 --- a/quarkus/config-api/src/main/java/org/keycloak/config/HttpOptions.java +++ b/quarkus/config-api/src/main/java/org/keycloak/config/HttpOptions.java @@ -127,9 +127,9 @@ public class HttpOptions { public static final Option HTTP_POOL_MAX_THREADS = new OptionBuilder<>("http-pool-max-threads", Integer.class) .category(OptionCategory.HTTP) .description("The maximum number of threads. If this is not specified then it will be automatically sized " + - "to the greatest of 8 * the number of available processors and 200. " + - "For example if there are 4 processors the max threads will be 200. " + - "If there are 48 processors it will be 384.") + "to the greater of 4 * the number of available processors and 50. " + + "For example if there are 4 processors the max threads will be 50. " + + "If there are 48 processors it will be 192.") .build(); } diff --git a/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/configuration/mappers/HttpPropertyMappers.java b/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/configuration/mappers/HttpPropertyMappers.java index 6180f6eb98..36f5247c58 100644 --- a/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/configuration/mappers/HttpPropertyMappers.java +++ b/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/configuration/mappers/HttpPropertyMappers.java @@ -20,6 +20,7 @@ import static java.util.Optional.of; import static org.keycloak.quarkus.runtime.configuration.mappers.PropertyMapper.fromOption; public final class HttpPropertyMappers { + private static final int MIN_MAX_THREADS = 50; private static final String QUARKUS_HTTPS_CERT_FILES = "quarkus.http.ssl.certificate.files"; private static final String QUARKUS_HTTPS_CERT_KEY_FILES = "quarkus.http.ssl.certificate.key-files"; @@ -111,6 +112,7 @@ public final class HttpPropertyMappers { .build(), fromOption(HttpOptions.HTTP_POOL_MAX_THREADS) .to("quarkus.thread-pool.max-threads") + .transformer(HttpPropertyMappers::resolveMaxThreads) .paramLabel("threads") .build() }; @@ -178,5 +180,13 @@ public final class HttpPropertyMappers { } return value; } + + private static Optional resolveMaxThreads(Optional value, + ConfigSourceInterceptorContext configSourceInterceptorContext) { + if (value.isEmpty()) { + return of(String.valueOf(Math.max(MIN_MAX_THREADS, 4 * Runtime.getRuntime().availableProcessors()))); + } + return value; + } } diff --git a/quarkus/tests/integration/src/test/resources/org/keycloak/it/cli/dist/approvals/cli/help/HelpCommandDistTest.testStartDevHelp.approved.txt b/quarkus/tests/integration/src/test/resources/org/keycloak/it/cli/dist/approvals/cli/help/HelpCommandDistTest.testStartDevHelp.approved.txt index 838fca4878..d40a287f06 100644 --- a/quarkus/tests/integration/src/test/resources/org/keycloak/it/cli/dist/approvals/cli/help/HelpCommandDistTest.testStartDevHelp.approved.txt +++ b/quarkus/tests/integration/src/test/resources/org/keycloak/it/cli/dist/approvals/cli/help/HelpCommandDistTest.testStartDevHelp.approved.txt @@ -157,9 +157,9 @@ HTTP(S): situation. Excess requests will return a "503 Server not Available" response. --http-pool-max-threads The maximum number of threads. If this is not specified then it will be - automatically sized to the greatest of 8 * the number of available - processors and 200. For example if there are 4 processors the max threads - will be 200. If there are 48 processors it will be 384. + automatically sized to the greater of 4 * the number of available processors + and 50. For example if there are 4 processors the max threads will be 50. If + there are 48 processors it will be 192. --http-port The used HTTP port. Default: 8080. --http-relative-path Set the path relative to '/' for serving resources. The path must start with a diff --git a/quarkus/tests/integration/src/test/resources/org/keycloak/it/cli/dist/approvals/cli/help/HelpCommandDistTest.testStartDevHelpAll.approved.txt b/quarkus/tests/integration/src/test/resources/org/keycloak/it/cli/dist/approvals/cli/help/HelpCommandDistTest.testStartDevHelpAll.approved.txt index ec0e1d7790..78685f75a4 100644 --- a/quarkus/tests/integration/src/test/resources/org/keycloak/it/cli/dist/approvals/cli/help/HelpCommandDistTest.testStartDevHelpAll.approved.txt +++ b/quarkus/tests/integration/src/test/resources/org/keycloak/it/cli/dist/approvals/cli/help/HelpCommandDistTest.testStartDevHelpAll.approved.txt @@ -201,9 +201,9 @@ HTTP(S): situation. Excess requests will return a "503 Server not Available" response. --http-pool-max-threads The maximum number of threads. If this is not specified then it will be - automatically sized to the greatest of 8 * the number of available - processors and 200. For example if there are 4 processors the max threads - will be 200. If there are 48 processors it will be 384. + automatically sized to the greater of 4 * the number of available processors + and 50. For example if there are 4 processors the max threads will be 50. If + there are 48 processors it will be 192. --http-port The used HTTP port. Default: 8080. --http-relative-path Set the path relative to '/' for serving resources. The path must start with a diff --git a/quarkus/tests/integration/src/test/resources/org/keycloak/it/cli/dist/approvals/cli/help/HelpCommandDistTest.testStartHelp.approved.txt b/quarkus/tests/integration/src/test/resources/org/keycloak/it/cli/dist/approvals/cli/help/HelpCommandDistTest.testStartHelp.approved.txt index 2c41106267..200ef6f956 100644 --- a/quarkus/tests/integration/src/test/resources/org/keycloak/it/cli/dist/approvals/cli/help/HelpCommandDistTest.testStartHelp.approved.txt +++ b/quarkus/tests/integration/src/test/resources/org/keycloak/it/cli/dist/approvals/cli/help/HelpCommandDistTest.testStartHelp.approved.txt @@ -158,9 +158,9 @@ HTTP(S): situation. Excess requests will return a "503 Server not Available" response. --http-pool-max-threads The maximum number of threads. If this is not specified then it will be - automatically sized to the greatest of 8 * the number of available - processors and 200. For example if there are 4 processors the max threads - will be 200. If there are 48 processors it will be 384. + automatically sized to the greater of 4 * the number of available processors + and 50. For example if there are 4 processors the max threads will be 50. If + there are 48 processors it will be 192. --http-port The used HTTP port. Default: 8080. --http-relative-path Set the path relative to '/' for serving resources. The path must start with a diff --git a/quarkus/tests/integration/src/test/resources/org/keycloak/it/cli/dist/approvals/cli/help/HelpCommandDistTest.testStartHelpAll.approved.txt b/quarkus/tests/integration/src/test/resources/org/keycloak/it/cli/dist/approvals/cli/help/HelpCommandDistTest.testStartHelpAll.approved.txt index 5dd4b85acf..791e818471 100644 --- a/quarkus/tests/integration/src/test/resources/org/keycloak/it/cli/dist/approvals/cli/help/HelpCommandDistTest.testStartHelpAll.approved.txt +++ b/quarkus/tests/integration/src/test/resources/org/keycloak/it/cli/dist/approvals/cli/help/HelpCommandDistTest.testStartHelpAll.approved.txt @@ -202,9 +202,9 @@ HTTP(S): situation. Excess requests will return a "503 Server not Available" response. --http-pool-max-threads The maximum number of threads. If this is not specified then it will be - automatically sized to the greatest of 8 * the number of available - processors and 200. For example if there are 4 processors the max threads - will be 200. If there are 48 processors it will be 384. + automatically sized to the greater of 4 * the number of available processors + and 50. For example if there are 4 processors the max threads will be 50. If + there are 48 processors it will be 192. --http-port The used HTTP port. Default: 8080. --http-relative-path Set the path relative to '/' for serving resources. The path must start with a diff --git a/quarkus/tests/integration/src/test/resources/org/keycloak/it/cli/dist/approvals/cli/help/HelpCommandDistTest.testStartOptimizedHelp.approved.txt b/quarkus/tests/integration/src/test/resources/org/keycloak/it/cli/dist/approvals/cli/help/HelpCommandDistTest.testStartOptimizedHelp.approved.txt index 85ac3b0859..d977355a55 100644 --- a/quarkus/tests/integration/src/test/resources/org/keycloak/it/cli/dist/approvals/cli/help/HelpCommandDistTest.testStartOptimizedHelp.approved.txt +++ b/quarkus/tests/integration/src/test/resources/org/keycloak/it/cli/dist/approvals/cli/help/HelpCommandDistTest.testStartOptimizedHelp.approved.txt @@ -131,9 +131,9 @@ HTTP(S): situation. Excess requests will return a "503 Server not Available" response. --http-pool-max-threads The maximum number of threads. If this is not specified then it will be - automatically sized to the greatest of 8 * the number of available - processors and 200. For example if there are 4 processors the max threads - will be 200. If there are 48 processors it will be 384. + automatically sized to the greater of 4 * the number of available processors + and 50. For example if there are 4 processors the max threads will be 50. If + there are 48 processors it will be 192. --http-port The used HTTP port. Default: 8080. --https-certificate-file The file path to a server certificate or certificate chain in PEM format. diff --git a/quarkus/tests/integration/src/test/resources/org/keycloak/it/cli/dist/approvals/cli/help/HelpCommandDistTest.testStartOptimizedHelpAll.approved.txt b/quarkus/tests/integration/src/test/resources/org/keycloak/it/cli/dist/approvals/cli/help/HelpCommandDistTest.testStartOptimizedHelpAll.approved.txt index 953dfa390a..5aa961ed62 100644 --- a/quarkus/tests/integration/src/test/resources/org/keycloak/it/cli/dist/approvals/cli/help/HelpCommandDistTest.testStartOptimizedHelpAll.approved.txt +++ b/quarkus/tests/integration/src/test/resources/org/keycloak/it/cli/dist/approvals/cli/help/HelpCommandDistTest.testStartOptimizedHelpAll.approved.txt @@ -175,9 +175,9 @@ HTTP(S): situation. Excess requests will return a "503 Server not Available" response. --http-pool-max-threads The maximum number of threads. If this is not specified then it will be - automatically sized to the greatest of 8 * the number of available - processors and 200. For example if there are 4 processors the max threads - will be 200. If there are 48 processors it will be 384. + automatically sized to the greater of 4 * the number of available processors + and 50. For example if there are 4 processors the max threads will be 50. If + there are 48 processors it will be 192. --http-port The used HTTP port. Default: 8080. --https-certificate-file The file path to a server certificate or certificate chain in PEM format.