Yandong Liu
Yandong Liu

Reputation: 345

generic-pool vs. pooling of node-mysql

I am writing a small Web app with node.js + MySQL and wondering which is a better choice for connection pooling. So far I discovered two options: connection pooling from node-mysql (https://github.com/felixge/node-mysql#pooling-connections) as well as node-mysql+generic-pool (https://github.com/coopernurse/node-pool). Both seem to serve the same purpose and I am just wondering if you happen to have experience with both, which one did you choose and why?

Upvotes: 3

Views: 4107

Answers (1)

JakubKnejzlik
JakubKnejzlik

Reputation: 6483

Well, it depends on how much control You need. Few months ago I've been using generic-pool+node-mysql, because I've struggled with some issues when using mysql-pool, but now it seems to work fine. Anyway if You need control over one of these:

  • min/max number of connections
  • connection destroy timeout
  • queueing priorities (check generic-pool priority queueing)
  • connection validation before acquiring

One advantage (it could be disadvantage also) with node-mysql pool is that you can get error callback when limit of maximum number of connections is reached. This should be useful when You deal with server overload and it's better to tell the client that the system is down(than let him wait – please correct me if generic-pool supports acquire timeout, couldn't find it anywhere). And also there's less of coding :).

Upvotes: 3

Related Questions