İyi bir oturum tek ana bilgisayar node.js üretim uygulaması için mağaza nedir?
Düğümün Express w/ katman Connect kullanıyorum. Connect hafıza oturum deposu üretim için uygun değildir:
Warning: connection.session() MemoryStore is not designed for a production environment, as it will leak memory, and obviously only work within a single process.
Büyük dağıtımları için, mongo veya redis mantıklı.
Ama üretimde tek ana bilgisayar uygulaması için iyi bir çözüm nedir?
CEVAP
Kabul cevabı uzak ana bilgisayarlara bağlanıyor sadece bu yana, localhost göre her zaman daha yavaş olacağı açıktır. Eğer evinize gelecek bilgisayarı varsa bile, milisaniye o bilgisayardan okumak için alır, ama yerel bellek sadece nanosaniye sürer. Yerel olarak yüklü sunucuları kullanarak bunları karşılaştırmak gerekir.
İşte benim yerel pc benim sonuçlar: Görüyorsunuz ya, redis-bellek kadar hızlı, yüksek yük altında. Benim bu test kodları kullanılabilir repo klon olabilir: https://github.com/mustafaakin/express-session-store-benchmark
Concurrency: 1
none 4484.86 [#/sec]
memory 2144.15 [#/sec]
redis 1891.96 [#/sec]
mongo 710.85 [#/sec]
Concurrency: 10
none 5737.21 [#/sec]
memory 3336.45 [#/sec]
redis 3164.84 [#/sec]
mongo 1783.65 [#/sec]
Concurrency: 100
none 5500.41 [#/sec]
memory 3274.33 [#/sec]
redis 3269.49 [#/sec]
mongo 2416.72 [#/sec]
Concurrency: 500
none 5008.14 [#/sec]
memory 3137.93 [#/sec]
redis 3122.37 [#/sec]
mongo 2258.21 [#/sec]
Oturum kullanılan sayfalar çok basit sayfaları;
app.get("/", function(req,res){
if ( req.session && req.session.no){
req.session.no = req.session.no 1;
} else {
req.session.no = 1;
}
res.send("No: " req.session.no);
});
Redis mağaza config:
app.use(express.session({
store: new RedisStore({
host: 'localhost',
port: 6379,
db: 2,
}),
secret: 'hello'
}));
Mongo mağaza config:
app.use(express.cookieParser());
app.use(express.session({
store: new MongoStore({
url: 'mongodb://localhost/test-session'
}),
secret: 'hello'
}));
Android uygulaması kullanıcı ayarların...
Node.js için Haskell yanıtı nedir?...
OS X için en iyi Düzeni veya LİSP uygu...
Oturum ele geçirme önlemek için en iyi...
Bir çıkış için komut C Konsol uygulama...