Skip to content

[FEAT]: Async Background Task Queue for PDF ProcessingΒ #230

@krrishrastogi05

Description

@krrishrastogi05

πŸ“ Description

PDF fill operations in FireForm are currently synchronous and block the API thread for the entire duration of the request. This becomes a critical bottleneck under concurrent load β€” e.g., multiple departments submitting forms simultaneously.

πŸ’‘ Rationale

For FireForm to scale as a Digital Public Good, it cannot afford to have a single long-running PDF fill block the server. An async job system decouples submission from processing, enabling parallel workloads and a better UX via status polling.

πŸ› οΈ Proposed Solution

  • Introduce an async job queue using arq or asyncio background tasks integrated with FastAPI's BackgroundTasks
  • On form submission, immediately return a job_id with a 202 Accepted response
  • Add a GET /api/v1/jobs/{job_id} status endpoint returning { status, result, error }
  • Store job state in Redis (for arq) or in-memory (for lightweight asyncio approach)
  • Update Docker Compose to include Redis if needed

βœ… Acceptance Criteria

  • POST /api/v1/fill returns { job_id, status: "queued" } immediately
  • GET /api/v1/jobs/{job_id} returns current status (queued, processing, complete, failed)
  • Multiple simultaneous submissions are processed concurrently without blocking
  • Works within the existing Docker container setup
  • Testable via Swagger UI (/docs)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions