PubNub
PubNub

106
224
30
Pusher
Pusher

307
200
45
Add tool

PubNub vs. Pusher - Help me decide


When we talk about adding real-time functionality to our applications, hosted services like Pusher and PubNub easily come to mind given their proven stability and consistency in providing amazing features that enable real-time notifications and messaging infrastructure. Each tool allows you to build apps that allow your users to engage in real-time across mobile, browser, desktop and server.

  • Pusher builds and delivers real-time APIs for app developers building communication and collaboration features.
  • PubNub makes it easy for you to add real-time capabilities to your apps, without worrying about the infrastructure.

In this post, we’ll look deeper into the two technologies and compare their features.

Transport medium

Pusher uses WebSockets and HTTP, and also provides fallbacks for devices that don’t support WebSockets. This makes Pusher an excellent option when considering the real-time effectiveness of the desired application since Websockets allow a long-held single TCP socket connection to be established between the client and the server. This allows for bi-directional, full duplex messages to be distributed instantly with little overhead, resulting in a very low latency connection.

PubNub uses HTTP streaming/long-polling. When building a real-time application with HTTP long polling for server push, you’ll have to develop your own communication management system. This means that you’ll be responsible for updating, maintaining, and scaling your backend infrastructure. With PubNub, you don’t have to worry about all that. PubNub takes care of the backend infrastructure for you, so you don’t have to worry about maintaining and orchestrating your real-time network.

When looking at HTTP long polling with the goal of streaming data, PubNub is a low-latency and low-overhead real-time Web app communication environment, and features the ability to send messages to a single client, client groups and all clients.

Debugging tools

According to this Quora post response by Jeremy Haile, both Pusher and PubNub provide some fantastic debugging tools for developers to aid in development. However, the features are not exactly the same. For instance, with Pusher, you can open up the debug console for your app and watch all of the message throughput.

In addition to the Pusher Debug Console, Pusher also has Event Creator and Channels JavaScript logging that helps you to debug applications and better understand what’s happening in your application during and after development.

In PubNub, you have to type in the exact channel name you want to listen to. Which is fine if your channel name is simple, but is more difficult if your channel name is a long string of random characters.

PubNub docs

PubNub also has a debugging tool called PubNub Functions. Functions is a Python script that monitors all of your event handlers and displays alerts/notifications in the terminal. This is beneficial as you can easily add all of your logs of this system to Elasticsearch via the remote server running the monitor. This will activate services like Kibana, Grafana, and PagerDuty – which in turn covers logging, metrics, and alerts.

PubNub provides structural integrity for applications of any scale, but there could be times where the code within the Function does something you didn’t intend. In such cases, the Functions debugging tool can come in handy to keep tabs on your running PubNub Functions, monitoring their state and health and reporting back any irregularities.

Message size limits

PubNub limits messages to about 1,800 bytes - which may not be enough depending on what you're sending. This could prove problematic when trying to push dynamic data or data from a user entry field. However, PubNub allows you to increase the maximum size to 7.2k for an additional monthly fee.

Pusher limits are 10kb per message as part of their normal offering. However, they offer larger maximum message sizes for enterprise plans compared to PubNub.

Ease of usage

Developers love getting started quickly. Each of these technologies have a well-structured API and documentation that help to make adoption a smooth process.

Getting started with Pusher:

  1. Create a Pusher account and get the API credentials (key, cluster and secret)
  2. Include the channels client library by adding the pusher-js script tag to your page.
<script src="https://js.pusher.com/4.3/pusher.min.js"></script>
  1. Open a connection to Channels using the key and cluster you noted down earlier.
var pusher = new Pusher('APP_KEY, {
      cluster: 'APP_CLUSTER'
      });

  1. Next, you subscribe to a channel - you will soon publish an event to a channel called my-channel, and your web app will receive this event. But to receive this event, your web app first needs to subscribe to the my-channel channel. Do this with pusher.subscribe:
var channel = pusher.subscribe('my-channel');
  1. Listen for events on the channel. Every published event has an “event name”. The event you will publish will have the event name my-event. For your web app to do something when it receives an event called my-event, your web app must first “bind” a function to this event name. Do this using the channel’s bind method:
    channel.bind ('my-event', function(data) {
      alert('An event was triggered with message: ' + data.message);
      });
  1. Finally, trigger events from your server. In the example below, we will trigger an event named my-event to Channels on a channel called my-channel. For this example, we’ll demonstrate with a Node server:
var Pusher = require('pusher');
var pusher = new Pusher({
    appId: 'APP_ID',
    key: 'APP_KEY',
    secret: 'APP_SECRET',
    cluster: 'APP_CLUSTER'
  });
    pusher.trigger('my-channel', 'my-event', {"message": "hello world"});

Getting started with PubNub:

  1. To build an application that leverages the PubNub Data Stream, you need to sign up for your account to obtain API keys.
  2. Install PubNub -To start publishing and subscribing, you first need to access PubNub libraries. Include the code hosted on their CDN just before closing your HTML tag.
