简体   繁体   English

在Node.js应用的多个实例之间共享同一会话

[英]Sharing same session across multiple instances of nodejs app

I have an app written in nodejs and express, we have used passport js for auth. 我有一个用nodejs编写并表达的应用程序,我们使用了护照js进行身份验证。 What I'm looking for is to share the session across multiple nodejs instances. 我正在寻找的是在多个nodejs实例之间共享会话。 So there is one app which will run on different ports ie instances. 因此,有一个应用程序可以在不同的端口(例如实例)上运行。

Is there any better way with Redis? Redis有更好的方法吗? If any of you have implemented something similar then do let me know. 如果你们中有人实施了类似的方法,请告诉我。 Thanks 谢谢

Any fast storage, Redis is the best, but also memcache, even mysql if you want to pay with some I/O. 任何快速存储,Redis都是最好的,但也是memcache,甚至是mysql(如果您想通过一些I / O付费)。 Another non-recommended way to resolve it is to configure the load-balancer/NGINX to have sticky session, so same user will always reach the same server. 解决该问题的另一种非推荐方法是将负载均衡器/ NGINX配置为具有粘性会话,因此同一用户将始终访问同一服务器。 It will be the cheapest way to resolve it, but i don't recommend on statefull servers 这将是解决问题的最便宜的方法,但是我不建议在全状态服务器上使用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM