Background Job Processing

Background Job Processing

Guides an AI agent to build background job systems with task queues, workers, scheduling and retries, using Celery, Bull and Sidekiq.

Skill files8 files

references/

scripts/

templates/

SKILL.md105 lines
1
---
2
name: background-job-processing
3
description: >
4
Implement background job processing systems with task queues, workers,
5
scheduling, and retry mechanisms. Use when handling long-running tasks,
6
sending emails, generating reports, and processing large datasets
7
asynchronously.
8
---
9
10
# Background Job Processing
11
12
## Table of Contents
13
14
- [Overview](#overview)
15
- [When to Use](#when-to-use)
16
- [Quick Start](#quick-start)
17
- [Reference Guides](#reference-guides)
18
- [Best Practices](#best-practices)
19
20
## Overview
21
22
Build robust background job processing systems with distributed task queues, worker pools, job scheduling, error handling, retry policies, and monitoring for efficient asynchronous task execution.
23
24
## When to Use
25
26
- Handling long-running operations asynchronously
27
- Sending emails in background
28
- Generating reports or exports
29
- Processing large datasets
30
- Scheduling recurring tasks
31
- Distributing compute-intensive operations
32
33
## Quick Start
34
35
Minimal working example:
36
37
```python
38
# celery_app.py
39
from celery import Celery
40
from kombu import Exchange, Queue
41
import os
42
43
app = Celery('myapp')
44
45
# Configuration
46
app.conf.update(
47
broker_url=os.getenv('REDIS_URL', 'redis://localhost:6379/0'),
48
result_backend=os.getenv('REDIS_URL', 'redis://localhost:6379/0'),
49
task_serializer='json',
50
accept_content=['json'],
51
result_serializer='json',
52
timezone='UTC',
53
enable_utc=True,
54
task_track_started=True,
55
task_time_limit=30 * 60, # 30 minutes
56
task_soft_time_limit=25 * 60, # 25 minutes
57
broker_connection_retry_on_startup=True,
58
)
59
60
# Queue configuration
61
default_exchange = Exchange('tasks', type='direct')
62
app.conf.task_queues = (
63
// ... (see reference guides for full implementation)
64
```
65
66
## Reference Guides
67
68
Detailed implementations in the `references/` directory:
69
70
| Guide | Contents |
71
|---|---|
72
| [Python with Celery and Redis](references/python-with-celery-and-redis.md) | Python with Celery and Redis |
73
| [Node.js with Bull Queue](references/nodejs-with-bull-queue.md) | Node.js with Bull Queue |
74
| [Ruby with Sidekiq](references/ruby-with-sidekiq.md) | Ruby with Sidekiq |
75
| [Job Retry and Error Handling](references/job-retry-and-error-handling.md) | Job Retry and Error Handling |
76
| [Monitoring and Observability](references/monitoring-and-observability.md) | Monitoring and Observability |
77
78
## Best Practices
79
80
### ✅ DO
81
82
- Use task timeouts to prevent hanging jobs
83
- Implement retry logic with exponential backoff
84
- Make tasks idempotent
85
- Use job priorities for critical tasks
86
- Monitor queue depths and job failures
87
- Log job execution details
88
- Clean up completed jobs
89
- Set appropriate batch sizes for memory efficiency
90
- Use dead-letter queues for failed jobs
91
- Test jobs independently
92
93
### ❌ DON'T
94
95
- Use synchronous operations in async tasks
96
- Ignore job failures
97
- Make tasks dependent on external state
98
- Use unbounded retries
99
- Store large objects in job data
100
- Forget to handle timeouts
101
- Run jobs without monitoring
102
- Use blocking operations in queues
103
- Forget to track job progress
104
- Mix unrelated operations in one job
105

© AJ Geddes · MIT · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 14,621 prompts

More by @OpenSourceBuffGuy

See all
Sea turtle carrying floating film studio island prompt image

Sea turtle carrying floating film studio island

Draws a giant sea turtle carrying a floating island film studio through a starry sky, where fairies polish rough film strips into golden film.

image-prompt, nano-banana, 3d-render, cartoon, fantasy-world, creatures, animals, whimsical, dreamy, cinematic, dramatic-lighting, vibrant-colors, bokeh, miniature, widescreen, night-scene, illustration, concept-art, surreal, storytelling, clay-3d

Desert buggy escapes drones past industrial outpost prompt image

Desert buggy escapes drones past industrial outpost

Builds a 15-second desert chase video where a racer in an armored buggy escapes drones past an industrial outpost, using five reference images with set jobs.

video-prompt, hailuo, action, multi-shot, timed-beats, camera-movement, reference-image, character-consistency, negative-prompt, cinematic, sci-fi, cars, landscape, aerial-view, tracking-shot, photorealistic, sound-effects, structured-output, long-form, widescreen

1 view
Cozy Pixel Art Farm Island Village prompt image

Cozy Pixel Art Farm Island Village

Draws a cozy 16-bit pixel-art farming village across six small islands joined by bridges, with exact counts for buildings, animals and crops.

image-prompt, gpt-image, pixel-art, isometric, game-assets, concept-art, maps, worldbuilding, cozy, vibrant-colors, ocean, landscape, wide-shot, widescreen, game-development, video-games, structured-output, whimsical, summer, high-angle, aerial-view, animals, negative-prompt, cityscape

1 view

Reviews

Loading reviews…

Discussion

Loading comments…