RethinkDB: how many connections?
I start with rethinkdb
in python
and look at different approaches:
- Blocking approach with threads
- A non-blocking, callback-based approach with
Tornado
- Greenlet based approach using
gevent
In the first case, it is natural to provide each thread with an object connection
. In the second and third cases, however, I don't quite understand.
With tornado and gentent, how and when should I create connections? How much should I have?
source to share
If you are using a non-blocking library, one connection should be sufficient in RethinkDB 2.0 (up to 2.0 was less for each parallelism connection). However, the connection overhead is quite low. Some people open a connection for every request, and even that is not too slow, so you should just do whatever you want.
EDIT: This advice is outdated. For newer versions of RethinkDB that use one connection per request, it is strongly discouraged. One connection per stream is still fine.
source to share