Wednesday, January 1, 2014

SignalR Performance and Scalability



ASP.NET Core SignalR is a library by Microsoft (now opensource) which allows server to communicate with client side web apps asynchronously. Performance and scalabality is a major consideration developers needs to consider when developing applications.

Performance tips

Reduce SignalR message size
You can reduce this by reducing size of your serialized objects. In Server, if you're sending an object that contains properties that don't need to be transmitted to client, use JsonIgnore attribute to make them not pass through. 

You can also reduce property name sizes using JsonProperty attribute. To make things readable in client side you can remap them to a meaningful name. 

Since messages are stored in the message bus in server memory, reducing the size of messages can also address server memory issues.

SignalR 
DefaultMessageBufferSize : By default SignalR keeps 1000 messages in memory per hub per connection. If large messages are transferred, this can create memory issues. This setting can be set in Application_Start event. Reducing this make server utilize memory in a better way (If using large messages)

IIS Settings
Max concurrent requests per application: Increasing the number of concurrent IIS requests will increase server resources available for serving requests.

ApplicationPool QueueLength: This is the maximum number of requests that Http.sys queues for the application pool. When the queue is full, new requests receive a 503 “Service Unavailable” response. The default value is 1000.

Shortening the queue length for the worker process in the application pool hosting your application will conserve memory resources.

Troubleshooting tips

You can use SignalR performance counter to measure no. of events since last application pool or server restart.

To measure performance, SignalR team uses Crank.

Scalability
You can scale up (larger server) or scale out (multiple servers). When scaling out since we have multiple servers one server might not be up to date with messages recieved by the other server. Therefore you need to use a backplane.

http://www.asp.net/signalr/overview/getting-started/real-time-web-applications-with-signalr This article also includes how to create BackPlane using SQL Server

Resources

9 comments:

Powered by Blogger.


Software Architect at Surge Global/ Certified Scrum Master

Experienced in Product Design, Software Engineering, Team management and Practicing Agile methodologies.

Search This Blog

Facebook