arangodb / arangojs

The official ArangoDB JavaScript driver.
https://arangodb.github.io/arangojs
Apache License 2.0
600 stars 106 forks source link

Simulataneous multiple db connections with a single arangodb server #752

Closed gitgkk closed 2 years ago

gitgkk commented 2 years ago

Hello All, I'd like to know if a feature/API exists to manage simultaneous connections to multiple databases at the same time. It is a useful feature to build diverse applications. I started the discussion here [https://stackoverflow.com/questions/69687128/connecting-to-multiple-databases-with-arangodb] If it does not exist, I believe it must be created to facilitate easy management of data from the ground up rather than users trying to find work around architectural solutions. Thanks.

pluma commented 2 years ago

If you mean having references to multiple databases using the same connection pool, you can do that using db.database:

https://arangodb.github.io/arangojs/7.6.0/classes/database.database-1.html#database

gitgkk commented 2 years ago

Hello @pluma, Thanks for the comment. I suppose you've seen the stack overflow link embedded in the original question. So by your response, I understand that we can use this API to connect to multiple databases on the same server. Correct me if I'm wrong. Referring back to the architecture that I need for my product, following questions arise

  1. How many databases can be created on a single server instance?
  2. How many parallel connections can be maintained to a server instance?
  3. How many parallel connections can be maintained to a database?
  4. What is the performance benchmark on database swapping for executing a query?
pluma commented 2 years ago

@gitgkk If you have questions about ArangoDB rather than the JS driver, I would recommend asking in our Community Slack: https://slack.arangodb.com

Depending on your scenario you might also want to look into ArangoDB's commercial developer support for a more in-depth consultation: https://www.arangodb.com/contact/

pluma commented 2 years ago

To clarify my earlier reply: the JS driver uses node's http or https module, which keeps open previously used TCP connections using keep-alive. This means the driver does not directly maintain a list of open connections but node may re-use connections on subsequent requests for performance as the driver will use the same socket pool.

If you perform requests while other requests are still pending, the driver will add them to an internal queue that is consumed as earlier requests are fulfilled. You can adjust the number of sockets the driver will use based on what works best for your specific performance profile. Configuring ArangoDB to be able to handle the number of requests you need is out of the scope of this driver's documentation. The default settings in the driver are intended to be safe defaults if the server configuration is unknown.

gitgkk commented 2 years ago

@pluma I agree with your remark to ask on arangodb community. Sorry about asking a more general question about arangodb. Quite frankly, I did ask on stack overflow, slack "general", I'm not getting any answers and therefore limited the scope of discussion in context to the driver of interest. I haven't found the information I'm looking for in the documentation. I'm disappointed to see that there's not much help.

Thanks for pitching in and sharing insight on internal details of driver implementation.

gitgkk commented 2 years ago

Posted the question on arangodb.