Ruby on Rails with IMAP IDLE for multiple accounts
There is no need to spawn a new thread for each IMAP session. These can be done in a single thread.
Maintain an Array (or Hash) of all users and their IMAP sessions. Spawn a thread, in that thread, send IDLE keep-alive to each of the connections one after the other. Run the loop periodically. This will definitely give you far more concurrency than your current approach.
A long term approach will be to use EventMachine. That will allow using many IMAP connections in the same thread. If you are processing web requests in the same process, you should create a separate thread for Event Machine. This approach can provide you phenomenal concurrency. See https://github.com/ConradIrwin/em-imap for Eventmachine compatible IMAP library.
How to listen a huge number of IMAP folders of differnet accounts in one thread?
Use the JavaMail IdleManager.
Related Topics
Rails Way to Detect Mobile Device
Active Record with Delegate and Conditions
Does Ruby Support Unicode and How Does It Work
Run a Cli Thor App Without Arguments or Task Name
How to Beautify Xml Code in Rails Application
How to Create Temp Dir in Ruby
Dynamically Create Class Attributes with Attr_Accessor
How to Determine Leap Year in Ruby
Cross-Platform Means of Getting User's Home Directory in Ruby
Rails 3: User Created Custom Forms
Rails - Paperclip Validating Attachment Size When It Shouldn't Be
Install Rvm "Bash /Root/.Rvm/Scripts/Rvm No Such File or Directory"
Using Acts_As_List with Has_Many :Through in Rails
Xpath to Find All Following Siblings Up Until the Next Sibling of a Particular Type