Skip to content

Exercise 1: Implement Redis Outage Circuit Breaker #4

Description

@harsharajkumar-273

Goal

Enhance the resilience of the API Ingestion Gateway by implementing a fallback mechanism.

Problem

Currently, if Redis crashes or loses network connectivity, redis.get() in src/middleware/auth.ts throws an unhandled error, resulting in an HTTP 500 status and halting all metric ingestions.

Task

  1. Wrap Redis cache lookup and sets in src/middleware/auth.ts inside a try/catch block.
  2. On connection error, log the failure as a warning and query PostgreSQL directly to validate the API key.
  3. Design a simple in-memory LRU or Map cache to store key validations locally for 30 seconds to prevent DB connection pool exhaustion during a Redis outage.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions