0

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?

1 Answers1

6

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.

Hope this helps...

Arad
  • 1,815
  • 2
  • 19
  • 39
enet
  • 26,272
  • 2
  • 38
  • 70