Spring Boot Embedded Tomcat Internal Working - spring-boot

I recently read an article regarding Tomcat architecture and a high level overview of its working and monitoring.
Key metrics for monitoring Tomcat - DataDog
In this article, it mentions Tomcat having a pool of worker threads per connector that can be configured.
It also mentions about Executors and how it is mainly a thread pool that is shared with multiple connectors.
I have some doubts regarding Spring Boot and its Embedded Tomcat Server
How many Connectors are configured by default for this embedded Tomcat Server?
Does the embedded Tomcat have an Executor configured? Or is it just the basic pool of worker threads.
I can see that we can configure the accept count using application.properties by using the following property
server.tomcat.accept-count
I believe acceptCount sets the max number of connections that can be queued up in the OS level queue when no worker thread is available. ( As per the mentioned article )
Does this mean that there is no Executor configured for the default Connector? If there is, how do we configure the queue size of that executor?
I would be grateful if someone could shed some light on the above.
In short, I just wanted to know if the server configuration via application.propeties is for an Executor or for the Connector specific pool of worker threads.

Related

Springboot callable async operation with liberty executor configuration

We have springboot microservice running on liberty server. We have liberty configured with executor threads core and max size, in parallel can we also have callable implementation on the service to make a maximum utilisation of machine? or will it have counter effect?
You should be able to instruct Spring to use Liberty's default managed executor (which runs tasks on the Liberty thread pool) by supplying a DefaultManagedTaskExecutor to the Spring AsyncSupportConfigurer.setTaskExecutor method.
This will cause Spring to look up java:comp/DefaultManagedExecutorService which is available in Liberty if you enable the concurrent-1.0 feature.
This page has an example of setting the task executor in Spring, except it uses a custom thread pool, and you would replace that with DefaultManagedTaskExecutor:
https://howtodoinjava.com/spring-boot2/rest/async-rest-controller-callable/

How to configure Spring boot 2.4 server threads in undertow?

How to configure spring boot server threads (for both IO and Worker) for undertow embedded server?
Thanks in advance.
As per the documentation:
server.undertow.threads.io //Number of I/O threads to create for the worker. The default is derived from the number of available processors.
server.undertow.threads.worker //Number of worker threads. The default is 8 times the number of I/O threads.

Monitoring tomcat threads and threadpool executors using Spring Boot Actuator

We are doing some performance testing of our application which uses SpringBoot 2.2.2 with Spring Actuator.
We want to monitor:
How many tomcat threads are being used
How many tomcat requests are being queued
How many ThreadPoolTaskExecutor threads are being used (we are using #Async with a threadpool for some of the tasks)
Is this information available in the actuator? I couldn't see which metrics I needed to use.
By enabling Tomcats MBean Registry you will get more metrics collected, including thread pool metrics:
server.tomcat.mbeanregistry.enabled=true

Reduce # of threads created when a Spring Boot-based service is listening on many ports?

This is probably a rather peculiar question. I am using Spring Boot 2.0.2 with the default Tomcat container. In order to set up a test in our QA environment that simulates many servers, I would like to set up a Spring Boot-based REST service that listens on a very large number of ports simultaneously. I'm able to do this using the technique previously described in in another SO post (Configure Spring Boot with two ports) which basically adds connectors using TomcatServletWebServerFactory.addAdditionalTomcatConnectors().
The difficulty is that a large number of threads seem to be created for each additional port activated; some empirical measurements show the total to be 17 + (15 * number of ports). This means listening on 250 ports result in 3767 threads created and 500 ports result in 7517 threads created and I would like to go somewhat beyond that number. The test program used to take the above measurements is the bare minimum to bring up a Spring service and there is no code that creates threads explicitly so insofar, as I know, all of those threads were created by Spring/Tomcat.
Is there a way to accomplish this using Spring that doesn't use so many threads per active port? Would an alternate container like Jetty be more efficient?
You can configure the embedded tomcat container properties in spring boot configuration file and set the appropriate numbers for these properties to limit the threads created by Tomcat container -
server.tomcat.max-threads=200 # Maximum amount of worker threads.
server.tomcat.min-spare-threads=10 # Minimum amount of worker threads.

Configure Stateless EJB Pool size in Websphere

I'm looking for a way to configure the SLSB Pool size in Websphere. Is it possible to configure it from the Admin Console ?
Looking at the IBM Red Books it's mentioned how to configure the ORB Pool which is however used by remote EJB clients. My Requests are arriving from the same JVM by servlets
Thanks
Max
There is a system property called com.ibm.websphere.ejbcontainer.poolSize that can be used to tune bean pool sizes.

Resources