fix: changing max threads default

closes: #17483

Signed-off-by: Steve Hawkins <shawkins@redhat.com>
This commit is contained in:
Steve Hawkins 2024-04-08 17:00:09 -04:00 committed by Alexander Schwartz
parent e4987f10f5
commit 9afe3a2560
9 changed files with 36 additions and 22 deletions

View file

@ -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.
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.

View file

@ -127,9 +127,9 @@ public class HttpOptions {
public static final Option<Integer> 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();
}

View file

@ -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<String> resolveMaxThreads(Optional<String> value,
ConfigSourceInterceptorContext configSourceInterceptorContext) {
if (value.isEmpty()) {
return of(String.valueOf(Math.max(MIN_MAX_THREADS, 4 * Runtime.getRuntime().availableProcessors())));
}
return value;
}
}

View file

@ -157,9 +157,9 @@ HTTP(S):
situation. Excess requests will return a "503 Server not Available" response.
--http-pool-max-threads <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 <port> The used HTTP port. Default: 8080.
--http-relative-path <path>
Set the path relative to '/' for serving resources. The path must start with a

View file

@ -201,9 +201,9 @@ HTTP(S):
situation. Excess requests will return a "503 Server not Available" response.
--http-pool-max-threads <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 <port> The used HTTP port. Default: 8080.
--http-relative-path <path>
Set the path relative to '/' for serving resources. The path must start with a

View file

@ -158,9 +158,9 @@ HTTP(S):
situation. Excess requests will return a "503 Server not Available" response.
--http-pool-max-threads <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 <port> The used HTTP port. Default: 8080.
--http-relative-path <path>
Set the path relative to '/' for serving resources. The path must start with a

View file

@ -202,9 +202,9 @@ HTTP(S):
situation. Excess requests will return a "503 Server not Available" response.
--http-pool-max-threads <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 <port> The used HTTP port. Default: 8080.
--http-relative-path <path>
Set the path relative to '/' for serving resources. The path must start with a

View file

@ -131,9 +131,9 @@ HTTP(S):
situation. Excess requests will return a "503 Server not Available" response.
--http-pool-max-threads <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 <port> The used HTTP port. Default: 8080.
--https-certificate-file <file>
The file path to a server certificate or certificate chain in PEM format.

View file

@ -175,9 +175,9 @@ HTTP(S):
situation. Excess requests will return a "503 Server not Available" response.
--http-pool-max-threads <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 <port> The used HTTP port. Default: 8080.
--https-certificate-file <file>
The file path to a server certificate or certificate chain in PEM format.