Site Search for Web Apps: Postgres vs Elasticsearch vs Algolia
Choosing search for your web app? Compare Postgres full-text search, Elasticsearch and Algolia on cost, relevance, effort and when to outsource the build.
WebSockets vs SSE vs polling: how to choose the right approach for live dashboards, chat and notifications, with cost, scaling and testing trade-offs.
Sooner or later most products get a request that sounds simple: “make it update live.” A dashboard that refreshes on its own, a chat window, an order status that changes without a page reload. The technology you pick for this has a long tail of consequences for hosting cost, scaling, mobile battery use and testing effort. This guide explains the three common options so a CTO, founder or product manager can make the decision with their engineers rather than inheriting it.
Polling. The browser asks the server “anything new?” on a timer, for example every 10 seconds. It uses ordinary HTTP requests, so it works everywhere and needs no special infrastructure.
Server-Sent Events (SSE). The browser opens one long-lived HTTP connection and the server pushes updates down it whenever it has something to say. Communication is one-way: server to client. Browsers reconnect automatically if the connection drops.
WebSockets. The browser and server upgrade an HTTP connection to a persistent, two-way channel. Either side can send messages at any time with very little overhead.
A fourth option, long polling, sits between polling and SSE: the server holds each request open until it has data, then the client immediately asks again. It is mostly a fallback today.
| Polling | SSE | WebSockets | |
|---|---|---|---|
| Direction | Client asks | Server to client | Both ways |
| Latency | Up to one interval | Near real time | Near real time |
| Complexity | Lowest | Low | Highest |
| Works through proxies and firewalls | Almost always | Usually | Sometimes needs configuration |
| Auto-reconnect | You build it | Built in | You build it |
| Best for | Slow-changing data | Feeds, progress, notifications | Chat, collaboration, games |
Polling has a poor reputation, but it is often the correct choice:
Be honest about the cost, though. Every poll is a request, and most return “nothing new.” With many users and short intervals, this wastes server capacity and drains mobile batteries. If you poll, add sensible intervals, back off when the tab is hidden and use conditional requests (ETags) so unchanged responses are cheap.
SSE is underused. It is a strong fit when the server does the talking:
Because it runs over standard HTTP, it plays well with existing authentication, logging and load balancers. Automatic reconnection, including the ability to resume from the last event ID, removes a lot of code you would otherwise write. The limitation is that the client cannot send data over the same channel, so user actions go through normal API calls. For most “live view” requirements, that is perfectly fine.
Choose WebSockets when you genuinely need frequent two-way messages with low latency:
The price is operational. Each connection stays open, so servers must hold many concurrent connections in memory. You also need to design for reconnection, heartbeats to detect dead connections, message ordering and authentication that does not rely on a single page load.
Persistent connections change how you scale. Raise these points early:
Ask these questions in order:
Start with the simplest option that meets the user need. Moving from polling to SSE, or from SSE to WebSockets, is much easier when the rest of your application separates “what changed” from “how it is delivered.”
Real-time features look small in a demo and become expensive when connection handling, scaling and testing are skipped. If you want an experienced team to design and build them, our web development services cover architecture, implementation and QA end to end. You can contact us to discuss your requirements and we will recommend the simplest approach that works.
Choosing search for your web app? Compare Postgres full-text search, Elasticsearch and Algolia on cost, relevance, effort and when to outsource the build.
How to integrate a payment gateway into a web or mobile app: choosing a provider, hosted vs custom checkout, webhooks, security and testing before launch.
A practical guide to web application caching strategies: browser, CDN, application and database layers, plus invalidation rules and common mistakes.
Tell us about your platform, your product idea or the systems you want to modernise. Someone from our Chennai engineering team will get back to you personally.