We are currently performing event processing in FIFO order in our Rails application using a queue in Sidekiq. Due to some reasons - cost and some other benefits - we are moving from Sidekiq to Shoryuken(with SQS FIFO queue).
Currently, we are using the Sidekiq worker at concurrency: 1
so that it processes one job at a time and maintains FIFO order.
SQS FIFO Queue will also handle this for us after we migrate to Shoryuken.
My problem is this - How do I migrate from Sidekiq to Shoryuken without any downtime but at the same time also maintain the FIFO order of processing of my events. There are 5 parallel Rails Puma instances that publish the events to Sidekiq or will publish to SQS. Restarting all 5 of them at the same time won't ensure that no event will be published to Sidekiq after at least one event is published to SQS. To explain the issue I have described an example as follows:
Example:
- I would want to start publishing events to SQS instead of Sidekiq from t=0.
- I would then want that events queued in Sidekiq before t=0 should be processed in order and only then should we start processing events from the SQS queue.
- Suppose we restart all the Puma servers together, Puma 1 finishes restarting first and publishes an event to SQS, but by this time due to some reason Puma 2 has still not restarted and pushes a subsequent event to Sidekiq.
How do I avoid this?
Any sort of help or suggestion is appreciated. Thanks in advance!