Search code examples
rubymultithreadingmerb

How many Ruby threads is too many?


I'm coding a Merb application which uses a combination of SimpleDB and Tokyo Tyrant for storage. For both of these data stores I'm implementing IN (list) type-functionality by spinning up a thread for each value in list and then merging the result sets. Bearing in mind that this is a web application, is there a limit to the number of threads I should be creating? Ruby 1.8.7, so they're not kernel threads.


Solution

  • Threads seems like a bad approach for what you're trying to do here, and if you can't use JRuby, I'd just drop the threads altogether. However, you could create a ruby file loading the database and use the benchmark library to do some benchmarking on which number is the fastest. You probably want to look at the memory used too.