Search code examples
ruby-on-railsjbosstorquebox

Trying to set TorqueBox Backgroundable concurrency, but it doesn't look like it's working?


So, I'm trying to use deployment descriptors in TorqueBox, by having a file (in my rails app) under config called torquebox.yml

The file itself contains:

---
application:
  root: /usr/local/labs/live_management
  env: development

tasks:
  Backgroundable:
      concurrency: 9

Which as far as I can tell is correct.

However, I don't know what this file is supposed to do... When I do rake torquebox:deploy it LOOKS like it still writes the default app_name-knob.yml file to the torquebox directory, which does NOT have my concurrency descriptors in it, and the documentation says that the external file has precedence.

Under that it appears that I can only have ONE background task at a time.

So I tried copying my torquebox.yml file to the Torquebox application directory, renaming it to be the app_name-knob.yml file.

This SEEMS to help, because now I have TWO background tasks at a time (even though I specified 9).

What am I doing wrong? Is my file incorrect, some how? Can Torquebox only have 2 background tasks?

What is the right way to use torquebox.yml as an internal descriptor?


Solution

  • You're almost there. The issue is due to the way TorqueBox sets up its runtime pools of Ruby interpreters. In the development environment, which you've specified in your internal descriptor, the default messaging runtime pool has a maximum of 2, so regardless of your concurrency setting, the maximum number of simultaneous tasks you'll ever see backgrounded is 2.

    In the production environment, the default pool is shared, meaning the same runtime is shared by however many threads try to use it, in your case, a maximum of 9. So either set your env variable to production, or add a pools element to your descriptor to force it shared. For example,

    ---
    application:
      root: /usr/local/labs/live_management
      env: development
    
    tasks:
      Backgroundable:
          concurrency: 9
    
    pooling:
      messaging: shared
    

    BTW, values from your external and internal descriptors are merged, with the external one taking precedence for any keys in common between the two. So you were doing that correctly.

    For more info, http://torquebox.org/documentation/1.0.1/pooling.html