3 ways to make your Web pages more responsive with Sidekiq
Sidekiq is a powerful background job processor for Ruby. It makes it easy to use separate processes to execute long-running jobs. It uses the concepts of workers, jobs and queues.
Queue highly computational tasks
If you have business logic that is taking more than hundreds of milliseconds, you should think about offloading it to a background process. Think about a video that after having been uploaded by a user, needs to be converted, filtered and transcoded again. Ever heard about Youtube? That is a classic case in which you should use Sidekiq:
Queue everything that doesn’t need real-time
If you have stuff that doesn’t take a lot of time to compute, but at a high volume might steal some precious milliseconds from your server page loading time, you might want to move less essential stuff to the background. For example, indexing Elasticsearch documents for Rails models:
Embrace asynch
Try to design your architecture in a way that promotes asynchronous data exchanges more than synchronous. The reason is simple: get back to the user with the answer she wants as fast as possible and also limit the number of concurrent requests your decoupled background services have to satisfy. Take into consideration a notification system for your website:
Learn more at Sidekiq’s Wiki page.
Did you like this?
If you liked this article, keep an eye my upcoming book about Rails 5 APIs. Register your interest here: http://goo.gl/forms/sOsrw5Ebcw