Communitygithub.com

YepAPI/스킬

BullMQ/Inngest/Trigger.dev를 사용한 큐 워커, 작업 재시도, 데드 레터 큐, 동시성 제어

스킬란 무엇인가요?

이 스킬은 Node.js 기반 애플리케이션에서 백그라운드 작업(job)을 안정적으로 처리하기 위한 모범 사례와 패턴을 제공합니다. BullMQ(자체 호스팅 Redis) 또는 Inngest와 Trigger.dev(서버리스/관리형) 플랫폼을 활용하여 이메일 전송, 이미지 처리, 웹훅, AI 호출 등 느린 작업을 API 요청 처리에서 분리합니다. 모든 작업은 멱등성을 보장하고 지수 백오프(3~5회 시도)로 재시도하며, 최대 재시도 후에는 데드 레터 큐(DLQ)로 이동시켜 작업 손실을 방지합니다. 큐별 동시성 제한, 우선순위 분리(critical/default/low), 큐 깊이 및 처리 시간 모니터링을 통해 워커 과부하를 방지하고 시스템 안정성을 높입니다. 주요 코드 패턴은 BullMQ와 Inngest의 실제 구현 예제를 포함하고 있습니다.

지원 대상~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/YepAPI/skills/tree/HEAD/skills/background-jobs

즐겨 사용하는 AI에게 물어보기

이 에이전트 스킬이 미리 로드된 새 채팅을 엽니다.

문서

백그라운드 작업

규칙

  • 느린 작업은 백그라운드 작업으로 오프로드: 이메일, 이미지 처리, 웹훅, 보고서, AI 호출
  • BullMQ는 자체 호스팅 Redis 큐에 사용 — Inngest 또는 Trigger.dev는 서버리스/관리형 환경
  • 모든 작업은 멱등성을 가져야 함 — 재시도 시 부작용 없이 안전하게 처리 (멱등성 키 사용)
  • 지수 백오프를 사용하여 재시도: 3-5회 시도, 지연 시간 1초, 10초, 60초, 5분
  • 데드 레터 큐(DLQ): 최대 재시도 후 DLQ로 이동하여 조사 — 절대 자동으로 삭제하지 않음
  • 큐별 동시성 제한 설정 — 워커 과부하 방지 (예: concurrency: 5)
  • 작업 페이로드는 작게 유지: 전체 객체 대신 ID와 참조 전달
  • 큐를 우선순위별로 분리: critical (결제), default (이메일), low (분석)
  • 큐 깊이 및 처리 시간 모니터링 — 큐가 쌓이면 알림 전송

패턴

// BullMQ 패턴
import { Queue, Worker } from "bullmq";
const queue = new Queue("이메일", { connection: redis });

await queue.add("환영", { userId }, {
  attempts: 3,
  backoff: { type: "exponential", delay: 1000 },
});

const worker = new Worker("이메일", async (job) => {
  await sendWelcomeEmail(job.data.userId);
}, { connection: redis, concurrency: 5 });
// Inngest 서버리스 패턴
import { inngest } from "./client";

export const sendEmail = inngest.createFunction(
  { id: "send-welcome-email", retries: 3 },
  { event: "user/created" },
  async ({ event }) => { await sendWelcomeEmail(event.data.userId); }
);

피해야 할 사항

  • API 요청 핸들러에서 느린 작업 처리 — 빠르게 응답하고 백그라운드에서 처리
  • 멱등성이 없는 작업 — 중복 실행 시 이중 청구, 이중 이메일 발생
  • 무제한 동시성 — 데이터베이스 연결과 메모리를 고갈시킴
  • 작업 큐에 큰 페이로드 저장 — 대신 참조 전달

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

YepAPI/skills

WCAG 2.1 AA — semantic HTML, keyboard navigation, screen readers.

YepAPI/skills

Experiment setup, variant splitting, statistical significance, and feature flag integration.

YepAPI/skills

CRUD generators, data tables, user management, role-based access, and bulk operations.

YepAPI/skills

Monitor what ChatGPT and Gemini say about your brand using YepAPI.

YepAPI/skills

Commander.js, interactive prompts with Clack, spinners, colors, config files, exit codes, and npm publishing.

YepAPI/skills

cmdk integration, Cmd+K trigger, fuzzy search, grouped actions, keyboard navigation, and dynamic action registration.

YepAPI/skills

Content planning with trend and sentiment data from YepAPI.

YepAPI/skills

Content calendar, keyword-driven planning, and content briefs.

YepAPI/skills

Theme switching with CSS variables, system preference detection, next-themes, and persistence.

YepAPI/skills

Threaded comments, @mentions, reactions, moderation queue, optimistic UI, and cursor pagination.

YepAPI/skills

Competitive analysis between domains using YepAPI.

YepAPI/skills

Layout grids, KPI cards, data tables with sorting/filtering, sidebar navigation, and responsive breakpoints.

YepAPI/skills

Data encryption — TLS everywhere, AES-256-GCM for PII, bcrypt passwords, encrypted backups.

YepAPI/skills

Chart patterns with Recharts/Nivo/D3, responsive containers, color scales, and accessibility.

YepAPI/skills

Drizzle schema definition, push vs migrate, type-safe queries, relations, transactions, and prepared statements.

YepAPI/skills

Upload handling, resize/compress, CDN delivery, blur placeholders, and next/image patterns.

YepAPI/skills

Local business and Google Maps research using YepAPI.

YepAPI/skills

Cursor-based pagination, IntersectionObserver, virtualized lists with @tanstack/react-virtual, and scroll position restoration.

YepAPI/skills

Tenant isolation (row-level vs schema), subdomain routing, per-tenant config, and data partitioning.

YepAPI/skills

Chat UI components, streaming responses with AI SDK, context window management, and RAG patterns.

관련 스킬