Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在瘦服务器上有机架 Faye 应用程序,我在每个 faye 客户端握手/订阅/断开连接上都有一些逻辑。
这个逻辑需要在数据库中存储数据,进行一些计算并将消息发布回一些通道。
应该在哪里以及如何实现这些东西以避免阻塞主 Faye 线程与扩展?
Faye的作者在这里。取决于您正在与之交谈的数据库,但通常您应该使用非阻塞(即基于 EventMachine 的 TCP 堆栈)数据库客户端。这意味着扩展将快速返回(假设您没有等待 DB 调用的结果来影响传入/传出消息),因此 Faye 可以在 DB 调用正在进行时继续处理消息。