MongoDB connections for Read/Write operation

Hello all,

I have started using mongodb node recently and I have some queries regarding the connections.

  • How does connections work in mongodb?
  • For every read/write operation a new connection used?
  • After every operation does the connection get closed or I can re-use it for next operation?
  • If I am making multiple request to mongodb (sequential or parallel) does it create a new connection for every request or I can res-use it?

Hi Ali, when quickly testing a workflow like below, only one connection appears to have been used as per mongodb.com’s monitoring:

Example Workflow

I am not sure how the node (and the library it’s using) would manage connections behind the scenes though, so I’ve asked the team for help on this one.

Hi @Mustafa_Ali, I can now confirm connections are not being re-used by n8n, instead a new connection is created for each operation.