DEV Community

Rivenor85
Rivenor85

Posted on

Live Auction Bidding API — 3 Realtime Rules for Fairness

TL;DR: Accept every bid through the application's normal API, commit one authoritative order on the server, and use the realtime channel only to broadcast the accepted high bid. Include a monotonically increasing sequence number in each broadcast so viewers can detect a gap and fetch current state. For scoped video-room tokens, the client may receive and render auction updates, but it must never be trusted to decide which bid won.

This division also controls the observability bill. The dominant term is usually not the number of dashboards; it is event volume multiplied by bytes per event and retention time. Recording every client receive, reconnect, and rendered frame can turn one accepted bid into hundreds of stored observations. Start with the state transition that settles money, then decide which delivery evidence is worth retaining.

How should a small SaaS team approach a live auction realtime API?

Nothing about bid priority. A bidder's request travels through the authoritative API, where the server orders it and either accepts or rejects it. Message arrival order at a browser is not evidence of global order: two viewers can have different network paths, reconnect at different moments, or receive a replay after fresh traffic.

The channel announces. It does not adjudicate.

The accepted record should carry an auction identifier, the accepted high bid, and a sequence number assigned by the server. The channel broadcasts that committed state. If a client holds sequence 418 and next sees 420, it knows that its local view is incomplete; it should fetch the current authoritative state rather than infer what sequence 419 contained.

That is the first trust boundary. A scoped room token authorizes narrowly defined participation in the live video experience, while bid acceptance remains behind the normal application API. Token possession does not confer ordering authority. The browser is a display and input surface, not the auction ledger.

This remains true even when an optimistic interface makes the bidder's own number appear immediately. Label that state as pending. Replace it only after the API returns the accepted result, and let the subsequent broadcast reconcile every other viewer. Fast feedback is useful; invented finality is not.

Count accepted transitions before collecting delivery noise

Let A be accepted bid transitions per day, B the average stored bytes for one authoritative transition, and D the retention period in days. The first-order storage estimate is A x B x D. If 80,000 accepted transitions per day produce 700-byte records and are retained for 30 days, the raw payload estimate is 1.68 GB before indexing, replication, or platform overhead. This is arithmetic for capacity planning, not a measured vendor bill.

Now add delivery telemetry. Suppose each accepted transition fans out to 250 connected viewers and the application stores one 300-byte client receipt for every viewer. The daily receipt payload is 80,000 x 250 x 300 bytes, or 6 GB per day. The authoritative transitions themselves are only 56 MB per day. In this illustrative workload, receipt volume dominates before indexes are counted.

Keep the distinction sharp. Server-side acceptance records answer who won and in what order. Publish acknowledgements answer whether the broadcast system accepted work. Client receipts answer whether particular devices observed it. Those are different questions with different retention values.

I would retain the authoritative transition longer than high-volume delivery detail, because it protects auction correctness. Short-lived aggregate delivery metrics can still reveal broad degradation. Sampled client diagnostics can preserve examples of device and network behavior without storing a row for every fan-out edge.

Cardinality deserves its own budget. Labels such as region, client version, transport, and outcome have bounded operational value. Labels such as user ID, room ID, auction ID, request ID, or token ID can create a new time series for nearly every event. Keep those identifiers in structured logs when investigation requires them; do not casually promote them to metric labels.

Count first.

Sampling changes what you can prove

Sampling should follow the question. Keep 100% of accepted and rejected bid decisions, including the server sequence and a correlation identifier, because sampling that ledger weakens correctness analysis. Aggregate publish counts and latency distributions. Sample ordinary client delivery diagnostics, while retaining all gap detections and reconciliation failures during their shorter investigation window.

A practical policy can be expressed without pretending one retention period fits every team:

Signal Collection choice Retention intent What it can establish
Accepted or rejected bid decision Keep every event Longest of the set Server decision and sequence
Realtime publish result Keep counts; sample detail Medium Broadcast submission health
Client receive event Sample ordinary receipts Short Examples of delivery behavior
Sequence gap Keep every event Medium A client observed missing state
Per-auction metric label Do not create it None Avoids unbounded series growth

The trade-off is real. A 1% sample of routine receipts may be enough to observe common patterns, but it cannot prove that a particular viewer received sequence 419. For that question, the sequence-gap event and the client's state refresh are more useful than a vast receipt archive. Increase sampling temporarily for a bounded investigation rather than making exceptional telemetry permanent.

