Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upAllow to use a pool of connection to PostgreSQL #97
Conversation
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
|
Ping ! |
JohnMcLear
merged commit 7b268b8
into
Pita:master
Oct 4, 2017
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
muxator
Oct 4, 2017
Contributor
Hi,
using the connection pool is awesome.
The two drivers are really similar: since we already bumped the pg version, shouldn't we simply port the changes in the old driver and remove the duplicated code?
$ diff --ignore-space-change --unified postgres_db.js postgrespool_db.js--- postgres_db.js 2017-10-05 00:45:45.977646205 +0200
+++ postgrespool_db.js 2017-10-05 00:45:45.977646205 +0200
@@ -25,8 +25,12 @@
this.settings.writeInterval = 100;
this.settings.json = true;
- this.db = new pg.Client(this.settings);
- this.db.connect();
+ // Pool specific defaults
+ this.settings.max = this.settings.max || 20;
+ this.settings.min = this.settings.min || 4;
+ this.settings.idleTimeoutMillis = this.settings.idleTimeoutMillis || 1000;
+
+ this.db = new pg.Pool(this.settings);
}
@@ -179,10 +185,5 @@
exports.database.prototype.close = function(callback)
{
- var _this = this;
- this.db.on('drain', function() {
- _this.db.end.bind(_this.db);
- callback(null);
- });
-
+ this.db.end()
}|
Hi, using the connection pool is awesome. $ diff --ignore-space-change --unified postgres_db.js postgrespool_db.js--- postgres_db.js 2017-10-05 00:45:45.977646205 +0200
+++ postgrespool_db.js 2017-10-05 00:45:45.977646205 +0200
@@ -25,8 +25,12 @@
this.settings.writeInterval = 100;
this.settings.json = true;
- this.db = new pg.Client(this.settings);
- this.db.connect();
+ // Pool specific defaults
+ this.settings.max = this.settings.max || 20;
+ this.settings.min = this.settings.min || 4;
+ this.settings.idleTimeoutMillis = this.settings.idleTimeoutMillis || 1000;
+
+ this.db = new pg.Pool(this.settings);
}
@@ -179,10 +185,5 @@
exports.database.prototype.close = function(callback)
{
- var _this = this;
- this.db.on('drain', function() {
- _this.db.end.bind(_this.db);
- callback(null);
- });
-
+ this.db.end()
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ldidry commentedMay 18, 2017
UeberDB currently use only one connection to PostgreSQL, which is insufficient for our high-traffic Etherpad instances.
This commit include a bump of pg dependency version and a new db connector,
postgrespool.It has been tested in production on several instances, one of it hosting more than 44,000 pads and heavily used.