Skip to content

Implement request deduplication for concurrent API calls #224

@RUKAYAT-CODER

Description

@RUKAYAT-CODER

Background

Rapid navigation or user actions trigger multiple identical API calls concurrently. Request deduplication tracks in-flight requests and returns same promise, reducing redundant calls by 40-60% and server load proportionally.

Description

Currently, identical API calls execute concurrently if triggered rapidly, causing unnecessary network traffic and server overload. Implement deduplication by tracking in-flight requests.

Current Behavior

User navigates rapidly or retriggers fetch → 5+ identical API calls execute

Expected Behavior

Identical in-flight calls return same promise. Redundant calls prevented.

Impact

📉 Reduce API calls by 40-60% in typical workflows
🚀 Lower server load
⚡ Faster response times from reduced network congestion

Acceptance Criteria

  • Create RequestDeduplicator utility
  • Track in-flight requests by method + URL + params
  • Return same promise for duplicate requests
  • Cancel request if no active subscribers after 5s
  • Reduce redundant API calls by 50%+ in typical workflows
  • Add comprehensive unit tests with timing scenarios
  • Monitor duplicate call rates in analytics
  • Document deduplication strategy in API docs

Implementation Hints

Use Map to track requests. Key = method + URL + JSON.stringify(params). Value = Promise. Use AbortController for cancellation.

Performance Metrics

Before:

  • apiCalls: 15 calls per workflow

After (Target):

  • apiCalls: 6 calls per workflow (-60%)

Related Issues

Metadata

Metadata

Assignees

No one assigned

    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