What is PubNub?
Serverless functions (PubNub Functions).
Authentication and encryption.
Fully-managed edge messaging infrastructure.
PubNub advantages and disadvantages
99.999% uptime SLA (for customers with the Pro package), and compliance with GDPR, SOC 2, CCPA, and HIPAA (the latter is only available for Pro customers).
Provides globally-distributed infrastructure spanning 15 datacenters, with data replication in multiple regions to protect against single points of failure.
PubNub does not guarantee that messages reach subscribers in the exact same order in which they are published. Message delivery is not guaranteed either - there’s a queue limit of 100 messages. If more than 100 messages are published while a user temporarily loses connectivity (e.g., driving through a tunnel), older messages will get discarded, and will never be delivered to the user once they reconnect.
HTTP long polling is used for realtime communication between PubNub servers and clients. Note that long polling is an inferior option to other realtime transports. For example, compared to WebSockets, long polling is more resource-intensive, and has higher latencies.
PubNub has a rather complex pricing model. It’s based on the number of monthly active users (MAUs), plus the number of transactions per month. However, there are tens of different transaction types, making it difficult to calculate and predict ongoing costs. Exceeding the number of MAUs & transactions allowed for your package may result in automatically being upgraded to a more expensive plan, or having your product keys locked.
What is Firebase?
Firebase is a Backend as a Service (BaaS) platform that helps you build, test, release, and monitor web and mobile apps for end-users. Firebase provides numerous features out of the box:
Notifications and in-app messaging. Firebase Cloud Messaging (FCM) allows you to send native push notifications and notification messages across platforms (iOS, Android, web). There’s also Firebase In-App Messaging, a cloud service designed to send contextual messages to app users.
Hosting. Firebase provides secure hosting on Google Cloud.
Authentication using passwords, phone numbers, popular federated identity providers like Google, Facebook and Twitter, and more.
Release and monitor capabilities like app distribution, app updates & feature flags (Remote Config), and performance monitoring.
Firebase advantages and disadvantages
Firebase helps app developers move quickly: you don’t have to worry about hosting, provisioning, and managing backend processes and components like databases, data storage, and authentication. Firebase’s collection of services makes the entire development cycle shorter and more straightforward.
Firebase has good technical documentation, and detailed SDK and API reference, making it easy to get started and use the platform. Going beyond docs, there are about 1.5 million apps built with Firebase, so there’s a pretty big community of experts who can help you with questions and issues.
Most of the Firebase services are free to start with, which is great if you are new to Firebase and simply want to test the platform, and assess if it’s the right choice for your project.
An instance of the Firebase Realtime Database has a limit of 200.000 concurrent connections and 1.000 write operations per second. To scale beyond these limits, you have to use sharding, which is a notoriously difficult process.
Vendor lock-in is an issue when you use Firebase. For example, if one day you conclude that the Realtime Database / Cloud Firestore is unsuitable for your use case, it’s hard to migrate to another (NoSQL) database. This is because of the way data is stored - a JSON tree in the case of the Realtime Database, respectively collections of documents (which are very similar to JSON data) in the case of Cloud Firestore.
There are plenty of horror stories of costs escalating out of control, especially if you are new to Firebase, and don’t yet have a good grasp on the pricing model and how to engineer your apps in a cost-effective manner. See How not to get a $30k bill from Firebase and We burnt $72K testing Firebase + Cloud Run and almost went bankrupt for details.
Comparing PubNub and Firebase
We’ll now look at the high-level similarities and differences between PubNub and Firebase, compare their key features, and cover their use cases.
How are Firebase and PubNub similar?
The first similarity of note is that PubNub and Firebase are technologies you can use to power real time functionality in web and mobile apps. See the PubNub and Firebase use cases section later in this article for details.
Another similarity worth mentioning is that Firebase and PubNub are commercial (paid) solutions that come with fully-managed infrastructure. PubNub is a globally-distributed, multi-region solution. Similarly, Firebase’s Cloud Firestore database can be used in a multi-regional setup.
Up to a point, PubNub and Firebase are similar in terms of the capabilities they provide. Both offer authentication, push notifications, the ability to send low-latency messages to connected clients, message persistence, pub/sub messaging, webhooks, and serverless functions.
Both Firebase and PubNub do reasonably well when it comes to security and compliance. In addition to authentication, Firebase and PubNub offer encryption in transit and at rest, and they’re both compliant with standards like SOC 2 and EU GDPR.
Firebase and PubNub have some shortcomings in common. For example, they don’t offer robust data integrity guarantees (message ordering and delivery are not guaranteed).
How are PubNub and Firebase conceptually different?
Firebase is a BaaS, with the realtime database as the central concept (and realtime messaging as a secondary concept). Meanwhile, PubNub is a PaaS, with realtime messaging as the central concept (and data storage as an optional feature).
The Firebase Realtime Database and Cloud Firestore use WebSockets to sync updates to client devices in realtime. In comparison, PubNub uses HTTP long polling for realtime communication between client and server.
While PubNub and Firebase have plenty of common features, there are some differences between them. Firebase provides a host of capabilities that PubNub doesn’t. Examples include: two database options to choose from, Remote Config, hosting for apps and websites, performance monitoring, app distribution, and A/B testing.
PubNub has the upper hand on Firebase in some areas: client SDKs for more languages, SDKs specifically for chat use cases, better support for presence (in Firebase’s case, presence is only available for the Realtime Database), and a file sharing feature.
PubNub vs. Firebase: head-to-head feature comparison
The table below compares PubNub and Firebase capabilities required to build apps with realtime functionality. (Note that the table is scrollable).
Type of solution
Claims it can handle unlimited concurrent connections and unlimited channels.
The Firebase Realtime Database has a limit of 200.000 concurrent WebSocket connections per instance.
Cloud Firestore can autoscale up to 1 million concurrent connections.
PubNub advertises sub-250ms worldwide latencies.
PubNub has a globally-available mesh architecture with no central point of failure.
Cloud Firestore is available in multi-regional configurations (but the Realtime Database is only a regional service).
99.999% uptime SLA for customers with the Pro package.
Unclear if any SLA is provided for the Starter and Free tiers.
99.95% for Firebase Hosting and the Realtime Database.
99.99 % if you are using Cloud Firestore in a single-region configuration.
99.999% if you are using Cloud Firestore in a multi-region configuration.
Unclear what SLAs (if any) are provided for the rest of the Firebase services.
Guaranteed message ordering
PubNub does not guarantee message order and in general does not guarantee that messages are stored or sent in the exact same order in which they are published.
PubNub is not a guaranteed message delivery service.
Automatic reconnections with continuity
PubNub SDKs support automatic reconnections.
However, there’s a queue limit of 100 messages. If more than 100 messages are published while a user is disconnected, older messages will get discarded, and will never be delivered to the user once they reconnect.
Firebase SDKs support automatic reconnections.
However, there’s a chance that some messages might be lost once an automatic reconnection takes place.
HTTP long polling
WebSockets (used for realtime communication between the realtime databases and clients).
HTTP (used by most other Firebase services).
PubNub offers integrations with tools such as:
- Agora and Vonage (for voice and video calls).
Firebase offers a limited number of integrations, primarily with Google Cloud services, such as Google Pub/Sub and Google Analytics.
Yes (PubNub Functions)
Cloud Functions for Firebase. No support for other serverless platforms, such as AWS Lambda or Azure Functions.
PubNub can store messages for up to 7 days for the Free package, and up to 30 days for the Starter package.
Unlimited message retention is available exclusively to Pro customers.
Firebase provides two different NoSQL databases: the Firebase Realtime Database, and the more recent Cloud Firestore. Indefinite data retention available.
Yes (PubNub channels)
Yes (Firebase Cloud Messaging)
Yes (but only for the Real time Database; this feature is not supported by Cloud Firestore).
TLS and AES-256 encryption, secret API keys and tokens for authentication, compliance with GDPR, SOC 2, CCPA, HIPAA (the latter is only available for Pro customers).
Good security, including an authentication service (Firebase Authentication), a permissions system, encryption in transit & at rest, and compliance with standards such as SOC 2, EU GDPR, and ISO 27001.
Firebase offers client SDKs for iOS, Android, C++, and Unity.
Admin SDKs are available in Node.js, Java, Python, and Go.
The PubNub pricing model is based on:
It’s difficult to calculate and predict ongoing costs. Exceeding the number of MAUs & transactions allowed for your package may result in automatically being upgraded to a more expensive plan, or having your product keys locked.
Note that PubNub also charges for support.
Firebase offers two plans: the free Spark plan, and the Blaze plan (monthly pay as you go), which is recommended for building apps at scale.
Pricing is difficult to calculate, as it's based on a multitude of factors, such as message ingestion & delivery, document read, write, delete operations, data storage, hosting, or function invocations.
There are plenty of horror stories of costs escalating out of control. See, for example, We burnt $72K testing Firebase + Cloud Run and almost went bankrupt.
PubNub and Firebase realtime use cases
PubNub and Firebase can be used for several types of realtime use cases:
In-app live chat.
Data broadcast (1-to-many fanout).
In-app and push notifications.
Multiplayer collaboration environments (e.g, whiteboards, multiplayer games)
Keeping backend services and frontend clients in realtime sync.
However, Firebase and PubNub play different roles in your tech stack and system architecture.
When to use Firebase?
Firebase is probably the better option if:
You’re looking for an all-in-one app development solution that includes diverse features like data storage, database with realtime syncing capabilities, app hosting, push notifications, and authentication.
You’re looking to build your system using other Google Cloud components. Firebase has integrations with Google services like Google Pub/Sub, Google Cloud Functions, Google Ads, Google Data Studio (Looker Studio), Google Cloud BigQuery, and Google Analytics.
You want to benefit from more features to release, manage, test, and monitor your apps.
When to use PubNub?
PubNub is a better fit if:
You are looking for a solution that’s optimized to handle realtime messaging for your apps.
You’re building more complex chat use cases; in addition to its generic SDKs, PubNub offers libraries that are specifically designed to simplify the development of chat functionality.
You need more control over realtime communication. PubNub can be connected to different backend/DB options, and allows you to flexibly tailor realtime communication to your use case. In contrast, Firebase is more restrictive; it offers only two database options, and comes with a pre-designed communication model (it forces you to store all events you want to push to connected clients in the Firebase database).
PubNub and Firebase alternatives for realtime apps
We hope this article is a good starting point for you to discover the advantages, disadvantages, similarities, and differences between PubNub and Firebase.
PubNub and Firebase are fully-managed solutions, removing the need for developers to deal with scaling and maintaining realtime infrastructure (or at least a part of it). Plus, they offer a pretty rich feature set.
However, PubNub and Firebase have their drawbacks. Among them:
Both solutions offer weak data integrity assurances (message ordering and delivery are not guaranteed, especially when disconnections and unreliable network conditions are involved).
PubNub uses HTTP long polling to power realtime communication between client and server. Note that long polling is an inferior option to other realtime transports. For example, compared to WebSockets, long polling is more resource intensive, and has higher latencies.
The Firebase approach of tightly coupling the database with realtime messaging (syncing) doesn’t leave much room for flexibility. Only the updates to your database are published to connected clients. This forces you to permanently store even the transient events that need to be sent to your users, leading to an unnecessary increase in storage costs. Plus, you can’t use Firebase to push updates to client devices from a non-Firebase database. Read more about the caveats of using Firebase for realtime apps.
It is ultimately up to you to decide if PubNub/Firebase is the best choice for your realtime use case. However, if you’re interested in further weighing your options, here are some alternative solutions you can explore:
Discover Ably, the PubNub & Firebase alternative that’s reliable at scale
Ably is a realtime experience infrastructure provider. Our APIs, SDKs, and managed integrations help developers build and deliver realtime experiences without having to worry about maintaining and scaling messy realtime infrastructure.
A globally-distributed network of datacenters and edge acceleration points of presence.
Client SDKs for every major programming language and development platform.
Pub/sub APIs with rich features, such as message delta compression, multi-protocol support (WebSockets, MQTT, Server-Sent Events), automatic reconnections with continuity, presence, and message history.
Guaranteed message ordering and delivery.
Global fault tolerance and a 99.999% uptime SLA.
< 65ms round-trip latency (P99).
Elastic scalability to handle up to millions of concurrent clients, and a constantly fluctuating number of connections and channels.
Find out more about Ably and how we can help with your realtime use case:
PubNub alternatives: 5 competitors to consider in 2023
Learn about similar solutions to PubNub that you can use to build realtime features like chat, asset tracking, live dashboards, and mobile push notifications.
Firebase alternatives: The best competitors to consider in 2023
Discover the best alternatives to the Firebase Backend as a Service platform for realtime messaging and push notifications in 2023.
Pusher vs. Firebase: Pros, cons, and head-to-head feature comparison
Developers can use Firebase & Pusher for realtime use cases like data broadcast, chat, and data sync. But what are the differences between Pusher and Firebase?