Reputation: 138
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?
Upvotes: 1
Views: 2357
Reputation: 45664
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.
Upvotes: 8
Reputation: 273464
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.
Upvotes: 1