英文:
How does Blazor carry objects across servers when load balancing
问题
I have some Blazor server side code that I can reduce down to this little bit:
@foreach (var employee in Employees)
{
<tr>
<td class="btn-group-sm">
<button class="btn btn-outline-danger"
@onclick="() => HandleDelete(employee)">
Delete
</button>
</td>
</tr>
}
And that calls HandleDelete(employee)
on a click, passing the employee object that it has persisted in the session data (I assume) to pass when the click occurs.
However, if I have multiple servers being load balanced, what happens if the submit event is sent to a different server? That different server won't have the employee object (I believe).
Does this all depend on the HTTPS session staying connected to the original server, and all subsequent communication going to that server?
And if so, in a fail-over situation, what happens? In that case, it's definitely a connection to a new server getting that submit action.
英文:
I have some Blazor server side code that I can reduce down to this little bit:
@foreach (var employee in Employees)
{
<tr>
<td class="btn-group-sm">
<button class="btn btn-outline-danger"
@onclick="() => HandleDelete(employee)">
Delete
</button>
</td>
</tr>
}
And that calls HandleDelete(employee) on a click passing the employee object that it has persisted in the session data (I assume) to pass when the click occurs.
However, if I have multiple servers being load balanced, what happens if the submit event is sent to a different server? That different server won't have the employee object (I believe).
Does this all depend on the https session staying connected to the original server and all subsequent communication going to that server?
And if so, in a fail-over situation, what happens. In that case it's definitely a connection to a new server getting that submit action.
答案1
得分: 0
Blazor Server不支持完全的负载均衡。客户端应始终与同一服务器上相同的Blazor电路保持连接。
这可以通过在负载均衡器上使用粘性会话、使用Azure SignalR服务或使用SkipNegotiation设置来实现。
使用SkipNegotiation设置时,负载均衡器应将所有SignalR消息广播到所有节点。
https://learn.microsoft.com/en-us/aspnet/core/signalr/scale
英文:
Blazor Server does not support full load balancing. The client should always stay connected with the same Blazor circuit on the same server.
This can be accomplished by using sticky sessions on the load balancer, by using the Azure SignalR service or by using the SkipNegotiation setting.
When using the SkipNegotiation setting, the load balancer should broadcast all SignalR messages to all nodes.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论