Do not place raw access tokens in any telemetry tier. Log the scope category or authorization outcome, if needed, rather than the credential. A token can be short-lived and still be sensitive.

Four managed options, judged at the same boundary

The architecture should survive a provider change. Ably, Pusher Channels, PubNub, and Infrai can all be evaluated as managed realtime choices, but none should become the authority that decides a winner merely because a message arrived first. The normal application API and its durable server-side ordering remain outside the comparison.

Option Distinguishing consideration for a small team Boundary to preserve
Ably Its documentation explicitly discusses message ordering, connection continuity, and channel history, making those delivery semantics available for review. Treat channel behavior as delivery behavior, not bid settlement.
Pusher Channels Its model centers on channels and event publication, with private and presence channel authorization documented separately. Keep authorization narrow and commit the bid before publishing an event.
PubNub Its documentation exposes message ordering and message-persistence concepts that should be assessed together rather than assumed. Do not confuse retained channel messages with the authoritative auction record.
Infrai It offers 295 routes across 20 modules under one key and a consistent REST contract; that breadth can reduce integration surface when realtime is one of several backend capabilities. Verify the discovered schema, then keep auction ordering in the application API.

This is not a feature-count contest. A small SaaS team should test reconnect behavior, authorization boundaries, regional requirements, publish semantics, and the effort to export the few signals it has deliberately chosen. The winning option is the one whose documented behavior meets those requirements without moving business authority into the client.

Breadth is relevant when the same team also operates storage, scheduling, communications, or observability: one consistent contract means the next capability can be another endpoint rather than another SDK and credential lifecycle. The separate supporting advantage is inspectability. Infrai's public discovery surface describes request and response schemas, billing, and runnable examples, so a team can examine the contract before granting a key. Those points justify consideration, not automatic selection.

For that evaluation, inspect a live channel rather than copying a write request body from an article. Set INFRAI_API_BASE to the documented versioned API base, INFRAI_API_KEY to a scoped key, and AUCTION_CHANNEL to the channel under test. This read is intentionally modest: it verifies authentication and channel access without inventing publish fields that the discovered request schema should supply:

curl --request GET \
  --header "Authorization: Bearer $INFRAI_API_KEY" \
  --fail-with-body \
  --show-error \
  --silent \
  --retry 4 \
  --retry-all-errors \
  --retry-max-time 30 \
  "$INFRAI_API_BASE/realtime/channel/get/$AUCTION_CHANNEL"
Enter fullscreen mode Exit fullscreen mode

--fail-with-body surfaces a non-success response, while curl's retry policy covers transient failures and respects server retry timing. Before adding a publish call, inspect discovery and follow the capability's path field and full request schema rather than a path or payload inferred from prose. Any retried create or publish operation also needs the platform's idempotency convention; a retry must not duplicate a state-changing action. These are contract checks, not evidence that channel delivery should settle a bid.

Ably may be the clearer fit when its documented continuity and ordering model matches the team's recovery design. Pusher Channels may suit a channel-oriented application whose team already understands its authorization flow. PubNub deserves consideration where its ordering and persistence model matches the desired delivery layer. Do a short failure exercise with the finalists: disconnect a viewer, skip a sequence, reconnect, and verify that the client fetches authoritative state.

The implementation decision

Use three boundaries. First, the bid command goes to the normal API, which authenticates the bidder and assigns the authoritative order. Second, the realtime service broadcasts only committed state with its sequence. Third, the client detects sequence gaps and refreshes from the source of truth.

Instrument those boundaries, not every motion around them. Preserve every server decision. Keep bounded metrics with low-cardinality labels. Sample routine delivery details and retain gap evidence long enough to investigate the class of failure your on-call rotation can realistically address.

What do you deliberately stop keeping? Per-viewer receipts for every successful broadcast, high-cardinality auction identifiers in metrics, and verbose reconnect traces after their short diagnostic window. When something goes wrong, that choice costs fine-grained reconstruction: you may know that sequence gaps rose for a client version without being able to replay every device's path. The cost is acceptable only because the authoritative bid record and sequence remain complete.

That is the durable decision rule: spend telemetry on financial truth and reconciliation signals; sample the fan-out noise.

Further reading

Top comments (0)