<!-- Include the PubNub Library -->
<script src="https://cdn.pubnub.com/sdk/javascript/pubnub.[version number].js"></script>


  1. Now you can instantiate a PubNub object using your own publish and subscribe keys or use the demo keys:
<!-- Instantiate PubNub →

var pubnubDemo = new PubNub({
      publishKey: 'Your Publish Key Here',
      subscribeKey: 'Your Subscribe Key Here'
});
  1. Subscribe - Now that you have PubNub installed and instantiated, subscribe to your own custom data channel and log all sent messages over that channel on the console. To make the channel private, you can use the PubNub Access Manager or use the additional security measures:
// Subscribe to the demo_tutorial channel
pubnubDemo.addListener({
      message: function(message) {
          console.log(message)
      }
  })
pubnubDemo.subscribe({
      channels: ['demo_tutorial']
  });
  1. Publish - After you have subscribed to your own channel, you can then publish your own messages to it:
// Publish a simple message to the demo_tutorial channel
pubnubDemo.publish({
        message: {
            "color" : "blue"
        },
        channel: 'demo_tutorial'
    });
  1. Unsubscribe - After publishing your messages, you can decide to unsubscribe from the channel:
pubnub.unsubscribe({
      channels: ['some_channel']
 });

With those few steps, you can easily get started with both Pusher and PubNub. They both have really simple and efficient API’s that makes them attractive to developers. However, Pusher’s API’s differ in a way such that it offers an additional event abstraction like:

Pusher:

    var pusher = new Pusher(KEY);
    var channel = pusher.subscribe('messages');
    channel.bind('new_message', function(msg) {
    });

PubNub:

    var pubnub = PUBNUB.init({
        subscribe_key : 'demo'
    }) 
    pubnub.subscribe({                                      
        channel : "hello_world",
        message : function(msg){
        }
    })

Pricing

Both Pusher and PubNub offer free plans for developers who want to quickly get started on their services. The major difference in the free and paid plans for both Pusher and PubNub are mostly in the size of messages allowed and how many transactions are available per day. Hence, if you’re building an enterprise application with potentially millions of daily transactions, consider any of the paid plans. However, if you’re building a mini usage app with hundreds or a few thousand messages, the free plans will work conveniently for you.

Pusher docs -pricing

On their free Sandbox plan, Pusher offers:

  • 100 Max Connections
  • Unlimited Channels
  • 200k Messages / Day
  • Limited Support
  • SSL Protection

PubNub’s free plan offers:

Note: Transactions are API requests made to the PubNub network. This includes messages sent and received using Publish and Subscribe APIs.

pubnub docs -pricing

In general terms, the PubNub free plan includes 1M free transactions per month (comprised of any combination of Replicated, Edge, and Function Executions) and 1 GB free Data Persistence per month.

They both offer a paid plan of $49/month with an additional option for a custom plan.

Products

Pusher and PubNub has a wide range of products that make it easy to integrate real-time functionality and other supported features to your apps. We’ll look at their most popular chat products and compare the services they provide.

Pusher ChatKit vs PubNub ChatEngine

| Features | ChatKit | ChatEngine | | ------------------------ | ----------- | ---------- | | Read receipts | Coming soon | ✅ | | Online user presence | ✅ | ✅ | | Typing indicators | ✅ | ✅ | | Webhooks | ✅ | ✅ | | Chatbot | ❌ | ✅ | | Chat group capacity | 100 | Infinite | | Muting | ❌ | ✅ | | Markdown | ❌ | ✅ | | Rich Media Support | Coming soon | ✅ | | Public and private rooms | ✅ | ❌ | | Language Translation | ❌ | ✅ | | Cross-platform | ✅ | ✅ | | Message storage | ✅ | ❌ |

| More Pusher Products | More PubNub Products | | ----------------------------------------------------------------- -------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Channels - Pusher Channels provides real-time communication between servers, apps, and devices. | PubNub DSN - Is a global network infrastructure powering APIs for low-latency real-time messaging to anywhere on Earth. | | Beams - A hosted push notifications API designed for developers who need critical transactional information delivered every time. | Real-time Messaging - This product lets you send and receive cross-platform and cross-device messages with robust yet simple APIs. | | Feeds - Is a product that allows developers build engaging features with an API that instantly delivers updates. | Mobile Push Notifications - Let’s you send APNS and GCM/FCM push notifications combined with real-time messaging for maximum user engagement. | | TextSync - Is a real-time collaborative editor that you can embed into your app in seconds and it’ll let your users collaborate in real-time. | Functions - A PubNub product that provides developers a serverless environment to execute functions on the edge, transforming, enriching, and filtering messages as they route through the PubNub DSN. |

Access Level Control for Websockets and Real-Time Protocols

According to PubNub CTO Stephen Blum on this post, PubNub supports server-side access control. The customer provides PubNub with a token and calls a PubNub API to specify the read/write permissions for that token on one or many channels. The customer then gives that token to the client. PubNub will follow the access control rules for the life of that token. This means that the customer doesn't have to provide authorization servers to ensure access control.

