web-dev-qa-db-ja.com

SpringBootアプリケーションのTomcatのデフォルトのスレッドプール

Spring Bootアプリケーションまたは一般的に、Tomcatにはデフォルトのスレッドプールが構成されていますか?

何も設定しない場合、Tomcatはリクエストごとに新しいスレッドを開始し、リクエストが終了するとスレッドは破棄されますか?

また、スレッドプールが構成されている場合、コンテナーがプールからそのスレッドを選択するたびに、特定のスレッドが多くの要求を処理しますか?

3
Harshana

これがspringbootに埋め込まれたTomcatの設定です

server.Tomcat.accept-count=100 # Maximum queue length for incoming connection requests when all possible request processing threads are in use.
server.Tomcat.accesslog.buffered=true # Whether to buffer output such that it is flushed only periodically.
server.Tomcat.accesslog.directory=logs # Directory in which log files are created. Can be absolute or relative to the Tomcat base dir.
server.Tomcat.accesslog.enabled=false # Enable access log.
server.Tomcat.accesslog.file-date-format=.yyyy-MM-dd # Date format to place in the log file name.
server.Tomcat.accesslog.pattern=common # Format pattern for access logs.
server.Tomcat.accesslog.prefix=access_log # Log file name prefix.
server.Tomcat.accesslog.rename-on-rotate=false # Whether to defer inclusion of the date stamp in the file name until rotate time.
server.Tomcat.accesslog.request-attributes-enabled=false # Set request attributes for the IP address, Hostname, protocol, and port used for the request.
server.Tomcat.accesslog.rotate=true # Whether to enable access log rotation.
server.Tomcat.accesslog.suffix=.log # Log file name suffix.
server.Tomcat.additional-tld-skip-patterns= # Comma-separated list of additional patterns that match jars to ignore for TLD scanning.
server.Tomcat.background-processor-delay=10s # Delay between the invocation of backgroundProcess methods. If a duration suffix is not specified, seconds will be used.
server.Tomcat.basedir= # Tomcat base directory. If not specified, a temporary directory is used.
server.Tomcat.internal-proxies=10\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}|\\
        192\\.168\\.\\d{1,3}\\.\\d{1,3}|\\
        169\\.254\\.\\d{1,3}\\.\\d{1,3}|\\
        127\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}|\\
        172\\.1[6-9]{1}\\.\\d{1,3}\\.\\d{1,3}|\\
        172\\.2[0-9]{1}\\.\\d{1,3}\\.\\d{1,3}|\\
        172\\.3[0-1]{1}\\.\\d{1,3}\\.\\d{1,3}\\
        0:0:0:0:0:0:0:1\\
        ::1 # Regular expression that matches proxies that are to be trusted.
server.Tomcat.max-connections=10000 # Maximum number of connections that the server accepts and processes at any given time.
server.Tomcat.max-http-header-size=0 # Maximum size in bytes of the HTTP message header.
server.Tomcat.max-http-post-size=2097152 # Maximum size in bytes of the HTTP post content.
server.Tomcat.max-threads=200 # Maximum amount of worker threads.
server.Tomcat.min-spare-threads=10 # Minimum amount of worker threads.
server.Tomcat.port-header=X-Forwarded-Port # Name of the HTTP header used to override the original port value.
server.Tomcat.protocol-header= # Header that holds the incoming protocol, usually named "X-Forwarded-Proto".
server.Tomcat.protocol-header-https-value=https # Value of the protocol header indicating whether the incoming request uses SSL.
server.Tomcat.redirect-context-root=true # Whether requests to the context root should be redirected by appending a / to the path.
server.Tomcat.remote-ip-header= # Name of the HTTP header from which the remote IP is extracted. For instance, `X-FORWARDED-FOR`.
server.Tomcat.resource.cache-ttl= # Time-to-live of the static resource cache.
server.Tomcat.uri-encoding=UTF-8 # Character encoding to use to decode the URI.
server.Tomcat.use-relative-redirects= # Whether HTTP 1.1 and later location headers generated by a call to sendRedirect will use relative or absolute redirects.

デフォルト値でわかるように、ワーカースレッドの最小量は10であり、ワーカースレッドの最大量は200であり、すべての可能な要求処理時の着信接続要求の最大キュー長です。使用中のスレッドは100です。

4
Bruce

はい、SpringBootはEmbededTomcatサーバーを使用します。application.ymlまたはapplication.propertiesで構成の一部を変更できます。デフォルトでは200スレッドです spring-docs

# EMBEDDED SERVER CONFIGURATION (ServerProperties)
server.port=8080
server.address= # bind to a specific NIC
server.session-timeout= # session timeout in seconds
server.context-path= # the context path, defaults to '/'
server.servlet-path= # the servlet path, defaults to '/'
server.Tomcat.access-log-pattern= # log pattern of the access log
server.Tomcat.access-log-enabled=false # is access logging enabled
server.Tomcat.protocol-header=x-forwarded-proto # ssl forward headers
server.Tomcat.remote-ip-header=x-forwarded-for
server.Tomcat.basedir=/tmp # base dir (usually not needed, defaults to tmp)
server.Tomcat.background-processor-delay=30; # in seconds
server.Tomcat.max-threads = 0 # number of threads in protocol handler
server.Tomcat.uri-encoding = UTF-8 # character encoding to use for URL decoding
4
Deadpool