Pergunta

Eu estou codificação um aplicativo Merb que utiliza uma combinação de SimpleDB e Tokyo Tyrant para armazenamento. Para ambos os armazenamentos de dados Estou implementando IN (lista) tipo funcionalidade, girando-se um fio para cada valor no lista e, em seguida, a fusão dos conjuntos de resultados. Tendo em conta que esta é uma aplicação web, há um limite para o número de threads que eu deveria estar criando? Ruby 1.8.7, então eles não são tópicos do kernel.

Foi útil?

Solução

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.

Outras dicas

To me your problem sounds IO bound, so multi threading a single core may help out.

Most of the time in your main Ruby loop you will probably be waiting on tokyo tyrant and simple DB which are running in separate multi-threaded process.

So how many threads? Who knows? You are going to have to benchmark and measure.

If you are using MRI then using threads in such cases won't be of a big help as MRI uses green threads that are not helpful when it comes to computational operations. I believe using JRuby(native threads) will be helpful then. I keep hearing that for native threads it's best to use (number of cores + 1) to make use of the available cores.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top