现在测试了500个并发的时候,持续3分钟,当连接数达到25000以后才会出现nginx报错99,直接没有代理到node来,node我感觉唯一可能造成该问题的是使用到了redis,我把redis写成了单例模式的。 求教下是我nginx配置有问题还是node连redis有问题呢 nginx
worker_processes 8; events { worker_connections 1024; } server { listen 80; server_name 暂时不公开 #charset koi8-r; #access_log logs/host.access.log main; location / { proxy_pass http://127.0.0.1:3000; proxy_redirect off; } redis连接 var express = require(‘express’); var config = require("…/lib/config.js"); var redis = require(‘redis’); //var client = redis.createClient(‘6379’, config.Redis.Redis);
var Singleton = (function(){ var uniqueInstance; function constructor(){ var privateAttr = “”; function privateMethod(){} return {} } return { getInstance: function(){ if(!uniqueInstance){ console.log(‘openclient’); uniqueInstance =redis.createClient(‘6379’, config.Redis.Redis); uniqueInstance.on(“error”, function (error) { console.log(error); });
}
return uniqueInstance;
}
}
})();
module.exports.client = Singleton.getInstance();
求帮忙解决下,随便问下用pm2开4个node怎么搞啊,我用nginx进行4个负载会咋样呢