Running Sneakers workers on Kubernetes

Allow Sneakers to receive SIGTERM

  1. Stop consuming the queue
  2. Finish any work that’s in progress on messages that have already been pulled from the queue.
  3. Terminate
command: ["bundle", "exec", "rake", "sneakers:run"]
command: ["/bin/sh", "-c", "WORKERS=MyWorker rake sneakers:run"]
- name: WORKERS
value: MyWorker

Increase the grace period

terminationGracePeriodSeconds: 180

Application level shutdown handling

class MyWorker
include Sneakers::Worker
from_queue :my_queue,
durable: true,
exchange: 'domain_events',
exchange_options: { type: :topic },
prefetch: 100,
threads: 1,
routing_key: [:EVENT_HAPPENED]
def work(message)
@counter += 1

return ack! unless @counter >= 10_000

@counter = 0
def stop




Software engineer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Bridging the Gap Between Businesses and Developers

My way of working with internal nuget packages

How to Love Poetry

Going Serverless With Google Cloud Functions For Beginners

Network Setup where you can ping Google but not able to ping Facebook from the same system

How I design JSON API responses

Interactive password validation UX in Flutter using Flare (2Dimensions)

What You Should Know Before You Start Programming

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Chris Harrison

Chris Harrison

Software engineer

More from Medium

Cluster Autoscaler for higher scalability ( K8s Part 2)

EKS Anywhere., PART-1 Dell EMC Unity-XT CSI version 2.2.0

Reverse engineering of a Helm chart

Open Application Model (OAM) — Bringing some sanity to application deployment on kubernetes (k8s).