Springboot version - 3.3.4 java - 21
I have used following settings to test tomcat with springboot. i want to check when tomcat rejects the requests. server.tomcat.accept-count=0 server.tomcat.threads.max=1 server.tomcat.maxConnections=1 server.tomcat.threads.min-spare=1 server.tomcat.threads.maxQueueCapacity=0
I have a controller method where i put a sleep of 5 seconds and i am hitting same endpoint from multiple terminals. Ideally other parallel requests should be rejected with an error but in my case requests are executing sequenclly once previous gets completed.
Could anyone please help what i am doing wrong here ?
Comment From: mhalbritter
server.tomcat.threads.maxQueueCapacity=0 doesn't work. It needs to be at least 1.
map.from(threadProperties::getMaxQueueCapacity)
.when(this::isPositive)
.to((maxQueueCapacity) -> customizeMaxQueueCapacity(factory, maxQueueCapacity));
That's because of this in the Tomcat code:
public TaskQueue(int capacity) {
super(capacity);
}
which calls LinkedBlockingQueue, which would throw if set to 0:
public LinkedBlockingQueue(int capacity) {
if (capacity <= 0) throw new IllegalArgumentException();
this.capacity = capacity;
last = head = new Node<E>(null);
}
Comment From: mhalbritter
I'll add some documentation around that.
Comment From: sahilkamboj334
@mhalbritter thanks for quick response but i also tried this with 1 and its still the same.
Comment From: mhalbritter
There are multiple queues in play here, and it's dependent on the OS. I've written some notes here: https://github.com/spring-projects/spring-boot/issues/36087#issuecomment-1611102793