Your Privacy

This site uses cookies to enhance your browsing experience and deliver personalized content. By continuing to use this site, you consent to our use of cookies.
COOKIE POLICY

Skip to main content

Achieving Real-Time Functionality in a Web App — the ‘Right’ Way

Achieving Real-Time Functionality in a Web App — the ‘Right’ Way
Back to insights

Today, there are many scenarios in which we expect real-time (or near real-time) functionality from our web applications. Often it is not even a conscious expectation—but instead is a more subtle enrichment of user experience that many take for granted. When I encounter this demand in my web development work, I take a step back to consider the ‘right’ solution for that particular context. This is because there are numerous ways of achieving a real-time experience (or the illusion of it)—be it through programmatically re-executing data queries or by opening a steady two-way data stream via a WebSocket subscription; or anything in between. Making the ‘right’ choice requires that a developer weigh the application’s needs against the performance expenses associated with the various data acquisition methods. 

Perhaps the most straightforward way to keep the client (your users) seamlessly up to date with your backend is through intermittent polling. For example, an investment application might allow its users to track their favorite stock prices by re-executing a query of the stock data every 10 seconds, perhaps even re-rendering some corresponding charts or graphs with that cadence as well. This approach can and does gracefully cover many use cases and provides a predictable, relatively responsive experience. The downside: polling can be expensive—especially when you are repeatedly querying for large, complex objects for which most of the fields change infrequently.  

A more holistic approach to keeping the client in sync with your backend is using a subscription: a means of bidirectional communication that allows information to flow freely without needing to re-query the database. This persistent connection is usually achieved by communicating via WebSocket (WS) rather than the standard HTTP transport. The power of subscriptions lies in their ability to communicate updates to individual fields as they occur in the database. For this reason, the approach proves very efficient in the case of small, incremental changes to large data objects.  In addition to their efficiency, subscriptions bring true real-time functionality to the table. In cases where your application demands new information as soon as it is available (think instant messaging), the subscription approach provides what is perhaps the very best sustained low-latency solution.  

On the other hand, if your application only needs an update every 5 minutes, it is less expensive to re-initiate an HTTP connection with each update than keeping a WS connection open for that duration when no immediate updates are required or available. The decision between the two protocols always includes weighing the two costs in your specific use case. Option one is the cost of keeping an existing WS connection open (in which case the client constantly receives information—albeit only the response data and a very small header). The second option is the cost of establishing a new HTTP connection (which requires that the client send large headers with the request and receive large headers back with the response). Whatever the best solution may be for your web application, adding real-time functionality can significantly enrich your end-user’s experience and inspire confidence in the app.

Digging In

  • Software Engineering

    When There’s Too Much to Fix: How Smart Prioritization Unlocks Revenue at Scale

    Every operations team has a backlog. The question isn’t whether you can clear it — it’s whether you’re clearing it in the right order. For most teams, the honest answer is no. And that gap between the order work gets done, and the order it should get done is quietly costing organizations millions. The Volume Problem High-volume exception processing shows up across […]

  • Software Engineering

    Creating Reusable Code Templates to Reduce Client Project Startup Time

    In consulting, one of the least visible but most expensive phases of a project is the beginning. Teams can spend days or weeks setting up repositories, agreeing on structure, wiring basic infrastructure, and solving problems that have already been solved many times before. Code templates are a practical way to reduce overhead while improving consistency. […]

  • Software Engineering

    Player Three Has Entered the Game: How AI Is Finally Bridging the Divide Between Design and Engineering

    As AI begins to become more prominent in our day-to-day lives, I find myself in a unique position. As a practicing software engineer and UI/UX designer, I am genuinely happy to see the introduction of AI tools begin to take shape in our industry. But more importantly, I am happy to start seeing the effects it is having on what has historically been a pretty challenging relationship: the […]

  • Software Engineering

    The Disappearing Middle of Software Work: Why the Bookends – Strategy & Impact – Matter Most Now

    Here’s a question nobody in enterprise software wants to sit with: what happens to the middle? Not the middle of the org chart. The middle of the work. The vast, expensive layer of effort that has defined enterprise software delivery for thirty years—translating what the business wants into working code. The requirements-to-implementation pipeline. The “build phase.” […]

  • Software Engineering

    Zero-Code Telemetry with OpenTelemetry’s OBI

    Full distributed tracing and exception capture for any application — without writing a single line of instrumentation code. View the source code on GitHub → The Premise Observability is essential for understanding what’s happening inside your services, but instrumenting an application by hand — adding trace spans, logging calls, and metric counters throughout your codebase […]

  • Software Engineering

    Building a Consultant in the Trenches: How Playing Offensive Line Shaped My Consulting Career

    People often ask me the same question when they find out that I played college football: “Do you miss it?” On the surface, it’s a bad question with an obvious answer. Yes. However, if I give myself a minute to sit with that question, the answer is more nuanced. Yes, I miss playing football, but […]