DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
View Events Video Library
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Integrating PostgreSQL Databases with ANF: Join this workshop to learn how to create a PostgreSQL server using Instaclustr’s managed service

Mobile Database Essentials: Assess data needs, storage requirements, and more when leveraging databases for cloud and edge applications.

Monitoring and Observability for LLMs: Datadog and Google Cloud discuss how to achieve optimal AI model performance.

Automated Testing: The latest on architecture, TDD, and the benefits of AI and low-code tools.

Related

  • How To Build Self-Hosted RSS Feed Reader Using Spring Boot and Redis
  • Redis-Based Tomcat Session Management
  • Deploy Quarkus Faster in the Cloud With Platform.sh Using the Redis Database
  • Spring Boot Application With Kafka, Elasticsearch, Redis With Enterprise Standards Part 1

Trending

  • TDD With FastAPI Is Easy
  • How To Validate Archives and Identify Invalid Documents in Java
  • Implementing Stronger RBAC and Multitenancy in Kubernetes Using Istio
  • DevSecOps: Integrating Security Into Your DevOps Workflow
  1. DZone
  2. Software Design and Architecture
  3. Microservices
  4. SignalR Scaleout with Redis Backplane

SignalR Scaleout with Redis Backplane

In this example, we’ll see one way of scaling out SignalR applications using something called a backplane.

Daniel D'agostino user avatar by
Daniel D'agostino
·
Sep. 14, 15 · Tutorial
Like (2)
Save
Tweet
Share
12.82K Views

Join the DZone community and get the full member experience.

Join For Free

in “ getting started with signalr ," i provided a gentle introduction to signalr with a few simple and practical examples. the overwhelming response showed that i’m not alone in thinking this is an awesome technology enabling real-time push notifications over the web.

web applications often face the challenge of having to scale to handle large amounts of clients, and signalr applications are no exception. in this example, we’ll see one way of scaling out signalr applications using something called a backplane.

scaleout in signalr

signalrscaleout

“ introduction to scaleout in signalr ” (official documentation) describes how signalr applications can use several servers to handle increasing numbers of clients. when a server needs to push an update, it first pushes it over a message bus called a backplane . this delivers it to the other servers, which can then forward the update to their respective clients.

according to the official documentation, scaleout is supported using azure, redis or sql server as backplanes. third-party packages exist to support other channels, such as signalr.rabbitmq .

scaleout example using redis

“ introduction to scaleout in signalr ” (official documentation) describes how to use signalr as a backplane. to demonstrate this, i’ll build on the chat example code from my “ getting started with signalr ” article.

all we need to scaleout using redis is install the microsoft.aspnet.signalr.redis nuget package, and then set it up in the startup class as follows:


        public void configuration(iappbuilder app)
        {
            globalhost.dependencyresolver.useredis("192.168.1.66", 6379, null, "signalrchat");
            app.mapsignalr();
        }

in the code above, i am specifying the host and port of the redis server, the password (in this case null because i don’t have one), and the name of the pub/sub channel that signalr will use to distribute messages.

to test this, you can get a redis server from the redis download page. redis releases for windows exist and are great for testing stuff, but remember they aren’t officially supported for production environments.

now to actually test it, i’ve set up the same scaleout-enhanced chat application on two different machines, and subscribed to the redis pub/sub channel:

signalr-scaleout-computer1

watching the pub/sub channel reveals what signalr is doing under the hood. there are particular messages going through when the application initializes on each machine, and you can also see the actual data messages going through. so when you write a message in the chat, you can also see it in the pub/sub channel.

but even better than that, you’ll also see it on the client (browser) that’s hooked up to the other machine:

signalr-scaleout-computer2

the magic you need to appreciate here is that these aren’t two browsers connected to the same server; they are actually communicating with different servers on different machines. and despite that, the messages manage to reach all clients thanks to the backplane, which in this case is redis.

caveats

so i’ve shown how it’s really easy to scale out signalr to multiple servers: you need to install a nuget package and add a line of code. and i’ve actually tested it on two machines.

stash-1-244250d58073b0ed1

but that’s not really scaleout. i don’t have the resources to do large-scale testing, and only intended to show how scaleout is implemented with this article. the actual benefits of scaleout depend on the application. as the official documentation warns, the addition of a backplane incurs overhead and can become a bottleneck in some scenarios. you really need to study whether your application is a good fit for this kind of scaleout before going for it.

Redis (company) application

Published at DZone with permission of Daniel D'agostino, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • How To Build Self-Hosted RSS Feed Reader Using Spring Boot and Redis
  • Redis-Based Tomcat Session Management
  • Deploy Quarkus Faster in the Cloud With Platform.sh Using the Redis Database
  • Spring Boot Application With Kafka, Elasticsearch, Redis With Enterprise Standards Part 1

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: