Skip to main content
Engineering Case Study

PythPal Oracle Cache & Proxy

Go service for Pyth price-feed access over REST and Server-Sent Events

backendScope L3

1. At a glance

PythPal is a Go proxy that consumes Pyth Hermes price updates, maintains an in-memory cache, and serves updates over REST and Server-Sent Events (SSE). It is an open-source backend service; no unverified latency or throughput figures are claimed here.

2. Why it existed

Trading services and dashboards reading multiple price feeds benefit from sharing one resilient upstream connection to Pyth Hermes rather than opening redundant upstream subscriptions per client process.

3. Contribution

Sole author in Go across the Hermes stream subscriber, concurrent in-memory cache, REST query handlers, and SSE fanout broadcaster.

4. System Shape & Architecture

System Architecture SchematicPYTHPAL // SVG
Pyth HermesPrice feed streamGo Proxy ServiceIn-memory cacheREST + SSEConsumersHTTP clients
Pyth Hermes updates feed a Go cache and are exposed to downstream HTTP clients.

5. Technical Decisions & Tradeoffs

Separating an in-memory snapshot cache (for on-demand REST lookups) from an async broadcast loop (for SSE subscribers) ensures point reads remain lock-cheap while streaming clients receive updates immediately as Hermes events land.

6. Challenges & how I solved them

Connection resilience

Recovering upstream Hermes streams without dropping subscribers

If an upstream Pyth Hermes SSE connection drops or times out, connected downstream clients risk hanging indefinitely or flooding upstream endpoints on simultaneous reconnects.

How I Solved It
Centralized upstream subscription management in a supervised Go goroutine with automatic reconnect backoff while keeping downstream HTTP/SSE client channels alive and serving explicitly typed snapshot state.

Fanout isolation

Preventing slow SSE consumers from blocking the price cache

In a naive broadcast loop, one stalled downstream HTTP subscriber can delay cache writes for all healthy readers sharing the same update cycle.

How I Solved It
Gave each SSE subscriber an independent buffered delivery channel with non-blocking dispatch and explicit stale-client cleanup so slow consumers are isolated from the shared price store.

7. Verification & Security

The public repository is the source for current implementation and test coverage. No numerical test or latency claim is included without a dated, reproducible source.

8. Outcome & Metrics

The repository demonstrates a Go service that connects Pyth Hermes updates with REST and SSE interfaces. No production deployment or scale claim is made here.

9. Reflection & Lessons Learned

Streaming systems have to handle upstream availability and downstream delivery as separate concerns. A local cache can give request-based clients a simple interface while an event stream serves consumers that need updates as they arrive.

10. Explore Source & Artifacts