Skip to content

[Performance] SMS log aggregator holds up to 5,000 records in memory with no persistence #737

Description

@RUKAYAT-CODER

Overview

src/lib/logging/sms-aggregator.ts stores all SMS log records in a module-level array capped at 5,000 entries. In a high-volume SMS scenario this consumes significant heap memory, and all data is lost on server restart — making it impossible to query historical delivery metrics or troubleshoot past failures.

Specifications

Features:

  • SMS logs are written to a persistent store (database or append-only log file)
  • In-memory buffer is small (e.g., 100 entries) for fast recent-query access only

Tasks:

  • Add a database table sms_logs with columns for all fields tracked by the aggregator
  • Flush the in-memory buffer to the database on a configurable interval or when the buffer reaches capacity
  • Update query methods to fall back to database queries for historical data

Impacted Files:

  • src/lib/logging/sms-aggregator.ts
  • src/lib/db/ (new migration)

Acceptance Criteria

  • SMS logs survive a server restart
  • Historical queries beyond the in-memory buffer hit the database
  • Memory usage does not grow with SMS volume

Metadata

Metadata

Assignees

Labels

Type

No type

Fields

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