HARP logo

Storage

HARP needs somewhere to keep the traffic it records. It runs with no setup for evaluation, and on PostgreSQL in production, optionally with Redis for message content.

Default: in-memory

With no configuration, HARP keeps what it records in an in-memory SQLite database, so you can try it without standing up a database. Only the memory of the HARP process limits its size, and its content is lost at shutdown. Its single connection also runs database operations in turn, never in parallel. That is convenient for development and testing, not for production: point HARP at a database there.

Production setup

PostgreSQL is the database for production. Set storage.url to it, with the harp-proxy[postgresql] extra installed. With the default blob storage, that is all.

toml
[storage]
url = "postgresql+asyncpg://user:password@localhost:5432/harp"

[janitor]
old_after = 30 # days, 60 by default

[proxy]
max_recorded_body_size = "4MiB" # 1 MiB by default

HARP records at most proxy.max_recorded_body_size of each request and response body. The cap, and the number of days the Janitor, HARP's background cleanup task, keeps transactions, are the two knobs on the volume of what it stores.

When blob writes load the SQL database, you can move blobs to Redis. This is optional:

toml
[storage.blobs]
type = "redis"

[storage.redis]
url = "redis://localhost:6379/0" # the default, set it to point elsewhere

Redis must be reachable. HARP starts without checking it, and drops without a log line the blobs it cannot write: the dashboard then shows transactions without headers or bodies. With Redis, nothing purges the blobs: they grow without bound, so size and watch your Redis.

Switching an existing install to Redis blobs moves no blob. The history recorded before the switch loses its headers and bodies in the dashboard, and its SQL blobs are no longer purged, so they outlive janitor.old_after. Choose the blob backend before recording, or reset the database with harp-proxy db:reset.

Pointing HARP at PostgreSQL starts from an empty database: no command copies the data of an SQLite database over. MySQL and MariaDB still work but are deprecated since 0.12.

How data is stored

HARP separates two layers:

  • Core storage keeps transactions, messages, users, tags and favorites in a SQL database through SQLAlchemy.
  • Blob storage holds the raw content of messages, their headers and bodies. It is content-addressable, so a payload repeated across thousands of transactions is stored only once, saving space. By default it reuses the SQL database; Redis is the alternative when blob writes load it.

Retention

Once the storage is persistent, the Janitor, HARP's background cleanup task, deletes recorded transactions after 60 days by default (set with janitor.old_after) and keeps those marked as favorite; with Redis blob storage, it deletes the transactions but not their headers and bodies. With SQL blob storage, it also deletes the blobs nothing references anymore.

The traffic history page tells what is recorded and what can be left out.