Using arangojs npm Database as a persistent connection

153 Views Asked by At

When creating an arangodb connection with the arangojs npm module via something like :

function createConnection(connectionUrl, databaseName) {
   var connectionProps = {
      url: connectionUrl,
      databaseName: databaseName
    };
    var connection = new Database(connectionProps);
    callback(null, connection);
 }

Is this Database object intended to live for the lifetime of the application or is it a one time connection?

We are experiencing a memory leak as we are creating a new connection for every query, "caching" the connection seems to solve this leak.

If the connection lives forever, does it behave like a connection pool? Will these connections time out if idle?

The documentation leads me to believe that I was originally wrong and that yes, it is a connection pool but confirmation of the above questions would be excellent!

1

There are 1 best solutions below

0
On

From our own investigations it looks as though, yes, this object is intended to live "forever" and be reused over and over again since it is created using an agent. It could probably be configured to be a "one time connection" depending on the agentOptions that are passed in. This has not been tested and may be an expensive operation for frequently used connections.