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

PubNub

237
457
+ 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?

Introduction

PubNub and Pusher are two popular real-time communication platforms used to build interactive applications. While both platforms provide similar functionality, there are several key differences between them that can influence the choice of developers.

  1. Data Centers and Global Reach: PubNub has a larger global network of data centers spread across multiple continents, providing better coverage and reducing latency. Pusher, on the other hand, has data centers primarily in US and Europe, which may result in higher latencies for users located in other regions.

  2. Presence Features: PubNub offers advanced presence functionality, allowing developers to keep track of users currently connected to a channel and their status, including join and leave events. Pusher, on the other hand, provides only basic presence features, such as detecting online/offline status of users.

  3. Scalability: PubNub is designed to handle massive amounts of concurrent connections and high message throughput, making it a suitable choice for applications with large user bases or ones that require real-time updates for a large number of users. Pusher, although capable of handling significant traffic, may have limitations when it comes to extreme scalability requirements.

  4. Pricing Model: PubNub offers a flexible pricing model based on the number of daily active devices, allowing developers to optimize costs based on actual usage. Pusher, on the other hand, follows a fixed pricing model based on the number of connections to channels, which may not be as cost-effective for applications with a fluctuating user base.

  5. Data Retention: PubNub offers a 7-day message history retention by default, allowing applications to access historical data of messages. Pusher, in comparison, provides only a limited message history retention, which may not be sufficient for applications requiring long-term access to historical data.

  6. Integration and Ecosystem: PubNub provides extensive client libraries and SDKs for various platforms, making it easier to integrate with different programming languages and frameworks. Additionally, PubNub offers pre-built integrations with popular services like AWS, Azure, and Google Cloud. Pusher also has good integration support but may not have the same breadth of options or pre-built integrations as PubNub.

In summary, PubNub offers a larger global network, advanced presence features, better scalability, flexible pricing, extensive integration options, and longer message history retention compared to Pusher. However, Pusher may still be suitable for applications with relatively smaller user bases, simplified requirements, European or US-centric focus, or specific integration preferences.

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
Manage your open source components, licenses, and vulnerabilities
Learn More