Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why is there more DB connection pool than main thread in Webflux?

I use Webflux R2DBC.

I know, The default value creates 1 thread per CPU core.

However, I know that the default value of R2DBC’s connection pool is 10.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I can’t understood that….

DB connections operate asynchronously. Then, DB connection don’t need many thread pool.

Because the DB connection only sends and receives, connection can do other work(other sending or receiving) while waiting for it.

Rather, since the main thread(1 per CPU core) performs various calculations, the number of main threads should be large.

What am i missing? please solve my doubts!

>Solution :

I think you kind of have it backwards.

since the main thread(1 per CPU core) performs various calculations, the number of main threads should be large.

A (logical) CPU can perform only one task at a time and since threads in a reactive application should never just wait, since all calls are non-blocking, it doesn’t make sense to have more threads than CPU’s.

DB connections operate asynchronously. Then, DB connection don’t need many thread pool.

Correct, you don’t need a thread pool for your database connectivity. But a connection pool isn’t a thread pool. I holds connections. Database connections are still expensive to create, so you want to reuse them and database transactions are bound to the database connection, so you need multiple connections in order to process different requests in separate transactions.

Of course how big a connection pool should be is a completely different and rather complex question.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading