Using Puma and Sidekiq in a backend Rails application

I have a backend Rails server with Sidekiqthat serves as an API server. The application works as follows:

  • The My Rails server receives many requests from incoming API clients at the same time.

  • For each of these requests, the Rails server will distribute jobs to the Sidekiq server. The Sidekiq server makes requests to external APIs (for example, Facebook) to receive data, and also analyzes them and returns the result to the Rails server.

For example, if I receive 10 inbound requests from my API clients, for each request I need to make 10 requests to external API servers, receive data and process it.

My task is to make my application respond to incoming requests at the same time. That is, for each incoming request, my application must be processed in parallel: make calls to external APIs, receive data and return the result.

Now I know that Puma can add a concurrency application to Rails, and Sidekiq can be multithreaded.

My question is: do I really need Sidekiq if I already have Puma? What are the benefits of using Puma and Sidekiq?

In particular, with Puma, I just call external API calls, data processing, etc. from my Rails application, and they will automatically be parallel.

+4
source share
2 answers

, , , Puma Sidekiq. .

Concurrency ( , ) - -, . , Puma Unicorn, concurrency, - .

- , -.

, , , , , , , . , 100 . - 10 . 5 , 50 . 500 , 2 reqs/sec 10 reqs/sec 5 .

API- , . Sidekiq - ( ) API. , API - 2 . 2,5 / 5 . , , , , , API, - API . .

Sidekiq , API -. , Sidekiq , " ". Sidekiq . , , . -, , . . ( , " ?", .)

, . , .

+6

Sidekiq, Resque Delayed Job, .

, , ( ) Sidekiq.

( , - , ), Sidekiq , , . Sidekiq ; , , , . , , .

+4

All Articles