Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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]

like image 277
wle8300 Avatar asked Nov 28 '25 13:11

wle8300


1 Answers

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.

like image 56
jishi Avatar answered Nov 30 '25 06:11

jishi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!