- Topics
- /
- Realtime technologies
- /
- Azure Web PubSub vs SignalR: Which one is best for you?
Azure Web PubSub vs SignalR: Which one is best for you?
This article compares Azure Web PubSub and SignalR, two event-driven, WebSocket-based solutions that developers can use to power realtime communication for use cases like live chat, broadcasting high-frequency updates (e.g., live sports scores), and multiplayer collaboration. We’ll go through the following:
What are the advantages and disadvantages of Azure Web Pub/Sub?
Azure Web PubSub vs SignalR: head-to-head feature comparison
What is Azure Web PubSub?
Generally available as of November 2021, Azure Web PubSub is a fully managed realtime messaging service. It allows you to create loosely coupled realtime web applications using WebSockets and the publish/subscribe pattern.
Azure Web PubSub comes with capabilities such as:
Authentication and authorization via JWTs.
The ability to send messages to a particular client, all clients, or a subset of clients.
Hubs (a set of client connections) and groups (a subset of connections to a hub).
Supports various subprotocols, like the JSON WebSocket subprotocol and the Protobuf WebSocket subprotocol.
Azure Web PubSub advantages and disadvantages
What are the key advantages and disadvantages of Azure Web PubSub?
Azure Web PubSub pros
Supports both native and serverless WebSockets (with Azure Functions).
Claims it’s designed for large-scale applications and highly available architectures.
Supports a large variety of clients, such as browsers, desktop and mobile apps, or IoT devices; you can use any standard WebSocket client (in your language of choice) with Azure Web PubSub.
Azure Web PubSub cons
Azure Web PubSub is a regional service, which can negatively impact its performance, reliability, and availability.
Azure Web PubSub doesn’t provide a robust messaging QoS. Message ordering and guaranteed delivery are theoretically only possible when you use reliable WebSocket subprotocols (Reliable Protobuf WebSocket and Reliable JSON WebSocket). However, both these subprotocols are currently in developer preview, and some changes are to be expected in the future.
Lacks features such as presence, message history (incredibly helpful for use cases such as chat), and delta compression (useful for reducing bandwidth costs and increasing throughput).
What is SignalR?
SignalR is a technology that enables you to add realtime functionality to web apps. SignalR comes in several different flavors - it’s available as an open-source library for ASP. NET developers (ASP .NET Core SignalR), but also as a fully managed service (Azure SignalR Service).
SignalR uses WebSocket as the main underlying transport, while providing additional features, such as:
Automatic reconnections.
Alternative transports (long polling and Server-Sent Events).
The ability to send messages to all connected clients simultaneously, or to specific (groups of) clients.
Hubs. A SignalR Hub is a high-level pipeline that enables connected servers and clients to invoke methods on each other.
SignalR advantages and disadvantages
What are the key advantages and disadvantages of SignalR?
SignalR pros
SignalR uses efficient message serialization techniques (e.g., MessagePack) to reduce the amount of bandwidth required for realtime communication. This is particularly important for mobile devices and other low-bandwidth networks.
Part of the ASP. NET Framework, which makes it easy to use SignalR in combination with other ASP.NET features like authentication, authorization, and dependency injection.
SignalR is flexible: it supports three transport protocols, and you can use it for 1:1 and 1:many messaging, as well as for client-to-server and server-to-client streaming.
SignalR cons
SignalR offers rather weak messaging QoS; ordering and delivery are not guaranteed. You’d have to develop your own mechanism to ensure robust messaging (e.g., adding sequencing information to messages themselves).
SignalR offers a limited number of client SDKs: C#, Java, Python, and JavaScript. There are no SDKs for platforms and languages like iOS, Android, Go, Ruby, or PHP.
Scaling ASP.NET Core SignalR is difficult, expensive, and time-consuming. You can abstract away the pain of managing SignalR yourself by using the managed version, Azure SignalR Service. However, SignalR Service has its limitations; for example, it provides a 99.95% uptime guarantee for premium accounts, which amounts to almost 4.5 hours of downtime per year. The situation is worse for non-premium accounts, where the SLA provided is 99.9% (almost 9 hours of annual downtime).
Comparing Azure Web PubSub and SignalR
We’ll now compare the features and capabilities of Azure Web PubSub and SignalR to highlight their similarities and differences. We’ll also cover Azure Web PubSub and SignalR use cases, and discuss when it’s best to use each of these two solutions.
Azure Web PubSub vs SignalR: head-to-head feature comparison
The table below compares Azure Web PubSub and SignalR features and capabilities. Note that this comparison is created based on documentation and resources freely available online. If you do find anything incorrect or out of date, then please let us know.
Feature/Capability | ASP.NET Core SignalR | Azure SignalR Service | Azure Web PubSub |
---|---|---|---|
Type of solution | Open-source realtime library | Cloud-based service on Azure | Cloud-based service on Azure |
Pricing | N/A | The free plan includes one unit, which has a cap of 20.000 messages per day and can sustain 20 concurrent connections. The standard and premium plans allow you to scale up to 100 units, and a maximum of 1.000 connections per unit. The price per unit is $1.61 (standard plan), respectively $2 (premium plan). You are also charged $1 per million messages. | The free plan includes one unit, which has a cap of 20.000 messages per day and can sustain 20 concurrent connections. The standard and premium plans allow you to scale up to 100 units, and a maximum of 1.000 connections per unit. The price per unit is $1.61 (standard plan), respectively $2 (premium plan). You are also charged $1 per million messages. |
Infrastructure | You have to self host / manage it yourself. | Hosted / managed for you. | Hosted / managed for you. |
Scalability | Unclear to what extent you can scale ASP.NET Core SignalR, but it’s a difficult challenge. | It can supposedly scale to millions of client connections. | Claims it can scale to millions of concurrent connections. |
Uptime SLA | N/A | 99.9% for free and standard accounts (this amounts to 8h 45m 56s downtime per year). 99.95% for premium accounts (this amounts to 4h 22m 58s downtime per year). | 99.9% for free and standard accounts (this amounts to 8h 45m 56s downtime per year). 99.95% for premium accounts (this amounts to 4h 22m 58s downtime per year). |
Single-region or multi-region? | ASP.NET Core SignalR is designed to work in a single region. | Azure SignalR Service is a regional service - your service instance is always running in a single region. | Azure Web PubSub is a regional service - your service instance is always running in a single region. |
Guaranteed message ordering | No | No | Message ordering is possible only when reliable JSON WebSocket or Reliable Protobuf WebSocket subprotocols are used. |
Guaranteed message delivery (exactly-once) | No | No | Exactly-once delivery is possible only when reliable JSON WebSocket or Reliable Protobuf WebSocket subprotocols are used. |
Reconnections with continuity | Provides automatic reconnections, but some messages may never get delivered upon reconnection. | Provides automatic reconnections, but some messages may never get delivered upon reconnection. | Connection recovery with continuity is possible only when reliable JSON WebSocket or Reliable Protobuf WebSocket subprotocols are used. |
Native push notifications | No | No | No |
Transport protocol(s) | - WebSockets | - WebSockets | WebSockets |
Multiplexing | Yes | Yes | Yes |
Webhooks | You can send webhooks to SignalR via bindings for Azure Functions. However, SignalR can only consume webhooks, but it cannot send webhooks to other systems. | You can send webhooks to SignalR via bindings for Azure Functions. However, SignalR can only consume webhooks, but it cannot send webhooks to other systems. | Yes |
Integrations | Easy integration with Azure services (e.g. Azure Functions, Azure Active Directory, Azure Policy, Azure App Service). Also provides an integration with Redis for horizontal scaling. No integrations with non-Azure products. | Easy integration with other Azure products (e.g. Azure Functions, Azure Active Directory, Azure Policy). No integrations with non-Azure products. | Easy integration with other Azure products (e.g. Azure Functions, Azure Static Web Apps). No integrations with non-Azure products. |
Serverless functions | Azure Functions. No support for other serverless platforms like AWS Lambda or Google Cloud Functions. | Azure Functions. No support for other serverless platforms like AWS Lambda or Google Cloud Functions. | Azure Functions. No support for other serverless platforms like AWS Lambda or Google Cloud Functions. |
Message history | No | No | No |
Pub/Sub messaging | No | No | Yes |
Broadcast support | Yes | Yes | Yes |
Security | Basic native security capabilities (e.g., supports CORS). Makes it easy to leverage .NET Core security features, like ASP. NET core authentication. | Benefits from Azure cloud security, including encryption, authentication, and compliance with standards like SOC 2 and EU GDPR. | Benefits from Azure cloud security, including encryption, authentication, and compliance with standards like SOC 2 and EU GDPR. |
SDKs | Limited number of client SDKs, for languages like .NET, Java, JavaScript. No support for languages like Python, Golang, Swift, C++. | Limited number of client SDKs, for languages like .NET, Java, JavaScript. No support for languages like Python, Golang, Swift, C++. | 4 server SDKs (C#, Java, JavaScript, Python). You can build/use standard WebSocket clients in different programming languages and connect them to Azure Web PubSub. |
Azure Web PubSub and SignalR use cases
Azure Web PubSub and SignalR can be used in web apps that require realtime content updates. They’re both WebSocket solutions that allow you to power real time communication for use cases such as:
Live chat. 1-to-1 chat, chat rooms, chat bots, support chat, in-game chat.
Data broadcast. High-frequency data updates sent in a 1-to-many fashion, such as live scores and traffic updates, live captions, voting, polling, and auction apps.
Multiplayer collaboration. Whiteboards and co-authoring apps (such as Google Docs).
Notifications across social media and chat apps, online marketplaces, gaming, travel and transportation, etc.
Live location tracking for logistics, fleet management, urban mobility, and food delivery apps.
As they address the same use cases, you’re probably wondering: when is it best to use Azure Web PubSub, and when to use SignalR?
When to use Azure Web PubSub Service?
Azure Web PubSub is a better choice than SignalR if:
You’re looking to build realtime functionality using pub/sub over WebSockets.
You’re interested in developing your own subprotocol on top of raw WebSockets or wish to use existing Azure Web PubSub subprotocols (e.g., Reliable Protobuf WebSocket subprotocol).
You have simpler application messaging patterns that you wish to implement using raw WebSockets.
You’re looking for a bit more flexibility (there’s no client or protocol requirement with Azure Web PubSub service, you’re free to use the WebSocket library of your choice on the client side).
When to use SignalR?
You should use SignalR instead of Azure Web PubSub if:
You’re a .NET developer or you need to integrate with the .NET ecosystem (e.g., Blazor).
There’s a SignalR client available for your platform.
You’re already using SignalR and you’re happy with it.
You need a solution that supports various calling patterns (RPC and streaming) and multiple transports (WebSocket, but also Server-Sent Events and HTTP long polling as fallbacks).
You want to use WebSocket clients that manage the connection lifetime on your behalf.
Azure Web PubSub and SignalR alternatives
We hope this article is a good starting point for you to discover the advantages, disadvantages, similarities, and differences between Azure Web PubSub and SignalR.
Azure Web PubSub and SignalR are both useful solutions that allow you to build realtime features with WebSockets. However, they have their limitations. Among them:
Azure Web PubSub and SignalR are regional solutions rather than globally-distributed services. This may lead to issues such as increased latency for some users, and unreliability (single point of failure and congestion).
They both offer rather weak assurances when it comes to data integrity (guaranteed message ordering and delivery).
They lack features like presence and message history that would simplify building realtime apps. In addition, they offer a limited set of integrations (only with Azure products).
There are, of course, plenty of Azure Web PubSub and SignalR alternatives you can explore. Some of these alternatives offer a richer feature set and stronger guarantees around reliability and data integrity, which might make them a better fit for your use case.
Ably, your scalable & reliable alternative to Azure Web PubSub and SignalR
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 WebSocket infrastructure.
Key Ably features and capabilities:
Pub/sub messaging over serverless WebSockets, with rich features such as message delta compression, automatic reconnections with continuity, user presence, message history, and message interactions.
Push notifications and webhooks.
Client SDKs for every major programming language and development platform.
Integrations with streaming solutions like Apache Kafka & Amazon Kinesis, and serverless platforms such as AWS Lambda, Microsoft Azure Functions, and Google Cloud Functions.
A globally-distributed network of datacenters and edge acceleration points-of-presence.
Guaranteed message ordering and delivery.
Global fault tolerance and a 99.999% uptime SLA.
< 65ms round-trip latency (P99).
Dynamic elasticity, so we can quickly scale to handle any demand (billions of WebSocket messages sent to millions of pub/sub channels and WebSocket connections).
Find out more about Ably and how we can help with your realtime use case:
Recommended Articles
Scaling SignalR: Available options and key challenges
Learn how to scale ASP.NET Core SignalR and Azure SignalR Service, and discover the challenges you’ll face along the way.
SignalR vs. Firebase: Learn about their differences, similarities, and use cases
We compare Firebase and SignalR, two popular realtime technologies. Discover their advantages and disadvantages, and compare their features.