0

We have a Rails application, which interfaces with iOS and web clients. Currently we are spawning subprocesses from a Rails controller using Open3 to retrieve and send data to a chat server, which running node.js with MongoDB. However, after a few days in production, we found out that the subprocesses made our Rails app very slow and increased the CPU usage by a lot.

We know that the long-term solution is to wrap our chat server with a REST API framework such as Express. But for the short term, we'd like to have a quick fix on how to make our subprocesses execute faster (spawning, execution etc.).

Any ideas?

uohzxela
  • 613
  • 4
  • 14
  • 28

1 Answers1

1

This is a very common problem(sending messages in the background), but your solution is not very efficient. Process management is hard. So in general, you want to have a background job processor or some sort of message queue. Zeromq, redis, delayed job, etc... Of course, doing the REST API framework is preferable, but it is not the only solution. Here are some options to consider:

For super speed, you can use something like:

http://zeromq.org/

For general background job processing:

https://www.ruby-toolbox.com/categories/Background_Jobs

Bassel Samman
  • 802
  • 5
  • 11