Hi Adam, I think a uniform, easy-to-use, reliable way of doing background processing would be a killer feature on Heroku, and I have come to realize that the lack thereof is a major weakness of Rails.
The code I have been working on in a webservice backend for a mobile app, a simple chat server with some extra functionality. Not the most common Rails use case. I was attracted by Rails' RESTful API, but discovered some drawbacks, of which the difficulty of doing asynchronous processing was the largest. > It would be helpful if you could tell me more > about exactly what you're trying to do, so that we can include your > requirements into our design. I came up against three different needs of background tasks: 1) Perform calls to a remote web service in the background so as not to block main app; this task can take up to 30-60 secs, and basically unlimited parallel tasks should be allowed. 2) Run a background task that wakes up every x seconds (15 in my case) to remove users that have lost connection from the server from the db. There can be only *one* of there tasks. 3) Run a background task that performs jobs based on requests that have been stored in the db. In my case, I let this process sleep for 2 seconds before checking for jobs that have been stored in the db. Only *one* of these as well. Because the requirements of each of these were different, I couldn't find a single plugin that would do it all. (Workling for example wouldn't let me do 1, as there can be only one worker of a particular kind.) Some frameworks looked good, but required too much configuration and didn't work out of the box. I ended up implementing each of the above using the Spawn gem. But then I ran into problems with spawned processes surviving between invocations of the Rails environment, so that I got too many background tasks interfering with each other. And so I implemented a scheme to keep track of pids and only spawn new processes when necessary, kill processes when needed etc. Unfortunately, as I described in my first post, this didn't work on Heroku, for the reasons that you rightly pointed out. So, if you can come up with something that can let me do each of 1, 2, 3 above, in an easy way, I would be more than satisfied! I would like to be able to create workers, and specify the minimum and maximum number of each that should be available. Some should be monitored so that, if they die, a new one should be spawned immediately. I would also like timing to be built in (something like rufus-scheduler). Ability to work off a job queue on the db should also be part of the deal. Thanks for considering my needs! /Felix --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Heroku" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/heroku?hl=en -~----------~----~----~----~------~----~------~--~---
