Ruby on Rails Background Jobs with Sidekiq
Run Code Later without Complicating Your App
by: David Bryant Copeland
Published | 2023-10-18 |
---|---|
Internal code | dcsidekiq |
Print status | In Print |
Pages | 79 |
User level | Intermediate |
Keywords | Ruby, Rails, Ruby on Rails, sidekiq, parallel, concurrency, web applications, big data, async, asynchronous |
Related titles | Agile Web Development with Ruby on Rails. |
ISBN | 9798888650363 |
Other ISBN |
Channel epub: 9798888650547 Channel PDF: 9798888650554 Safari: 9798888650530 |
BISACs | COM051410 COMPUTERS / Programming Languages / RubyCOM060150 COMPUTERS / Web / User Generated ContentCOM060150 COMPUTERS / Web / User Generated Content |
Highlight
Using Sidekiq for background jobs is a great way to scale and grow your app. This book will give you a solid, practical foundation for creating resilient, well-tested, self-healing code that uses background jobs. You’ll be able to simulate real-world failure modes and learn how to write idempotent code that can be safely run with Sidekiq.
Description
One of the best ways to improve your Rails app’s performance is to use background jobs with Sidekiq. While Sidekiq is easy to get set up, you need to do more than just move code around to reap the benefits. In this book, you’ll get solutions to what sort of code should go into a Sidekiq job and how to manage those jobs.
You’ll create a Sidekiq configuration that will serve as a solid foundation for your app, including how to be notified when jobs inevitably fail. You’ll then tame alerting fatigue by designing idempotent jobs that can be safely retried in the face of the types of transient failures that are common in networked applications, all without alerting you until action is needed. With that foundation, you’ll get a conceptual framework for general monitoring and alerting around your Sidekiq installation and the Redis database it uses, as well as practical tips for organizing the code around your Sidekiq jobs. You’ll also learn valuable testing strategies for code that uses Sidekiq jobs.
In no time at all you’ll build a Rails app using Sidekiq that is efficient, manageable, and sustainable.
Contents and Extracts
- Preface
- Introduction
- What You’ll Need
- What You’ll Learn
- From Zero To a Sustainable Sidekiq Config
- Setting Up the Example App and Installing Sidekiq
- Creating a Baseline Sidekiq Configuration
- Moving Code to a Sidekiq Job
- Up Next
- Handle Failures by Planning Ahead
- Making Sure Jobs Succeed…Eventually
- Understanding Why Jobs Fail
- Handling Permanent Failures via Monitoring
- Managing Transient Failures Through Smarter Code
- Monitoring for Failed Jobs That Stop Retrying
- Up Next
- Safely Retry Jobs by Making Them Idempotent
- Retrying Failed Jobs Creates New Failures
- Understanding Idempotence
- Breaking Down Large Jobs into Safely Retriable Parts
- Addressing Idempotence Issues with Third Parties
- Testing Code for Idempotency
- Assessing Code for Idempotency
- Using Database Transactions Can Help…Sometimes
- Up Next
- Sustainable Operations and Development
- Monitoring Sidekiq Performance
- Using Queues and Concurrency to Control Performance
- Organizing Sidekiq Job Code
- Additional Topics to Explore Next
- Wrapping Up