Need advice about which tool to choose?Ask the StackShare community!

PubNub

244
453
+ 1
238
Pusher

608
1.4K
+ 1
234
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.

s_8AA9BC19EE193ADC188FA7D48B1878844C06B97A4BA0DE4B8CCC6EC026D52D9A_1538055273619_Capture1.PNG

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.

s_8AA9BC19EE193ADC188FA7D48B1878844C06B97A4BA0DE4B8CCC6EC026D52D9A_1538055660617_Capture2.PNG

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

PubNub vs Pusher: What are the differences?

Developers describe PubNub as "Build real-time apps quickly and scale them globally". 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. On the other hand, Pusher is detailed as "Hosted APIs to build realtime apps with less code". Pusher is the category leader in delightful APIs for app developers building communication and collaboration features.

PubNub and Pusher belong to "Realtime Backend / API" category of the tech stack.

Some of the features offered by PubNub are:

  • PubNub SDKs support over 50 of the most popular environments, including: iOS, Android, JavaScript, .NET, Java, Ruby, Python, PHP and many more.
  • Data Push - Establish and maintain persistent socket connections to any device (mobile, browser, desktop and server) and push data to global audiences in less than ¼ of a second
  • Presence - Automatically detect when users enter or leave your app and whether machines are online

On the other hand, Pusher provides the following key features:

  • Easily build scalable in-app notifications, chat, realtime graphs, geotracking and more in your web & mobile apps with our hosted pub/sub messaging API.
  • Send programmable push notifications to iOS and Android devices with delivery and open rate tracking built in.
  • Easily add 1-1 and group Chat to your web & mobile apps. Presence, message storage, rich media, notifications, typing indicators and more.

"Massively scalable & easy to use" is the primary reason why developers consider PubNub over the competitors, whereas "An easy way to give customers realtime features" was stated as the key factor in picking Pusher.

Groupon, Buffer, and Mailchimp are some of the popular companies that use Pusher, whereas PubNub is used by PubNub, Balsamiq, and Blossom. Pusher has a broader approval, being mentioned in 124 company stacks & 42 developers stacks; compared to PubNub, which is listed in 43 company stacks and 12 developer stacks.

Advice on PubNub and Pusher
Needs advice
on
AblyAblyPubNubPubNub
and
PusherPusher

I am building an IoT application that will utilize connected air quality sensors to provide real-time indoor air quality in offices. I want to be able to share this data with a few different databases, etc.

Wondering if anyone has any advice on which real-time streaming API would be best for this sort of application, or even how I should think about it?

See more
Replies (2)
Ben Gamble
Recommends
on
AblyAbly

For IoT, we support MQTT along with websockets and SSE. The pattern you're suggesting that involves harvesting data from devices and soaking into a database is easy to achieve with one of the Ably integrations (Serverless functions/webhook) . Here are some tutorials to do things like this: https://ably.com/tutorials/reactor-event-zapier#step2-mqtt-ably

See more
Philip Rossen
Recommends
on
PusherPusher
at

We use Pusher at www.justlearn.com. It works fine. When you reach more users, Pusher gets expensive. We use Pusher for live chat between users. Their software is easy to use. We have had issues with auth on Pusher.

See more
Get Advice from developers at your company using StackShare Enterprise. Sign up for StackShare Enterprise.
Learn More