Search code examples
rethinkdbrethinkdb-javascript

Should I explicitly close RethinkDB connections?


I'm a little hazy on how connections in RethinkDB work. I'm opening a new connection every time I execute queries without closing them once the queries finish.

Is this a good practice? Or should I be explicitly closing connections once queries are finished?

(I'm using the JS driver. I don't believe the documentation speaks to this)

[edited cuz the previous post title was vague]


Solution

  • You should explicitly close connections, otherwise you will exhaust the database server. I'm assuming you are running node.js, which will keep connections until you kill the application.

    Preferrably you would use a pool, to lessen the overhead of connecting. For a pre-made solution, look into rethinkdbdash which is basically the same API as the official one, but with builtin pooling.