Skip to content

Instantly share code, notes, and snippets.

@ryansmith3136
Created January 23, 2012 05:03
Show Gist options
  • Select an option

  • Save ryansmith3136/1660752 to your computer and use it in GitHub Desktop.

Select an option

Save ryansmith3136/1660752 to your computer and use it in GitHub Desktop.
The Worker Pattern

The Worker Pattern

Contents

  • Introduction
  • Definition
  • Examples
  • Credits

Introduction

The modern application developer has undoubtedly dealt with the problem of process execution locality. More precisely, when responding to HTTP requests, developers must carefully balance what work is to be done in the process handling the request and the work that can be done in a process outside of the HTTP request. The Worker Pattern exists to help strike such a balance.

In this article, we will define the pattern and look at several applications of the pattern. However, before we dive in, a quick note on how to successfully grok this material. The fundamental idea of the Worker Pattern is and should always be simple. Much like mathematical techniques, the definition is quite simple and the application is not alway clear. However, with sufficient exposure to examples and with enough practice, the pattern becomes a reflex for the application developer.

Definition

Processor: Something that can execute instructions. Not a physical processor, thread, coroutine, etc...

Group of Computation: One or many atomic instructions.

The Worker Pattern: To divide a group of computations amongst a set of processors.

Examples

Dispatch

Append Only Log

Fork

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment