I am developing a node.js application and I really need to use Redis. The application will cluster ed through 8 processor cores.
Now I have 100 simultaneous connections to Redis, because each worker on one processor has several modules with require('redis').createClient() .
Scenario A:
file1.js:
var redis = require('redis').createClient();
file2.js
var redis = require('redis').createClient();
SCENARIO B:
redis.js
var redis = require('redis').createClient(); module.exports = redis;
file1.js
var redis = require('./redis');
file2.js
var redis = require('./redis');
Which approach is better: creating a new Redis instance in each new file that I present (scenario A), or creating one Redis connection worldwide (scenario B) and sharing this connection in all of my modules. What are the disadvantages / advantages of each solution?
Thanks in advance!
Pono
source share