Real-time dashboard updates without hammering the database: what we poll and what we push

Tanvir Akhter Shakib7 min read

The short answer

Real-time dashboard updates do not need a WebSocket on every screen. We keep most of the CRM fresh with visibility-aware polling on four fixed cadences, a short client cache and a refetch on tab focus, and we use WebSockets with Redis pub/sub only where seconds matter: team chat and viewing availability. Expensive dashboard figures are cached on the server, so a refresh does not recompute them.

Which parts of the CRM are real-time, and which are polled

Real-time covers three different things in our app, so it helps to be precise. Team chat and the viewing availability page use WebSockets. The customer inbox, the conversation list, deals, viewings, tasks and most other screens use polling. Dashboard figures are polled slowly and cached on the server.

That surprises people, because the inbox feels live. It is polled: the conversation list every 20 seconds and an open thread every 10. Polling is stateless and its load is easy to bound, and the cost is latency. A new inbound message can take about ten seconds to appear in a thread that is already open. Every interval in the app comes from one of four named tiers, defined in one file so the cadences are tuned in one place:

export const FRESHNESS = {
  REALTIME: 10_000, // open inbox thread, live job progress
  LIVE: 20_000,     // deals, viewings, leads, tasks, conversation list
  STANDARD: 45_000, // properties, tenancies, finance lists
  SLOW: 90_000,     // analytics, nav badges, dashboard panels
} as const;

How polling stays cheap: visibility, a short cache and parallel requests

Polling is cheap only if it is disciplined. The navigation badge shows the pattern at its smallest: it polls on the slowest tier, issues its three requests in parallel, and tolerates any one of them failing, so a flaky endpoint cannot blank the badge. The same rules keep the rest of the app bounded:

  • Only mounted queries poll. React Query refetches on an interval only while a component using that query is on screen, and by default it does not poll in a background tab. Load is roughly one active screen per active user, not the whole app.
  • Our own poller, used where data is not fetched through React Query, pauses while the tab is hidden and refreshes immediately when the user returns.
  • A global 30-second stale time, with refetch on window focus and on reconnect, means returning to a tab or navigating re-validates only data older than 30 seconds.
  • Previous data stays on screen while the next request is in flight, so a refresh never flashes an empty table.

Keeping the queries themselves cheap on Postgres

Polling multiplies whatever one request costs, so the cost of a request matters more than the cadence. Four things keep ours down:

  • Indexes shaped like the queries. A migration added indexes for the lists every page load reads: the latest message in a conversation, the notification bell, the agency inbox, the leads and properties lists and the viewings counts. Each matches an existing query, and they were built concurrently so writes were not blocked.
  • Bounded reads. The activity feed has a default window, a hard cap on rows and a maximum look-back, so one request cannot pull an agency's history into memory to draw a handful of lines.
  • Cached dashboard metrics. The analytics dashboard is cached in Redis per agency and date window for five minutes. It is not invalidated on writes, so those figures can be up to five minutes old, and the report builder and analytics assistant read live figures instead.
  • A cached sentence on fresh counts. The daily brief counts its figures fresh each time, but the generated sentence is cached against a digest of those counts, so identical facts return identical text from cache. If the language model is slow or unavailable, a plain sentence built from the same counts is served.

Where we use WebSockets: team chat and viewing availability

Two surfaces justify a persistent connection. Team chat needs messages, typing, read receipts and presence in the moment. The viewing availability page is where two people booking the same property at the same time is a real problem.

The availability design is worth copying. An event says only which property changed and why. No slot or figure travels over the socket: the page re-reads the real numbers through the normal REST endpoints, which apply the branch rules. Events can repeat, and applying one is just a refresh, so a duplicate is harmless. The socket itself is only opened for people holding the availability permission, and a person only hears about properties in branches they can reach.

A socket is authorised once, when it connects, and that is not enough for a long-lived connection. Every 30 seconds an open socket rechecks whether the session is still valid and, in chat, whether the person is still in the room, and closes itself if not. Clients reconnect with exponential backoff. The availability page also asks for a full resync every 20 seconds while its socket is down, and once more as soon as it reconnects, so a missed event is never left on screen.

WebSockets with Redis pub/sub across several FastAPI workers

The API runs several worker processes. Each holds its own set of sockets, so a message handled by one worker would never reach a colleague connected to another. Redis is the shared piece.

Publishing is two hops. First an in-process broadcast, which is the only path that still works when Redis is down, so a cache outage degrades chat to single-worker instead of silencing it. Then a Redis publish on a per-room channel (a per-agency channel for availability) that every socket listens on. The price is that sockets on the publishing worker receive the event twice. Clients de-duplicate messages by id and presence events are idempotent, so we accepted the duplicate.

Presence needed its own care. Who is online in a room is a Redis hash with one field per connection, because one person can hold several sockets. Each connection refreshes its field on a heartbeat every 25 seconds, and a field older than 90 seconds is treated as gone. Without that, a worker killed mid-connection would leave someone showing as online to everyone else indefinitely.

async def publish_room_event(room_id, event):
    # 1. This worker's sockets. Still works if Redis is down.
    await manager.broadcast_to_room(room_id, event)

    # 2. Every other worker, through Redis pub/sub.
    if redis.is_connected():
        await redis.publish(f"chat:room:{room_id}", json.dumps(event))

The trade-offs we accepted

Polling means latency between ten and ninety seconds depending on the tier, and every open tab makes its own requests, so load grows with active users rather than with data changes. Pushing the inbox over a socket would cut both, but it would also mean authorising and rechecking another long-lived connection for that feed, and we have not built it. For dashboard figures that move over hours, slow polling and a short cache are enough.

Server-side caches have the same shape of trade-off. The analytics cache can be up to five minutes behind, because it is not invalidated when data is written. The honest way to describe a dashboard is by how old its numbers can be, and that is the number to ask any vendor for.

Where this fits in Propily

These are the choices behind the inbox, calendar and dashboard in Propily, the CRM we build for UK estate and letting agencies. If you are comparing CRMs, ask which screens are pushed and which are polled, and how fresh the headline numbers are. The real estate CRM page shows what the product covers, and a demo shows it on your own data.

Questions people ask

Do I need WebSockets for a real-time dashboard?

Not for every screen. If a few seconds of delay is acceptable, polling on a sensible interval with a client cache is simpler and easier to bound. Use WebSockets where people act on each other's changes in the moment, such as chat or booking.

How do you scale WebSockets across several FastAPI workers?

Each worker only knows its own sockets, so publish events through Redis pub/sub as well as in-process, and have each socket subscribe to its room's channel. Keep presence in Redis with heartbeats, so a crashed worker does not leave stale state.

How often should a dashboard poll?

Match the interval to how fast the data really changes. We use 10 seconds for an open conversation, 20 for active work lists, 45 for slower lists and 90 for dashboard panels and badges, and we pause polling in hidden tabs.

How do you stop polling overloading Postgres?

Bound the number of pollers by polling only the visible screen, make each request cheap with matching indexes and capped reads, and cache expensive aggregates for a few minutes. We cache the analytics dashboard figures per agency for five minutes.

Who answers your phones tonight?Book a demo
Real-time dashboard updates: polling, WebSockets, Redis | Propily