High Performance In-Memory Nostr Relay
- WebSocket-based Nostr relay protocol support on
/ - Nostr message framing (EVENT, REQ, EOSE, NOTICE, OK, ERROR, CLOSED)
- Event parsing from Nostr JSON
- In-memory event storage with LRU eviction
- Event indexing by pubkey, kind, and tag references
- Subscription management with filters (kinds, authors, e-tags, p-tags, since/until)
- HTTP information endpoint at
/info - Optional disk persistence for events (JSONL format)
- Integration tests
The subscription manager uses a query plan that picks the most selective index first:
- IDs - exact match, most selective
- e-tags - referenced events
- p-tags - referenced pubkeys
- authors - event creators
- kinds - event types
All filters within a single REQ are combined with AND logic.
cargo build --releasecargo run --releaseThe relay will start on 0.0.0.0:8080 by default.
Create a config.yaml file:
bind_addr: "0.0.0.0:8080"
target_ram_percent: 80
max_bytes: 0
max_subscriptions: 300
max_limit: 5000Or use environment variables:
MEMLAY_BIND_ADDR="0.0.0.0:8080" ./target/release/memlayEnable event persistence to survive restarts:
# Save events to this directory
persistence_path: "/var/lib/memlay/data"
# Auto-save interval in seconds (default: 60)
persistence_interval: 60Events are saved as JSONL (one JSON event per line) with atomic writes for crash safety.
/- WebSocket upgrade for Nostr protocol/info- Relay information (name, description, supported NIPs)
cargo testcargo run --releaseThen connect with a Nostr client using WebSocket to ws://localhost:8080/