使用 Redis 作为 socket.io 内存存储有什么好处,是否需要额外的资源。我正在使用 MongoDB 作为数据库,我可以使用 MongoDB 作为 Socket.io 的内存存储,还是将 MongoDB 替换为 Redis 作为数据库?对于构建实时 Web 应用程序和提供最大并发连接数,什么会更有效?
最佳答案
can i use MongoDB as memory store for Socket.io
Yes, you can try mong.socket.io
do i replace MongoDB with Redis as database?
Redis 和MongoDB 是不同类型的数据库,而mongodb 是面向文档的redis 是面向key/value 的(我们甚至可以说redis 是一个数据结构服务器)。
What would be more efficient for building a real-time web app and providing maximum concurrent connections?
Redis 在这方面肯定比 mongo 快,它支持开箱即用的 pub/sub(而 mong.socket.io 使用集合来模拟 pub/sub)但是你必须知道你所有的数据都存储在 redis 中必须存在于内存中(这里唯一存储在 redis 中的数据将是额外的 socket.io 信息)。
关于node.js - 使用 Socket.io 的 Redis 存储,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21658278/