Tokio-postgres: Should I use Pooling just like multithreaded database connection?

In a non-asynchronous database connection, I can create several threads, each has their own database client, i.e pooling.

However, in an asynchronous context, should I use the same approach as above (pooling)?
I believe the answer is, yes. Because I've seen database client pooling in Node.js (node-postgres, etc), and it is asyncronous...

Yes - your IO implementation doesn't affect the need to have separate connections to service concurrent requests.

1 Like

Hi, @sfackler

Thank you for the response. But, is there any existing example for tokio-postgres pooling? If there isn't any, would you at least give a clue of how to build one?

Thanks.

I haven't used it (I don't use async) but the deadpool-postgres crate has examples using tokio-postgress, in the crate's readme.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.