question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MongoWaitQueueFullException in Webflux + Reactive Mongo

See original GitHub issue

Affects: 5.1.2.RELEASE


The latest TechEmpower’s benchmark shows a lot of errors for Webflux + Spring data mongo. I digged and found out that under load, we get a lot of com.mongodb.MongoWaitQueueFullException: Too many threads are already waiting for a connection. Max number of threads (maxWaitQueueSize) of 500 has been exceeded. exceptions.

From our discussion on gitter, @mp911de thinks that “WebFlux could have a notion of connection backpressure and should limit subscription rate/demand rate to provide a sense of protection for downstream components within the application”.

Code of the benchmark here

Related issue : #20338

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:18 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
simonbaslecommented, Feb 6, 2019

Yes, and I believe that would also be resolved by a reactive DB Connection pooled capped at 500 connections.

0reactions
cbornetcommented, Feb 10, 2019

For the current use case here, I think the first step is to have a closer look to understand why Flux.concat does not help. It seems like it should with 100 connections + 500 queue size > 512 concurrency. Only then we can reason about what should change if anything in the configuration.

So using concat instead of merge does have an effect on the number of items put in the wait queue. The number of concurrent connections is related to the queue size (with concat it’s queue size + a little number). The pool size doesn’t seem to have any effect. I guess all items go into the queue before being given a pool connection. I can put a high maxWaitQueueSize (using waitqueuemultiple parameter in connexion string) and then I don’t see any issues both for concat and merge. I think I’ll keep merge with a queue size of 512*20 since it gives better results for low concurrency requests (since the 20 requests are done concurrently). For me this issue is understood and can be closed. Maybe there could be some documentation somewhere about the Mongo async driver pool size. I’ll do the fix for the TechEmpower benchmark. Thanks to all.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[JAVA-3166] Improve MongoWaitQueueFullException message
MongoWaitQueueFullException is created with two messages: Too many threads are already waiting for a connection.
Read more >
Spring WebFlux/Reactive Mongo based application opens ...
It is caused by setting maxConnectionIdleTime=1 , which you can see in logs as well: ...because it is past its maximum allowed idle...
Read more >
spring-projects/spring-data - Gitter
Hi. The latest TechEmpower benchmark show quite disappointing results for Webflux + Reactive-mongo. I replayed the test on my laptop and have quite...
Read more >
[Java] High Mongo time and error rates on Spring Webflux and ...
On the mongo issue, the mongo DB transaction times are so wrong. see the image. In here I'm using spring-boot-starter-data-mongodb-reactive 2.3.
Read more >
Spring Data Mongo · Spring WebFlux By Example - Hantsy Bai
Spring Data Mongo provides reactive variants of MongoTemplate and MongoRepository , aka ReactiveMongoTemplate and ReactiveMongoRepository which have ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found