Skip to content

perf: bound flush() latency with per-event timeout and concurrent sends #64

@beonde

Description

@beonde

Problem

flush() now sends events individually (one POST per event) to match the server's flat db.Event struct. With batch_size=10 and the default httpx 10s timeout, a single flush could block for up to ~100s in the worst case if the registry is slow or unreachable.

The old batch approach had the same 10s timeout but for a single request. In practice the registry responds in <100ms so this isn't a production issue today, but it's a latent risk.

Proposed improvements

  1. Per-event timeout — reduce from inherited 10s to ~2s for event ingestion POSTs
  2. Concurrent sends — use a thread pool or asyncio.gather to send events in parallel rather than sequentially
  3. Overall deadline — cap total flush duration regardless of event count (e.g., 5s total)

Context

From reviewer comment on PR #63: #63 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions