- April 30
- 9 min
SignalR was created to make it easier to add “real-time” web functionality to your ASP.NET application. Such an application could be a collaboration tool, a dashboard or one that uses push notifications. What are the advantages, what is worth keeping in mind, and will SignalR work in every case? We invite you to read the article.
Table of contents
What is SignalR?
What is the purpose of SignalR?
SignalR Persistent Connections & Hubs
What is SignalR used for?
Azure SignalR service and performance
When to use SignalR?
To better illustrate the role of a real-time tool like SignalR in software development let’s use an example.
A collaborative tool: a web-based Word application.
When more than one user is working on the same document and one is making changes, at the same time the other user sees the changes without reloading the page. Real-time web functionality allows server-side code to receive data from connected clients and transmit data to connected clients.
SignalR supports “server push” functionality. Server code can call client code in the browser using remote procedure calls (RPCs), rather than the request-response model that is common on the Web today. Features of SignalR for ASP.NET:
- support connection management automatically,
- send messages to all connected clients simultaneously,
- send messages to specific clients or groups of clients,
- scale to handle increasing traffic.
SignalR automatically opts for the best transport method within the capabilities of the server and client. SignalR uses several different techniques to make communication possible, including WebSockets (a new HTML5 API that enables bi-directional communication between the browser and server). When WebSockets are not available, it automatically switches to Long Polling, or Server Sent Events.
The SignalR API offers two models for communicating between clients and servers: Persistent Connections and Hubs.
Persistent Connection provides a simple endpoint for sending single, group or broadcast messages.
A hub is a high-level pipeline that allows the client and server to call each other’s methods. SignalR automatically handles sending across machine boundaries, allowing clients to call methods on the server, and it works both ways. Hubs API is recommended for most applications.
SignalR is designed to make it easy to add real-time features to ASP.NET web applications. SignalR is an ideal solution for adding real-time features to web applications, such as chat applications, live dashboards, and collaborative editing tools.
Good possible projects for SignalR could be:
- Applications that require frequent updates from the server, such as gaming, social networking, voting, auction, map and GPS applications.
- Monitoring or dashboards applications. Business dashboards & real-time sales updates or travel notifications.
- Collaboration apps, like white board applications and team meeting software.
- Applications with notifications, such as social networking, email, chat, games, travel notifications & other software requiring notifications.
However, SignalR use depends largely on the individual business requirements of the project. There are use cases for which SignalR will be a great solution and such cases in which the use of this technology will cause performance issues. The decision to use SignalR should be based on project-specific needs.
In terms of performance in big traffic – you can speed up your application using cloud solutions like the Azure SignalR service. Azure SignalR Service is an Azure-managed service designed to help developers build web applications with real-time features more easily.
The benefit of using the Azure SignalR Service is the ease of scaling SignalR applications and the support of Microsoft and the broad developer community. In any commercial undertaking performance is an important factor. Microsoft’s documentation includes several performance cases for SignalR use and optimization.
The Azure SignalR service acts as a message router that routes a message from a set of clients or servers to other clients or servers. Switching to Azure SignalR Service brings to the project development: native ASP.NET Core support, broad client support, use cases, different scenarios, and hosting in a standardized environment.
Backing SignalR with Azure SignalR Service means eliminating the need to manage the back planes that handle customer scales and connections. SignalR Service has a global scope, a world-class data center and a network. Devoted to scaling to millions of connections, it guarantees SLAs while providing all Azure compliance and security.
SignalR is a choice for many developers because it is easy to use and can be added to existing applications with little code changes. SignalR abstracts away many of the complexities of real-time web communication and makes it easier for developers to add real-time functionality to their applications.
As every technology, SignalR has its purpose (use case) and limitations. It is important to be aware of that. SignalR technology should be treated as a supporting feature, good for notifications, sending small pieces of data.
SignalR as a technology works, but it all depends on the specific requirements. Each SignalR use case should be analyzed carefully (in terms of performance and reliability). For example, SignalR won’t be suitable for cash transactions.
If you are considering using SignalR in your application but need a consultation or analysis of your specific case contact us! We will gladly help.
After carefully evaluating suppliers, we decided to try a new approach and start working with a near-shore software house. Cooperation with Hicron Software House was something different, and it turned out to be a great success that brought added value to our company.
With HICRON’s creative ideas and fresh perspective, we reached a new level of our core platform and achieved our business goals.
Many thanks for what you did so far; we are looking forward to more in future!
Hicron is a partner who has provided excellent software development services. Their talented software engineers have a strong focus on collaboration and quality. They have helped us in achieving our goals across our cloud platforms at a good pace, without compromising on the quality of our services. Our partnership is professional and solution-focused!