1

I have a Blazor Server app hosted on an Azure App Service which seems to be quite "chatty" as it is handling some UI events on the browser such as drag and drop events. I've added trace logs to have some sort of estimate of how many SignalR messages are being used and their size.

I have the following in my Program.cs

public static IHostBuilder CreateHostBuilder(string[] args) =>
        Host.CreateDefaultBuilder(args)
            .ConfigureLogging(logging =>
            {
                logging.ClearProviders();
                logging.AddConsole();
                // Logs to trace Blazor SignalR traffic.
                logging.AddFilter("Microsoft.AspNetCore.SignalR", LogLevel.Trace);
                logging.AddFilter("Microsoft.AspNetCore.Http.Connections", LogLevel.Trace);
            })

            .ConfigureWebHostDefaults(webBuilder =>
            {
                webBuilder.UseStartup<Startup>();
            });
}

This gives me a quite extensive log output which looks something like this:

trce: Microsoft.AspNetCore.Http.Connections.Internal.Transports.WebSocketsTransport[9]
     Message received. Type: Binary, size: 319, EndOfMessage: True.
dbug: Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher[1]
     Received hub invocation: InvocationMessage { InvocationId: "", Target: "DispatchBrowserEvent", Arguments: [ {"browserRendererId":0,"eventHandlerId":366,"eventArgsType":"mouse","eventFieldInfo":null}, {"type":"click","detail":1,"screenX":386,"screenY":-443,"clientX":700,"clientY":514,"offsetX":70,"offsetY":21,"button":0,"buttons":0,"ctrlKey":false,"shiftKey":false,"altKey":false,"metaKey":false} ], StreamIds: [  ] }.
trce: Microsoft.AspNetCore.Http.Connections.Internal.Transports.WebSocketsTransport[11]
     Sending payload: 1078 bytes.
trce: Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher[7]
     InvocationId (null): Sending result of type 'System.Void'.
trce: Microsoft.AspNetCore.Http.Connections.Internal.Transports.WebSocketsTransport[9]
     Message received. Type: Binary, size: 28, EndOfMessage: True.
dbug: Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher[1]
     Received hub invocation: InvocationMessage { InvocationId: "", Target: "OnRenderCompleted", Arguments: [ 1237,  ], StreamIds: [  ] }.
trce: Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher[7]
     InvocationId (null): Sending result of type 'System.Void'.
trce: Microsoft.AspNetCore.Http.Connections.Internal.Transports.WebSocketsTransport[11]
     Sending payload: 13216 bytes.

I can see large messages being sent there, which I assume are caused by the initial data being loaded on the server size (from a database) and passed to components to render information. Smaller UI events produce tons of smaller 75-byte messages (apparently).

I'm applying some regex work to get the info I need from those logs, without being certain of the accuracy of the information gathered.

What's the best/right way to and count SignalR messages (both, in amount of messages and size per message)?

I want to estimate if using an Azure SignalR service would be a feasible solution to scale my app.

How Azure SignalR messages are counted for billing is described here.

My tests so far with the free tier of SignalR puts me exceeding the 20 thousand free messages per day in minutes. When testing a standard tier with 1 million free messages/day I can see how hundreds of thousands of messages have already used within an hour.

I have hunted down things that produce unwanted (or very large) messages on my app, yet something seems out of control; I need to measure this correctly.

Giancarlo Sierra
  • 391
  • 1
  • 6
  • 15

1 Answers1

0

Thank You SnehaAgrawal-MSFT Posting your suggestion as an answer to help other community members .

"You may refer to this Doc on resource logs for Azure SignalR Service are and how to set them up, and how to troubleshoot with them.

To add to this for the SignalR resource in a free tier instance has a message limit of 20000 per day.

Please check this Microsoft document on how messages are counted in SignalR service.

If large messages split into smaller ones and counted as multiple messages, In this case connections gets throttled.

If the message count is expected, then the only solution is to scale the instance to Standard tier which doesn’t have a hard message count limit."

Please refer this Microsoft Document for more information: . Evaluation for complex use cases for Azure SignalR Service

AjayKumarGhose
  • 4,257
  • 2
  • 4
  • 15