Asynchronous Processing

Overview of asynchronous processing patterns used on the Journals.

Introduction

We use asynchronous processing patterns throughout the system. There are 3 primary areas where it’s particularly useful:

  • Batch processing including shipping and report generation
  • Subscription purchase and renewal
  • Scheduling

Batch Processing

Asychronous processing allows processing of large datasets in manageable chunks, preventing server overload and maintaining system stability. It also allows that processing to continue in the background, letting the user move on to other tasks whist e.g. shipping batches are pulled or large reports processed.

Subscription Purchase

Subscription purchase and renewal require considerable processing in addition to standard checkout & payment capture processes. Copies owed, deferred amounts, entitlements, expiry groups, gift handling, Klaviyo integrations, and potentially perk assignments all need to be handled.

To avoid delaying the checkout experience for the customer and not blocking the main thread, we run these additional processes asynchronously. They fire a few seconds / minutes after the customer has checked out.

Scheduling

Asynchronous processing also allows us to schedule events, e.g. we use it to handle delayed notifications to gift recipients, to distribute renewal order processing evenly throughout the AR day (to limit processor overload), and to run scheduled reports such as the overnight duplicate detection report without the need for admin interaction.

Action Scheduler

The Action Scheduler library underpins the bulk of our asychronous processing tasks. The library essentially extends the WordPress hook & action system with support for actions that fire:

  • When the processor next becomes idle
  • Or, after a scheduled period of time

It additionally supports recurring actions, retries, error logging and monitoring.

Originally developed by WooCommerce, it has become a widely adopted solution for handling asynchronous operations in WordPress applications


Table of contents