Skip to content

Design a Reactive Database (Live Queries), stage 1 of 9: model

What polling actually costs

Use the numbers in the scenario: 40,000 people online, five queries per screen, a poll every five seconds, 2,000 mutations a second.

System so far· 4 parts
123CLIENTWeb andmobile appsSERVICESync serversSERVICEFunction runnersDATABASEVersioned store

Select a component to see what it is responsible for and which state it owns.

  1. 1Web and mobile apps → Sync servers: Subscribe and mutate
  2. 2Sync servers → Function runners: Run a function
  3. 3Function runners → Versioned store: Read at a snapshot

What you need to know

0 of 3 checks done
  1. Polling and push put cost in different places:

    • Polling costs (viewers × queries per screen ÷ interval), whether anything changed or not.
    • Push costs (writes × queries each write affects), plus sending each new result to whoever watches it.

    Which is cheaper depends on how often data changes compared with how often it's viewed. See Server push: polling, long polling, SSE, WebSockets.

  2. Work it out

    40,000 people online, 5 queries per screen, polling every 5 seconds. How many query runs a second?
    per second