Internet users increasingly expect their digital experiences to be realtime. To meet this growing expectation, augmenting digital products with realtime features is becoming a priority for many businesses.
This is the first post in a multi-part series that looks at what it takes to build and deliver realtime experiences for end-users. This post covers the core capabilities you need to engineer realtime functionality. Then, we’ll look at the various types of realtime use cases you can address with these core capabilities.
Future posts in the series will focus on:
- Realtime infrastructure costs and challenges
- How to reduce the risk of delivering realtime experiences
- How to reduce the cost of delivering realtime experiences
- How to launch realtime features to market faster
The growing demand for realtime digital experiences
In the early days of the internet, the online user experience was purely the consumption of static content on a request-response basis. A user requested a page via their browser. To see updates, the user needed to initiate a full page refresh, which removed the entire page’s content and reloaded it regardless of how much had changed upon it.
As the internet was maturing, users gradually expected updates to be served to them more gracefully and efficiently. This was initially made possible by using techniques such as AJAX and Comet long polling, which attempted to “hack” the HTTP request/response model, and make it suitable for realtime communication.
In time, WebSockets emerged - a technology that enables full-duplex, event-driven, realtime communication between client and server over a persistent connection. WebSockets opened a new world of possibilities for developers looking to build digital experiences that are interactive, immersive, and responsive.
Nowadays, we have become accustomed to immediate digital experiences, and we take it for granted that our favorite apps and web pages should offer immersive, interactive services without lag. We seek smooth collaborative environments like Figma, we expect to be able to track our lunch orders in realtime, and we use live chat daily.
Estimates suggest that 30% of all global data consumed by 2025 will result from realtime information exchange, as 150 billion devices are predicted to be connected and consuming realtime data. Organizations that enhance their digital products with rich realtime features to engage their users can reap the rewards of higher levels of engagement, with potential repeat visits and new business.
Businesses that fail to offer realtime experiences risk losing market share, as competitors leverage realtime features to gain a competitive advantage. Whether you are in B2B or B2C, realtime is no longer a nice to have; it's a necessity.
Capabilities required to deliver realtime experiences
This section covers the key capabilities (building blocks) needed to engineer and deliver robust realtime experiences for end-users.
The cornerstone of any realtime digital experience is low-latency messaging. The average human reaction time is approximately 250ms, and a response time of 100ms is perceived as instantaneous by most people. If you can consistently deliver realtime updates to user devices in roughly 100ms or less, then, from a usability perspective, they can be considered as happening live, in realtime.
Latency is primarily constrained by distance and the speed of light. Of course, there’s nothing we can do about the latter. Even in theoretically perfect network conditions, packets cannot exceed the speed of light. However, we can do something when it comes to distance: bring data closer to clients through edge computing. If you’re building a cloud-based system, you should choose your availability zones carefully, ensuring they are in proximity to your users, and route traffic accordingly.
Another thing to consider is using an event-driven protocol designed for low-latency communication, such as WebSockets. Unlike HTTP, where you have to constantly request updates, with WebSockets, updates are sent immediately when they are available. Learn more about the differences between WebSockets and HTTP.
Message ordering and delivery guarantees
For numerous realtime use cases, it’s unacceptable if messages are sent out of order. Think, for example, of chat apps, and imagine how frustrating and confusing it can be for users if replies are not delivered in the correct order. Additionally, guaranteed delivery (preferably exactly-once delivery) is critical in many scenarios - for example, sending fraud alerts to mobile banking users.
Providing these guarantees is especially difficult when you have client devices experiencing changing network conditions. Devices might switch from a mobile data network to a Wi-Fi network, go through a tunnel, or deal with intermittent network issues. Scenarios like these lead to connections being dropped. In the interest of good UX, when users reconnect, it’s crucial that the stream of data can resume precisely where it left off, without dropped or out-of-order messages.
Persisting message data is another capability that’s key for realtime experiences. Sometimes, it’s a matter of storing a few messages for a short time - to a stream with continuity (no messages lost) after a brief disconnection. Other times, you might want to persist larger volumes of data for longer periods (e.g., to allow chat users to view their conversation history). Either way, it’s almost certain that you’ll need to persist some data and make it possible for users to rewind from a point in time / retrieve their message history.
The ability to interact with previously sent messages is relevant for a wide variety of use cases. With message interaction capabilities, you can augment your apps with features such as:
- Emoji reactions.
- Editing and deleting messages.
- Read receipts and unread counts.
- Quoting/replying to a message.
- Message threads.
Being able to keep track of which devices are connected and which aren’t (who is and isn’t present) is important for a lot of realtime use cases. With a presence capability, you can embed “who’s online” type functionality to your product. This is very useful if you’re building chat apps, multiplayer gaming, and collaborative document editing.
Besides indicating availability, presence can display the user’s status. Here’s an example - if the user’s account has been inactive for a certain number of minutes, they may be set as “Away”.
Many production-ready realtime systems don’t use just one protocol, but rely on a mixture of multiple protocols. For example, if you decide to use WebSockets as the primary transport protocol, you need to consider supporting fallback transports, as certain environments block WebSocket connections (e.g., restrictive corporate networks). Options like Server-Sent Events and HTTP long polling are frequently used as fallbacks for WebSockets. Or you might want to send native push notifications to users when they’re not using your app.
Another example - if you’re developing a video conferencing solution, WebRTC is a good option for sending audio and video data between peers. But you also need a protocol like WebSockets to complement WebRTC, and act as a signaling mechanism. In addition to signaling, you can use WebSockets to add realtime text chat to your video conferencing app.
Any kind of digital product (realtime or not) delivered over the public internet needs to benefit from robust security capabilities. This includes authentication and authorization, permissions, security policies, and end-to-end encryption. Depending on your use case, you probably also need to think about compliance with general standards such as EU GDPR, SOC 2, and even industry-specific ones, like HIPAA.
Realtime experience use cases
We’ll now look at the main types of experiences and realtime use cases you can power with the capabilities described in the previous sections.
Live chat is the most widespread type of realtime experience. There are many different chat use cases, including but not limited to:
- Customer support. Chat is used to assist customers who have questions or problems with a product or service.
- Collaboration. Teams collaborating on projects use chat to communicate and share information in realtime.
- Socializing. Chat is used for socializing and connecting with friends and family.
- Online learning. Chat facilitates communication between students and instructors.
- E-commerce. Chat is often embedded in e-commerce websites to provide customer support and assistance with online orders.
- Online gaming: Chat is essential for online multiplayer games, allowing players to coordinate in realtime.
- Healthcare. Chat can be used by healthcare providers and patients for online consultations.
Low-latency messaging and strong ordering and delivery guarantees are critical for any chat app. Here are some other key capabilities that are needed to engineer rich chat experiences:
- Pub/sub messaging. Pub/sub is a flexible messaging pattern that allows for one-to-one communication (private chat), as well as one-to-many (useful when building chat rooms).
- Presence, to indicate the online/offline status of chat users. In addition, presence comes in handy for building typing indicators and avatar stacks.
- Message interactions, to implement emoji reactions and allow users to edit/delete messages.
- Token-based authentication, coupled with flexible permissions, so you can build features like chat admin privileges.
Data broadcasting is the practice of transmitting the same data to a large number of recipients simultaneously. It’s a one-to-many form of communication that can be used for a variety of realtime use cases, including:
- Streaming live score updates
- Sending traffic updates
- Transmitting financial information, such as stock quotes and market updates
- Distributing news alerts
Here are the essential building blocks needed for data broadcast:
- Pub/sub messaging. The pub/sub pattern is ideal for data broadcast, as it allows the publisher to send messages to channels; in theory, any number of clients can subscribe to channels to listen to updates.
- Low latency. Low latency is critical for use cases like live score updates. Suitable protocol options include WebSockets and Server-Sent Events. In addition, it’s often worth using message delta compression, which allows you to send only the difference between the current message and the previous one rather than the entire payload. This helps reduce bandwidth costs and reduce latency.
- Message ordering and delivery guarantees. For instance, in a live sports event, the score may change frequently. If the messages containing the score updates are not transmitted in the correct order, it could lead to confused and frustrated users.
- Message persistence. By pairing message persistence with the ability to retrieve/rewind historical messages, you can build features such as live activity feeds.
Data synchronization refers to the process of ensuring that data is consistent and up-to-date across multiple devices or systems. Many realtime experiences rely on a flow from a database or datastore to frontend clients. Think, for example, of features like multi-user live polls and quizzes. Whenever a user votes in a poll, this event may be recorded in a database. And whenever there’s an update to the DB, the change needs to be propagated to all other connected clients.
In terms of capabilities needed, low-latency messaging and guarantees around ordering and delivery are important for any realtime data synchronization use case. Pub/sub messaging is a great choice if you need to synchronize updates to multiple and unpredictable numbers of connected users.
Multiplayer collaboration refers to working or playing together with other people in an online environment. Multiplayer collaboration is used to facilitate teamwork and collaboration on group projects, shared documents, presentations, whiteboards, and other materials. Figma is a prime example of multiplayer collaboration.
Generally, when building multiplayer collaboration experiences you need to:
- Ensure everyone has the same up-to-date view.
- Show who is working on a document and where.
- Enhance the experience with visual cues, e.g., cursor tracking and typing indicators.
Message ordering, guaranteed delivery, and low latency are essential for any multiplayer collaboration functionality. Without them, the user experience is severely affected. And here are a couple of other capabilities you’ll likely need:
- Pub/sub messaging, so you can easily communicate updates (such as a user making an edit) to all other connected devices in a one-to-many fashion.
- Presence, so you can build things like avatar stacks.
Realtime notifications are prevalent in today’s digital world. Here are but a few of the numerous use cases where you can use them:
- Social media and chat apps. These platforms use realtime notifications to alert users about new messages, comments, or other updates from their friends or contacts.
- Online marketplaces. Realtime notifications can be used to inform buyers and sellers about updates to their listings or offers.
- Financial updates. Financial apps and websites use realtime notifications to inform users about changes in their account balances or stock prices.
- Gaming. Multiplayer online games use realtime notifications to alert players about in-game events.
- Travel and transportation. Realtime notifications are frequently used by travel websites or apps to alert users about flight delays or cancellations, or by transportation apps to notify users about the arrival of a ride.
- Health and fitness apps. These apps use realtime notifications to alert users about their progress, such as when they have reached a daily step goal or when their heart rate exceeds a certain threshold.
There are different ways developers can implement realtime notifications. For instance, you can use low-latency, event-driven technologies like WebSockets or Server-Sent Events to send in-app notifications to client devices. Or you could send native push notifications through platform-specific services: APNS (for Apple) and Firebase Cloud Messaging (for Android users).
Realtime location tracking is becoming increasingly common, and it’s being used for a wide range of purposes, including:
- Fleet management. Realtime location tracking allows you to monitor the location and movements of vehicles in a fleet.
- Vehicle tracking: Realtime location tracking is an essential component for urban mobility and ridesharing Uber-like apps, so users can see where their ride is at any given moment.
- Asset tracking: Realtime location tracking empowers users to have a clear understanding of where their orders are, and visibility into when they will arrive.
To provide an optimal user experience, realtime location tracking must be delivered to end-users with consistently low latencies. Of equal importance is data integrity; location updates must be sent in the right order. Otherwise, the experience will be frustrating and confusing for the user.
Realtime infrastructure considerations
The capabilities you need to deliver realtime experiences to end-users are powered by an underlying realtime infrastructure layer. There are two main paths you can take: build and manage this realtime infrastructure yourself, or offload it to a specialized provider.
Managing realtime infrastructure in-house
Building realtime infrastructure in-house means that you are in complete control over what capabilities and realtime features to develop, how to engineer them, and what tech stack to use.
However, this flexibility comes at a cost. No matter what protocols you choose, or what libraries and frameworks you plan to use, you will have to ensure your system is low-latency, fault-tolerant, scales well, and provides superior messaging QoS guarantees, such as guaranteed ordering - all of these are formidable engineering challenges. See, for example, what it takes to embed fault tolerance into a large-scale realtime system. Or how difficult it is to ensure consistently low latencies in a globally-distributed architecture.
Building and managing realtime infrastructure in-house is expensive, complex, and potentially risky:
- Large financial costs to build the infrastructure in the first place, and significant additional costs to maintain it and enhance it over time.
- Significant engineering effort to build and maintain, shifting focus away from core product development, and increasing your time to market.
- Developing a system you can trust to trust to behave in a dependable way is a tough nut to crack. Failing to do it right (e.g., sub-optimal latency or outages) can lead to user dissatisfaction and loss of revenue.
We spoke to engineers at companies like LinkedIn, Slack, and Box who'd already built realtime infrastructure themselves. They told us it would take non-trivial upfront engineering with significant operating costs.
Pato Echagüe, CTO and co-founder, Split
Using a PaaS provider to power your realtime experiences
The alternative to building realtime capabilities in-house is to offload this responsibility to a specialized realtime provider. Using a PaaS to power realtime experiences can bring a number of benefits, including:
- Reduced engineering complexity and resources. PaaS providers typically handle the maintenance and management of the underlying infrastructure, so you don’t have to worry about load balancing, provisioning server capacity, network connectivity, and other infrastructure headaches.
- Scalability. PaaS providers usually allow you to easily scale your applications up or down as needed. This is particularly useful when dealing with realtime experiences with high and fluctuating numbers of concurrent users.
- Cost efficiency. By using a PaaS you can reduce overall costs compared to setting up and maintaining realtime infrastructure in-house.
- Improved security. PaaS providers often have robust security measures in place to protect user data and applications.
- Easy integration. Many PaaS providers offer a range of tools and APIs to integrate with other services and platforms, which can make it easier for developers to build realtime experiences that work seamlessly with other systems.
Ably is a realtime experience infrastructure provider. Our realtime APIs and SDKs help developers power multiplayer collaboration, chat, data synchronization, data broadcast, notifications, and realtime location tracking at internet scale.
Find out more about Ably and how we can help with your realtime use case:
- Explore customer stories and discover how organizations like HubSpot, Mentimeter, and Genius Sports benefit from trusting Aby with their realtime needs.
- Read our product documentation.
- See what kind of realtime experiences you can build with Ably and check out our chat apps reference guide.
- Get started with a free Ably account and give our APIs a try.
Coming soon: Part 2 of this blog series, where we will take a closer look at the costs and challenges of building realtime infrastructure in-house.