On the other hand, Pusher supports webhooks. Customers provide a REST endpoint to be called whenever a request to Pusher is made. This puts the onus on the customer to develop, maintain, and scale their own authorization servers that must respond in near real-time to calls from Pusher.

Geographic Distribution

PubNub Real-Time Network Every message sent to PubNub is replicated across 14 data centers (including California, Virginia, Ireland, Amsterdam, Sao Paulo, Tokyo, and others). On connection to a PubNub stream, subscribers get automatically routed to their closest data center. It's a bit like a CDN for real-time data. The benefits of this are:

  • Redundancy - across many geographically distributed data centers.
  • *Auto-failover - * If a DC goes down, the users are automatically routed to the next closest data center within seconds, and data they missed during the failover is bundled and sent to them upon reconnection
  • Performance - Users get low latency by always ensuring a minimum distance between them and the closest data center.

Pusher Real-Time Network Pusher is a single data center solution. Pusher does have presence in multiple regions, (Virginia and Ireland), but a customer needs to identify and choose a specific region on which to run their application.

Conclusion

If reaching more users all over the world and delivering extended real-time services is most important to you, then PubNub maybe your better choice here. If however, you’re more interested in fast and efficient message delivery to and from your users with more control over the delivery channels, then Pusher might serve you best.

As always, it's worth evaluating and prototyping with both of them to figure out which service meets your particular needs better.

- No public GitHub repository available -
- No public GitHub repository available -

What is PubNub?

PubNub makes it easy for you to add real-time capabilities to your apps, without worrying about the infrastructure. Build apps that allow your users to engage in real-time across mobile, browser, desktop and server.

What is Pusher?

Pusher is the category leader in delightful APIs for app developers building communication and collaboration features.

Want advice about which of these to choose?Ask the StackShare community!

Why do developers choose PubNub?
Why do developers choose Pusher?
What are the cons of using PubNub?
What are the cons of using Pusher?
Be the first to leave a con
Be the first to leave a con
What companies use PubNub?
What companies use Pusher?
What are some alternatives to PubNub and Pusher?
Firebase
Firebase is a cloud service designed to power real-time, collaborative applications. Simply add the Firebase library to your application to gain access to a shared data structure; any changes you make to that data are automatically synchronized with the Firebase cloud and with other clients within milliseconds.
Socket.IO
Socket.IO enables real-time bidirectional event-based communication. It works on every platform, browser or device, focusing equally on reliability and speed.
Google Cloud Pub/Sub
Cloud Pub/Sub is a fully-managed real-time messaging service that allows you to send and receive messages between independent applications. You can leverage Cloud Pub/Sub’s flexibility to decouple systems and components hosted on Google Cloud Platform or elsewhere on the Internet.
SignalR
SignalR allows bi-directional communication between server and client. Servers can now push content to connected clients instantly as it becomes available. SignalR supports Web Sockets, and falls back to other compatible techniques for older browsers. SignalR includes APIs for connection management (for instance, connect and disconnect events), grouping connections, and authorization.
NATS
Unlike traditional enterprise messaging systems, NATS has an always-on dial tone that does whatever it takes to remain available. This forms a great base for building modern, reliable, and scalable cloud and distributed systems.
See all alternatives
What tools integrate with PubNub?
What tools integrate with Pusher?
Decisions about PubNub and Pusher
No stack decisions found
Interest over time
Reviews of PubNub and Pusher
Avatar of gdi2290
Co-Founder and CTO at Tipe
Review ofPubNubPubNub

PubNub is my goto solution for when I want to use sockets at scale. They have redundant data centers in 14 regions with 99.999% SLA allowing me to build realtime apps for any platform. Also Stephen (PubNub CTO) is Awesome!

How developers use PubNub and Pusher
Avatar of Nathan Heffley
Nathan Heffley uses PusherPusher

In the original prototype all the communication was handled by a backend server. Each client connected directly to the server using the socket.io library. This quickly proved to be messy and unreliable, especially on the cheap server being used to host it.

Websockets proved to be a little more reliable, but still just as messy and not all browsers support them. That's when the project was switched over to use Pusher. Using Pusher has allowed all but the initial connection code to be off-loaded onto the client. Now instead of communicating through a self-hosted server, clients can communicate pretty much peer-to-peer over Pusher.

Avatar of Volkan Özçelik
Volkan Özçelik uses PubNubPubNub

Using websockets is something, scaling a message pipeline to thousands of concurrent connections is something else.

I trust PubNub with what it does best, and use it as zerotoherojs.com ’s messaging pipeline.

With PubNub, I have one less problem to think about.

Avatar of Flutter Health Inc.
Flutter Health Inc. uses PubNubPubNub

Flutter uses PubNub for sending push notifications when the users add new posts to the Flutter Community or leave comments.

Avatar of Jewel Mahanta
Jewel Mahanta uses PusherPusher

Pusher is used to send update notification whenever Lapzbot joins a server.

Avatar of Vamsi Krishna
Vamsi Krishna uses PusherPusher

Push real-time updates

How much does PubNub cost?
How much does Pusher cost?