Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document that Tomcat's maxQueueCapacity need to be greater than 0 #42726

Closed
sahilkamboj334 opened this issue Oct 17, 2024 · 4 comments
Closed
Labels
type: documentation A documentation update
Milestone

Comments

@sahilkamboj334
Copy link

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 ?

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Oct 17, 2024
@mhalbritter
Copy link
Contributor

mhalbritter commented Oct 17, 2024

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);
    }

@mhalbritter mhalbritter changed the title Tomcat not rejecting incoming connection requests. Document that Tomcat's maxQueueCapacity need to be greater than 0 Oct 17, 2024
@mhalbritter mhalbritter added type: documentation A documentation update and removed status: waiting-for-triage An issue we've not yet triaged labels Oct 17, 2024
@mhalbritter mhalbritter added this to the 3.3.x milestone Oct 17, 2024
@mhalbritter
Copy link
Contributor

I'll add some documentation around that.

@sahilkamboj334
Copy link
Author

@mhalbritter thanks for quick response but i also tried this with 1 and its still the same.

@snicoll snicoll modified the milestones: 3.3.x, 3.3.5 Oct 17, 2024
@mhalbritter
Copy link
Contributor

There are multiple queues in play here, and it's dependent on the OS. I've written some notes here: #36087 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: documentation A documentation update
Projects
None yet
Development

No branches or pull requests

4 participants