使用 Ruby 加速 IPC
我正在尝试在 Ruby 中的同一个 Linux 机器上的 2 个进程之间进行 IPC,并且我需要尽可能优化解决方案。
我开始使用 TCPSocket,但我发现使用 UNIXSocket 可能更快,并且也许不会将数据复制到内核缓冲区。
我一直在阅读 SO 线程,看起来 mmap 可能会很有趣。但对于 mmap,我需要 a) 安装 mmap gem 和 b) 提供锁定,因为多个客户端进程可能会尝试与服务器进程连接(都在同一个盒子上运行)。
我的问题:
- 您会推荐哪些其他选择?
- 您建议如何使用 ruby mmap 锁定内存?
- UNIXSocket 与 mmap 的数字(如果有的话)如何叠加?
I am trying to do IPC between 2 processes on the same Linux box in Ruby, and I need to optimize the solution as far as practicable.
I had begun with a TCPSocket but I see that using UNIXSocket is probably faster, and perhaps does not copy data to kernel buffers.
I have been reading SO threads, and looks like mmap might be interesting to look at. But for mmap I need to a) install mmap gem and b) provide locking since multiple client processes would likely try connect with the server process (both running on same box).
My questions:
- What other options would you recommend?
- How do you recommend locking the memory with ruby mmap?
- How do the numbers, if there's any available, stack up for UNIXSocket versus mmap?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论