1

I read elsewhere that when creating a Blazor server-side app, every time a user of your app interacts with the app, the server creates an instance of you app, meaning, if you have 1000 users using your app simultaneously, your hosting server will have to manage 1000 instances of your app simultaneously.

So if that's true, is it also the case with a Asp.net core hosted layer of a Blazor WASM Asp.net Core hosted app? meaning, if you have 1000 users simultaneously sending requests to the WebAPI, will there be 1000 instances created to handle the requests?

5
  • Please provide a reference for "elsewhere." Commented Jun 10, 2020 at 23:13
  • with the blazor wasm it can run offline but if it needs communication then its going to use signalr Commented Jun 10, 2020 at 23:14
  • @RobertHarvey, Let me go and search for the article. brb. Commented Jun 10, 2020 at 23:37
  • 1
    @Robert enet explained it nicely below Commented Jun 11, 2020 at 3:00
  • 1
    @Rahul, that's exactly what I wanted to know... he explained it so clearly. Commented Jun 11, 2020 at 15:12

2 Answers 2

8

Blazor Server App runs on the server and communicates with its client-side (browser) via SignalR. The server does not create an instance of the app for each connection to the app. As the code is executed on the server, and only html diffs are passed to the client in order to update the DOM, the server creates a circuit object for each connecting client, which store the app state, session data, etc. This can be very demanding but still it works, and the server can serves thousands of clients concurrently.

WebAssembly Blazor App hosted works differently. The role of the server is only to serve the app, when it is first accessed. The app itself runs on the client's browser, and everything is performed on the client. The server is not involved here. Performing HTTP calls from Blazor client side to Web Api endpoints is equivalent to performing an AJAX call from the client browser to a Web Api when your web app is, say an MVC app or a Razor Pages App. Actually, behind the scenes, WebAssembly app employs the JavaScript Fetch Api to send HTTP calls to Web Api endpoints.

Sign up to request clarification or add additional context in comments.

1 Comment

Couple questions: Q1. Is server in the Hosted model equivalent to a .NET Core API (that doesn't do SignalR connections to the Blazor WASM client)? Q2. Does it provide any benefits to let's say having a .NET Core API running in the Server (hosted through for eg: Azure App Service) with a Blazor WASM running in the client (hosted through for eg: Static Websites)? Please elaborate on these questions in your answer if possible.
1

every time a user of your app interacts with the app, the server creates an instance of you app,

Not of the entire App but yes, the Server does keep a model of the current Page in memory, along with the SignalR connection.

is it also the case with a Asp.net core hosted layer

No, that is a 'normal' Web API and usually is as stateless as possible.

Running Blazor Server for 1000 users doesn't require extraordinary resources, moderate hosting will handle that. A free hosting plan (like Azure F1) will probably struggle.

But Blazor/Server is not the best platform for millions of users, and it does require fairly good internet connections.

Also see the docs.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.