Amazon SNS vs PubNub: Differences for Pub/Sub

5 min readAug 18, 2022

We're often asked “what is the difference between PubNub and Amazon SNS for latency?” In this blog post, we’ll take a look at both and show you the difference between PubNub and Amazon SNS for publish/subscribe.

Both PubNub and Amazon SNS use a publish/subscribe metaphor for sending and routing data. However, PubNub and Amazon SNS provide different functionalities and solve different business problems; and one actually cannot replace the other. After reading through this blog post, you’ll find that the two technologies are very different, with very different use cases and applications.

Amazon SNS vs PubNub Data Stream Network

Publishing to End-User Devices: PubNub vs Amazon SNS

PubNub is explicitly designed to deliver data with low latencies (under 0.25 seconds SLA) to end-user devices, including smartphones, tablets, browsers, and laptops.  These devices can be behind firewalls, NAT environments, cell towers authorities, and other hard-to-reach network environments; additionally PubNub is providing message caching for retransmission of lost signals over unreliable network environments.  PubNub accomplishes this by maintaining an always open socket connection to every device, and using this open socket connection to ‘push’ data at low latencies. PubNub provides over 50 client SDK libraries to make it easy “plug into” PubNub with a simple PubNub Subscribe API call.

Conversely, the main use for Amazon SNS is for server-to-server publish/subscribe use cases, or email & text message end-user notifications.  To get a better idea of how Amazon SNS is implemented, check out the common Amazon SNS use cases here.  Amazon SNS is also not optimized for in-app real-time notifications. Amazon SNS is more analogous to TIBCO or Tuxedo, which are server-to-server publish/subscribe systems.

Amazon SNS has no way to reach client devices, except via email or SMS notifications. As a result, for applications that rely on low-latency data (such as multiplayer games, chat applications, collaborative apps, etc.) Amazon SNS is not the right solution in for this environment.

The primary way that Amazon SNS sends data to subscribers is via email or HTTP callbacks. Running an HTTP server on mobile, browser, and desktop devices to receive these notifications is impractical, both because of network firewalls and device security reasons.

Amazon SNS Latency (i.e. “Real-time”) vs. PubNub

Amazon SNS latency provides no guarantees, and the vast majority of latencies are measured over 1 second, and often many seconds slower. Again, this is somewhat irrelevant; Amazon SNS is designed for server-to-server (or email/SMS) notifications, where a latency of many seconds is often acceptable and expected.

Because PubNub delivers data via an existing, established open network socket, latencies are under 0.25 seconds from publish to subscribe in the 95% percentile of the subscribed devices. Most humans perceive something as “real-time” if the event is perceived within 0.6 – 0.7 seconds.

Channels/Topics and Multiplexing PubNub and SNS

Amazon SNS allows for up to 100 “topics” to be created on an account.  A “topic” is equivalent to a PubNub channel.  Conversely, PubNub supports an unlimited number of PubNub channels. This allows every end-user device to have its own channel for one-to-one connectivity.

Further, PubNub’s support for Multiplexing allows a client device to connect to multiple PubNub channels simultaneously, while continuing to use a single network socket.  This allows for a client to simultaneously subscribe to, for example, a “private” channel specifically paired with a single device or set of devices owned by the same person, and a “public” channel that a group or entire population may also subscribed to.

Another use-case for Multiplexing would be a streaming stock price application: Assume you want to stream the stock price changes for 1,000 different equities.  Each stock would have it’s own PubNub channel. The end-user device would use PubNub Multiplexing to subscribe only to the PubNub channels associated with the equities they want to track.

Since Amazon SNS does not support Multiplexing, this type of use case is not possible.

Reliability and Redundancy

PubNub is globally distributed in 14 data centers and growing. All data published into the PubNub Global Cloud is automatically replicated globally, providing both low latency worldwide, as well as unparalleled reliability, even in the event of entire data center failures. PubNub offers up to 99.999% SLA uptime for its Data Stream Network.

PubNub and Amazon SNS Features

Beyond simple publish/subscribe, PubNub offers a collection of real-time building block services for any kind of real-time application.  These services are not offered by Amazon SNS or other Amazon services:

  • Data Sync: Automatically syncs application data in real time across devices and stores and shares objects throughout an applications lifecycle.
  • Presence — Provides real-time updates for which users are online, and alerts for when they go off-line.  These updates are provided via a multiplexed PubNub “sister-channel” that streams presence updates whenever the user count within an app changes.  An additional API called “Here_Now()” also provides an up-to-the-second count for users in the app.
  • Storage & Playback — PubNub automatically stores all data published to each channel, and provides two mechanisms for retrieving this data: (a) a simple REST request to retrieve the data all at once, and (b) a playback mechanism for “playing back” this data similar to a DVR for TV recordings.
  • Real-time Analytics — PubNub provides various visualizations and usage statistics to display user activity, geography, and usage.  An example screenshot is below
  • Offline Mobile Push — PubNub also provides a fallback mechanism for messages to mobile devices for when the mobile app is not running (or in the background).  PubNub can fall back to a mobile “push notification”, ensuring the mobile end-user is notified even when the phone is in their pocket.  As soon as the app is launched, the app will begin using the data stream network again.

PubNub data stream network

  • AES Encryption — PubNub provides out-of-the-box AES 256 encryption support, ensuring that data remains encrypted while routing through the PubNub network.  While Amazon SNS provides HTTPS, this means that the data is unencrypted while routing through the Amazon network.  This immediately invalidates Amazon SNS’s use for HIPAA, SAS70, and other security-minded applications.
  • Multiplexing — PubNub enhances multi-channel communication with a mechanism that allows all data topics to be streamed over a single TCP Socket Connection.  With PubNub Multiplexing the savings are most apparent with mobile device resources such as phones on battery and slower network connectivity.  Data is compressed and bundled via configurable windowing to provide longer battery life and improved end-user experience under continuously changing network conditions.

Summary of PubNub and Amazon SNS

Amazon SNS has a variety of interesting uses, mostly related to server-to-server notifications and email/SMS end-user alerts.  It was originally developed as a way to orchestrate data between various other Amazon AWS cloud services, and thus is primarily used for server back-end operations and movement of data.

PubNub is designed to make it easy to build real-time apps on mobile, browser, and desktop that scale globally to millions of simultaneous users. Today PubNub is used by over 2,000 organizations globally spanning social, advertising, gaming, telecommunications, and a variety of other markets.

More from PubNub

How to Create a Dating App: 7 Steps to Fit Any Design
Insights6 minMar 15, 2023

How to Create a Dating App: 7 Steps to Fit Any Design

There are common underlying technologies for a dating app, and in this post, we’ll talk about the major technologies and designs...

Michael Carroll

Michael Carroll

How to Create a Real-time Public Transportation Schedule App
Build6 minMar 14, 2023

How to Create a Real-time Public Transportation Schedule App

How to use geohashing, JavaScript, Google Maps API, and BART API to build a real-time public transit schedule app.

Michael Carroll

Michael Carroll

How to Create Real-Time Vehicle Location Tracking App
Build2 minMar 9, 2023

How to Create Real-Time Vehicle Location Tracking App

How to track and stream real-time vehicle location on a live-updating map using EON, JavaScript, and the Mapbox API.

Michael Carroll

Michael Carroll

Talk to an expert