From 2510a47262cdfaebf00eedb9d2b21437b29888a9 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Tue, 29 Jan 2013 17:36:50 +0100 Subject: [PATCH] Add maxConnection environment configuration, have it default to 128 The number gives the maximum number of contemporary connections and is dimensioned on the limit of open file descriptors found to be needed on a per-connection basis. --- app.js | 8 ++++++++ cluster.js | 3 +++ config/environments/development.js.example | 3 +++ config/environments/production.js.example | 3 +++ config/environments/staging.js.example | 3 +++ config/environments/test.js.example | 3 +++ 6 files changed, 23 insertions(+) diff --git a/app.js b/app.js index f432a617..aee614d2 100755 --- a/app.js +++ b/app.js @@ -33,7 +33,15 @@ var Windshaft = require('windshaft'); var serverOptions = require('./lib/cartodb/server_options'); ws = CartodbWindshaft(serverOptions); + +// 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 +// 1 is good if you have max 16 filedescriptors +ws.maxConnections = global.environment.maxConnections || 128; + ws.listen(global.environment.port, global.environment.host); + ws.on('listening', function() { console.log("Windshaft tileserver started on " + global.environment.host + ':' + global.environment.port); }); diff --git a/cluster.js b/cluster.js index d5501d17..74f7361a 100755 --- a/cluster.js +++ b/cluster.js @@ -36,6 +36,9 @@ var serverOptions = require('./lib/cartodb/server_options'); var ws = CartodbWindshaft(serverOptions); +// Maximum number of connections for one process (see apps.js) +ws.maxConnections = global.environment.maxConnections || 128; + //.use(cluster.logger('logs')) //.use(cluster.stats()) //.use(cluster.pidfiles('pids')) diff --git a/config/environments/development.js.example b/config/environments/development.js.example index 8d5bb5a9..27509b2a 100644 --- a/config/environments/development.js.example +++ b/config/environments/development.js.example @@ -2,6 +2,9 @@ var config = { environment: 'development' ,port: 8181 ,host: '127.0.0.1' + // Maximum number of connections for one process + // 128 is a good value with a limit of 1024 open file descriptors + ,maxConnections:128 // idle socket timeout, in miliseconds ,socket_timeout: 600000 ,enable_cors: true diff --git a/config/environments/production.js.example b/config/environments/production.js.example index fb9ef4b3..5d73f79e 100644 --- a/config/environments/production.js.example +++ b/config/environments/production.js.example @@ -2,6 +2,9 @@ var config = { environment: 'production' ,port: 8181 ,host: '127.0.0.1' + // Maximum number of connections for one process + // 128 is a good value with a limit of 1024 open file descriptors + ,maxConnections:128 // idle socket timeout, in miliseconds ,socket_timeout: 600000 ,enable_cors: true diff --git a/config/environments/staging.js.example b/config/environments/staging.js.example index dedb5001..366401e2 100644 --- a/config/environments/staging.js.example +++ b/config/environments/staging.js.example @@ -2,6 +2,9 @@ var config = { environment: 'production' ,port: 8181 ,host: '127.0.0.1' + // Maximum number of connections for one process + // 128 is a good value with a limit of 1024 open file descriptors + ,maxConnections:128 // idle socket timeout, in miliseconds ,socket_timeout: 600000 ,enable_cors: true diff --git a/config/environments/test.js.example b/config/environments/test.js.example index 096acb03..a9db586f 100644 --- a/config/environments/test.js.example +++ b/config/environments/test.js.example @@ -2,6 +2,9 @@ var config = { environment: 'test' ,port: 8888 ,host: '127.0.0.1' + // Maximum number of connections for one process + // 128 is a good value with a limit of 1024 open file descriptors + ,maxConnections:128 // idle socket timeout, in miliseconds ,socket_timeout: 600000 ,enable_cors: true