P
💻DeveloppementAdvancedAll AIs

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

Adapt this prompt

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:

  1. Project structure. Show how to organize files for workers, jobs, and configuration.
  2. Job definitions. Write classes or functions for each job type, with strong typing, payload validation, and serialization.
  3. Queue configuration. Set up separate queues by priority and job type, and configure concurrency.
  4. Main worker. Show the worker code and its lifecycle, including startup, graceful shutdown, and SIGTERM/SIGINT handling.
  5. Retries. Set up exponential backoff, a dead-letter queue, and a maximum number of attempts.
  6. Error handling. Use structured try/catch blocks, contextual logging, and alerts for critical failures.
  7. Monitoring. Track pending jobs, processing times, and failure rates. Add a health check endpoint.
  8. Scheduling. Configure recurring or cron jobs declaratively.
  9. Tests. Include example unit tests for jobs and integration tests for the full workflow.
  10. 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

Set up a background transactional email sending systemCreate an image processing or PDF generation pipelineOrchestrate periodic synchronizations with third-party APIsImplement a reliable and monitored scheduled tasks (cron jobs) system

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 Optimizer

Comments

Be the first to comment on this prompt.

📬 Get new prompts every week

Join our newsletter and never miss a prompt.

Go further

Similar Prompts

💻DeveloppementIntermediateClaude

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.

1681
💻DeveloppementIntermediateClaude

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.

640
💻DeveloppementAdvancedAll AIs

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.

411
💻DeveloppementIntermediateAll AIs

Generate Storybook Stories for UI Components

Generate Storybook stories for a UI component, with visual variants, interactive controls, interaction tests, and MDX documentation.

474