Skip to content

TaskiqAdminMiddleware adds significant latency to task triggering #8

@nimaxin

Description

@nimaxin

The TaskiqAdminMiddleware significantly slows down task triggering (.kiq()) because it blocks execution waiting for HTTP requests to complete. Each task operation creates a new HTTP client httpx.AsyncClient() instead of reusing one, adding unnecessary overhead.

The middleware should:

  1. Avoid blocking task operations while reporting status
  2. Reuse HTTP connections where possible httpx.AsyncClient()
  3. Handle reporting asynchronously without impacting task throughput

This becomes particularly noticeable when triggering many tasks rapidly (e.g., in loops or batch operations). The current implementation forces sequential HTTP requests, making bulk task triggering much slower than expected.

I believe the problem is clear, but I'm happy to provide code examples or additional details if needed.

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