wvanbergen / node-vertica

Pure javascript Vertica database client. Except it is written in CoffeeScript.
MIT License
44 stars 30 forks source link

connection best pracrtices #6

Closed yaronn closed 12 years ago

yaronn commented 12 years ago

I use node-vertica in an express web app.

Is it better to open one connection per the whole app (e.g. mongo style)? Or open the connection whenever I need it (postgress style)?

wvanbergen commented 12 years ago

I wouldn't suggest to using one connection, because you can only run one query at the time per connection. This is bad if you want to use node's parallelism. Depending on your use case I would do one of the following:

runk commented 12 years ago

If you use the express framework, I think it's a good point in using build-in cluster module in node. So then you'll have N workers and each of them will do their own tasks and has its own connection. When one worker in the waiting state and working with vertica connection others can handle new requests and perform them independently.

wvanbergen commented 12 years ago

I updated the README to include some of this info and added some more documentation.