Create Async Workers and Jobs with AI
A complete prompt to design and implement async workers and jobs with queuing, retry, monitoring and deployment.
Paste in your AI
Paste this prompt in ChatGPT, Claude or Gemini and customize the variables in brackets.
You are a software architect who specializes in distributed systems and asynchronous processing. Design a complete architecture for background workers and asynchronous jobs in my project.
Project context:
- Language and framework: [LANGUAGE_AND_FRAMEWORK]
- Preferred queue system: [QUEUE_SYSTEM] (e.g., Redis/BullMQ, RabbitMQ, SQS, Celery, Sidekiq, or recommend the best fit)
- Job types: [JOB_TYPES] (e.g., sending emails, generating PDF reports, processing images, syncing with a third-party API)
- Estimated volume: [ESTIMATED_VOLUME] jobs per hour
- Constraints: [CONSTRAINTS] (e.g., maximum run time, guaranteed ordering, required idempotency)
Cover the following:
- Project structure. Show how to organize files for workers, jobs, and configuration.
- Job definitions. Write classes or functions for each job type, with strong typing, payload validation, and serialization.
- Queue configuration. Set up separate queues by priority and job type, and configure concurrency.
- Main worker. Show the worker code and its lifecycle, including startup, graceful shutdown, and SIGTERM/SIGINT handling.
- Retries. Set up exponential backoff, a dead-letter queue, and a maximum number of attempts.
- Error handling. Use structured try/catch blocks, contextual logging, and alerts for critical failures.
- Monitoring. Track pending jobs, processing times, and failure rates. Add a health check endpoint.
- Scheduling. Configure recurring or cron jobs declaratively.
- Tests. Include example unit tests for jobs and integration tests for the full workflow.
- Deployment. Provide a worker Dockerfile, horizontal scaling configuration, and environment variables.
Provide complete, commented, production-ready code for each section. Explain your design choices and trade-offs.
Personalize this prompt with Léa · AI assistant
Léa rewrites this prompt for your job and your exact goal — 3 quick questions.
Why this prompt works
This prompt lets you generate a complete asynchronous processing architecture tailored to your tech stack. By specifying your language and framework, queue system and job types, the AI produces production-ready code covering the entire job lifecycle. The key variables to customize are the queue system (BullMQ for Node.js, Celery for Python, Sidekiq for Ruby) and the job types specific to your business. The estimated volume helps the AI adapt concurrency configuration and scaling recommendations. The prompt covers aspects often neglected but critical in production: graceful worker shutdown to prevent job loss, idempotency to handle retries without side effects, and dead letter queues to isolate permanently failed jobs. Use it as a starting point then iterate on each section based on your needs.
Use Cases
Expected Output
A complete architecture with structured source code: typed job definitions, queue configuration with priorities, worker with graceful shutdown, retry mechanism with exponential backoff, monitoring with metrics, deployment Dockerfile, and test examples.
Improve this prompt
Run this prompt through the Optimizer to strengthen its context, constraints and expected format.
Improve this prompt with the OptimizerComments
Be the first to comment on this prompt.
Glossary Terms
📬 Get new prompts every week
Join our newsletter and never miss a prompt.
Go further
Improve this prompt with the Optimizer
Analyze the prompt, strengthen the context and get a more precise version.
Prompt Engineering
Cross-model principles for writing more reliable prompts.
AI prompts for web developers
Code review and debugging, keeping API keys and secrets out of the prompt.
Security, GDPR & Business Plans
ChatGPT Business, Claude Team, Gemini Workspace and Mistral Vibe compared from vendor sources: training, EU hosting and a GDPR checklist.
Similar Prompts
Task brief for Claude Code: frame a feature end to end
Brief template to delegate a complete feature to Claude Code: goal, starting point, constraints, definition of done, working rules and recap format.
Write a project's CLAUDE.md: the brief Claude Code reads at every session
Turns your project description into a dense CLAUDE.md: commands, structure, conventions, pitfalls, off-limits areas and situations where the agent must ask before acting.
Design a Secure Webhook API
Design a webhook API with event subscriptions, signed deliveries, retry limits, and a delivery log your support team can inspect.
Generate Storybook Stories for UI Components
Generate Storybook stories for a UI component, with visual variants, interactive controls, interaction tests, and MDX documentation.