Sidekiq可以利用多个CPU核心吗?

时间:2021-08-28 08:59:51

I am new to Sidekiq and use it with Ruby on Amazon EC2 instances to do some work using ImageMagick with images.

我是Sidekiq的新手,并在Amazon EC2实例上使用Ruby来使用ImageMagick和图像做一些工作。

While running it I realized that every worker runs on the same core. I use EC2 c3.2xlarge machines and they have 8 cores. It shows CPU usage is 15% but one core used 100%, and the others are using 0%.

在运行它时,我意识到每个工作者都在同一个核心上运行。我使用EC2 c3.2xlarge机器,它们有8个核心。它显示CPU使用率为15%,但一个核心使用100%,其他核心使用0%。

Can Sidekiq use different CPU cores for different workers? If it can, is this inefficiency caused by ImageMagic and how can I make it to use other cores?

Sidekiq可以为不同的工作人员使用不同的CPU内核吗?如果可以的话,ImageMagic会导致效率低下吗?如何才能使用其他内核?

1 个解决方案

#1


17  

If you want to utilize multiple cores using MRI, you'll need to start multiple Sidekiq processes; having multiple threads configured for your sidekiq instance is not enough.

如果您想使用MRI来利用多个核心,您需要启动多个Sidekiq进程;为sidekiq实例配置多个线程是不够的。

So if you wanted to use all 8 cores, you would start 8 processes. They will all feed off of the same queue, so there's no need to worry about jobs being processed multiple times.

因此,如果您想使用所有8个核心,您将启动8个进程。它们都将从相同的队列中获取,因此无需担心多次处理作业。

#1


17  

If you want to utilize multiple cores using MRI, you'll need to start multiple Sidekiq processes; having multiple threads configured for your sidekiq instance is not enough.

如果您想使用MRI来利用多个核心,您需要启动多个Sidekiq进程;为sidekiq实例配置多个线程是不够的。

So if you wanted to use all 8 cores, you would start 8 processes. They will all feed off of the same queue, so there's no need to worry about jobs being processed multiple times.

因此,如果您想使用所有8个核心,您将启动8个进程。它们都将从相同的队列中获取,因此无需担心多次处理作业。