简体   繁体   English

为什么Windows Azure在Thread.Sleep()时不实现负载平衡?

[英]Why do Windows Azure not load balance while Thread.Sleep()?

I am playing with the the Windows Azure emulator running an MVC website with a single controller method that calls Thread.Sleep(5000) before it returns. 我正在使用运行一个MVC网站的Windows Azure模拟器进行操作,该模拟器具有一个在返回之前调用Thread.Sleep(5000)的单一控制器方法。

On the client I run a loop that sends a POST request to the controller every 1000 ms, receives a reply from the server with the RoleEnvironment.CurrentRoleInstance.Id, and prints it on the screen. 在客户端上,我运行一个循环,该循环每1000毫秒向控制器发送一个POST请求,并从服务器接收带有RoleEnvironment.CurrentRoleInstance.Id的答复,并将其打印在屏幕上。

I have 4 instances of my MVC worker role running. 我有4个MVC辅助角色正在运行的实例。

I understand that the connection: keep-alive HTTP header can keep the browser from making a request to a different instance, because an existing connection is open. 我知道该连接:keep-alive HTTP标头可以阻止浏览器向其他实例发出请求,因为现有连接已打开。

But still, even when loading up my site in multiple browser windows, it keeps hanging while waiting for the Thread.Sleep(), and then (most times) continues to get replies from the same instance. 但是,即使在多个浏览器窗口中加载我的网站时,它仍在等待Thread.Sleep()时挂起,然后(大多数情况下)继续从同一实例获取回复。

Why doesn't Azure's load balancer send subsequent requests to a non-busy worker role instance? 为什么Azure的负载平衡器不将后续请求发送到不忙的辅助角色实例? Do I need to manually mark it as busy? 我需要手动将其标记为忙吗?

You mentioned using the emulator, which doesn't handle load balancing the same way as Azure's real load balancers. 您提到使用模拟器,该模拟器不能像Azure真实负载均衡器那样处理负载均衡。 See this post for details about the differences. 有关差异的详细信息,请参见这篇文章 I don't know what exactly is going on in your case, but... I'd suggest you trying this out in Azure to see if you get the behavior you're expecting. 我不知道您的情况到底是怎么回事,但是...我建议您在Azure中尝试一下,看看您是否达到了预期的行为。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM