Architecting Real-Time Apps with The Streaming Web

Gone are the days of banks of request/response servers supporting real-time mobile and web applications. It’s a bold statement, but today's users demand instant access to data and applications that operate with extreme accuracy. This customer need often entails development teams finding ways to stream gigabytes of information and events worldwide to devices that fit in the palms of users’ hands.

The Serverless / Streaming Architecture

Classic architecture has application developers provisioning complex sets of servers, spending countless amounts of time moving and transforming data across different networks to provide end users with information based on complex data requests. This approach is slow and costly to maintain.

Today’s modern architecture does not rely on these complex monolithic web service APIs. Instead, today’s applications publish messages and subscribe to events that utilise small single purpose functions. These purpose built functions do not have the overhead of a larger server and API system. These microservices allow applications to collect and stream data from event to event; transporting massive amounts of data extremely quickly between the originating event and the data destination. The nature of the resulting architecture is one that is horizontally scalable, modular, and can be built in less time than a traditional web service.

We commonly refer to this as the “serverless architecture”, meaning the backend is managed primarily by a third party Backend as a Service (BaaS) like PubNub.

How It Works

The way the BaaS works is elegantly simple and powerful. Data is published as messages, processed by small containerized blocks of code running in the cloud and pushed as a message to all the subscribers listening for that particular data. The blocks used to prepare and transform data are written in JavaScript. The anonymous function blocks, which in computer science we sometimes identify with the Greek symbol λ (lambda), are containerized and only created when a message streamed through the network. When the task is complete, the container function container is destroyed. The micro-service creation and destruction process happens in mere milliseconds.

The final result is real-time messages, passed through ultra-fast cloud-based, micro-service functions and pushed directly to subscribed peers within milliseconds. PubNub further optimizes the process by always having blocks ready to run, further reducing the time required to process a stream.

Benefits for Real-Time Applications.

Building real-time applications (ex. The ride share application Lyft) is possible with traditional architectures, but it can be simplified significantly by utilising services like PubNub. Instead of building a back-end system based on complex URL requests and HTTP methods, we create fast, streaming data flows that provide instant communication between devices. Clients that traditionally poll for data can now subscribe to a stream of data; pushed in milliseconds instantaneously across the network. Publication of data to the stream is propagated back in the same manner, where data becomes available in real time with an extremely lean overhead cost.

The implications of this type of architecture for building real-time applications is profound. has built real-world applications using a serverless architecture to help a large service-based organization communicate with their field technicians in real-time. Because we adopted PubNub as our BaaS, was able to create a system that readily utilised a serverless architecture to publish and subscribe to updates instantaneously, eliminating the need to develop and maintain a complex system from scratch.

Moving Forward

Every day, more devices outside of traditional mobile phone and desktop applications take advantage of this serverless approach to building software. The Internet of Things (IoT) is producing more real-time data that can be streamed and processed in blocks. As more devices become network connected, we will see applications that use IoT data migrate from a traditional architecture towards a streaming architecture. Any time that you are building an application based on real-time data (from the IoT or otherwise), ensure that you are following the right architecture to ensure scalability and performance.

If you want to get started today and see it working first hand, please check out our blog post on building a React.js app with PubNub. is excited to attend PubNub's StreamConf this year in San Fransisco, and to connect with industry leaders in streaming and serverless architecture. We’d be excited to talk to you about how and PubNub can help make your Cross-Channel real time application effective. Sign up for the conference with our sponsor