Report to statsd the status of redis pools

This commit is contained in:
Raul Ochoa 2014-10-14 22:12:35 +02:00
parent 9f5faf7cf8
commit 804088009e
6 changed files with 25 additions and 4 deletions

View File

@ -1,6 +1,9 @@
1.19.1 -- 2014-mm-dd
--------------------
New features:
- Report to statsd the status of redis pools
Enhancements:
- Share one redis-mpool across the application

14
app.js
View File

@ -70,10 +70,7 @@ if ( global.environment.rollbar ) {
log4js.configure(log4js_config, { cwd: __dirname });
global.logger = log4js.getLogger();
var redisOpts = _.extend(global.environment.redis, {
name: 'windshaft_cartodb',
reportInterval: 5000
}),
var redisOpts = _.extend(global.environment.redis, { name: 'windshaft' }),
redisPool = new RedisPool(redisOpts);
// Include cartodb_windshaft only _after_ the "global" variable is set
@ -83,6 +80,15 @@ var CartodbWindshaft = require('./lib/cartodb/cartodb_windshaft'),
ws = CartodbWindshaft(serverOptions);
if (global.statsClient) {
redisPool.on('status', function(status) {
var keyPrefix = status.name + '.db' + status.db + '.';
global.statsClient.gauge(keyPrefix + 'count', status.count);
global.statsClient.gauge(keyPrefix + 'unused', status.unused);
global.statsClient.gauge(keyPrefix + 'waiting', status.waiting);
});
}
// Maximum number of connections for one process
// 128 is a good number if you have up to 1024 filedescriptors
// 4 is good if you have max 32 filedescriptors

View File

@ -108,6 +108,9 @@ var config = {
slowPool: {
log: true, // whether a slow acquire must be logged or not
elapsedThreshold: 25 // the threshold to determine an slow acquire must be reported or not
},
emitter: {
statusInterval: 5000
}
}
,sqlapi: {

View File

@ -102,6 +102,9 @@ var config = {
slowPool: {
log: true, // whether a slow acquire must be logged or not
elapsedThreshold: 25 // the threshold to determine an slow acquire must be reported or not
},
emitter: {
statusInterval: 5000
}
}
,sqlapi: {

View File

@ -102,6 +102,9 @@ var config = {
slowPool: {
log: true, // whether a slow acquire must be logged or not
elapsedThreshold: 25 // the threshold to determine an slow acquire must be reported or not
},
emitter: {
statusInterval: 5000
}
}
,sqlapi: {

View File

@ -102,6 +102,9 @@ var config = {
slowPool: {
log: true, // whether a slow acquire must be logged or not
elapsedThreshold: 25 // the threshold to determine an slow acquire must be reported or not
},
emitter: {
statusInterval: 5000
}
}
,sqlapi: {