Web Garden和静态对象难以理解 [英] Web Garden and Static Objects difficult to understand

查看:71
本文介绍了Web Garden和静态对象难以理解的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在调查将我们的Web应用程序转换为Web场的过程.因此,我从转换为最大工作进程= 3"开始使用网络花园.以下是我的问题的简化版本.

I am in the process of investigating to convert our web application to the web farm. So I started with web garden, by converting the 'Maximum Worker Process = 3'. Following is the simplified version of my problem.

以下是我的静态对象类.

Following is my Static Object class.

public static class MyStaticObject
{
public static string MyProperty {get;set;}
}     

然后在页面加载中,我按如下方式初始化了静态对象-

Then on Page Load I initialized the Static Objects as follows -

MyStaticObject.MyProperty = "My Static Property";

然后使用asp.net ajax [WebMethod]在我的网页上创建ajax方法

Then using asp.net ajax [WebMethod] create the ajax method on my web page

[WebMethod()]
public static string getStaticProperty()
{
  return MyStaticObject.MyProperty;
}

//然后,我使用Java脚本调用此Ajax方法,并将返回值设置为文本框.

// Then I call this Ajax method using Javascript and set the return to the text box.

此测试无法正常工作.以下是我的假设和测试的错误结果.

This test is not working as expected. Following are my assumptions and wrong outcome from the test.

  1. 我认为当我们将虚拟目录设置为网络花园时,对虚拟目录的每个请求都将由网络花园中的不同进程处理,因此我对服务器的下一个请求,应在初始化后返回null一个工作过程的静态对象.但是,即使我连续单击ajax按钮20次(表示20个请求),静态对象也会返回我一个值.

  1. I thought when we set virtual directory to be web garden, then each request to the virtual directory is handled by different process in web garden, so my next few request to the server, should return null as I have initialized the static objects for one working process. But even if I click the ajax button for 20 times in row (means 20 requests) even then the static objects return me value.

我认为重新启动IIS应该会杀死所有静态对象.

Am i right in assuming on restarting the IIS should kill all the static objects.

静态对象不在网络花园/网络农场中共享.

Static objects are not shared in web gardens/web farms.

我对IIS,静态对象和Web花园的行为感到惊讶.

I am surprised by the behaviour of IIS, static objects and web garden.

我是在假设错误还是我的测试方法是错误的?

Is I am assuming wrong or my way of testing is wrong.

谢谢.

推荐答案

您对AppPools/网络花园中静态对象的管理方式的假设是正确的.

Your assumptions about the way static objects are managed in AppPools / web gardens is correct.

但是,关于Web请求分发方式的假设却并非如此.只有在建立新的TCP连接时(而不是在新请求到达时),HTTP.sys驱动程序才会将HTTP请求循环到IIS工作进程.由于默认情况下会启用keepalive,即使您连续发出20个请求,它们也可能全部由同一个IIS工作进程处理.

However, your assumption about the way that web requests are distributed is not. HTTP requests are round-robined by the http.sys driver to IIS worker processes only when a new TCP connection is established, not when a new request arrives. Since keepalives are enabled by default, even though you made 20 requests in a row, they probably were all served by the same IIS worker process.

您可以在IIS管理器中设置公共标头"下的"HTTP响应标头"部分中,使IIS禁用keepalive以进行测试.这应该会使您的浏览器为每个请求打开一个新的连接.

You can have IIS disable keepalives for testing purposes from the HTTP Response Headers section in IIS Manager, under Set Common Headers. That should cause your browser to open a new connection for each request.

要测试启用了keepalive的功能,可以使用IIS 6资源工具包附带的Web容量分析工具(WCAT)生成多线程负载,该负载可以访问Web花园中的两个IIS进程.

To test with keepalives enabled, you can use the Web Capacity Analysis Tool (WCAT), available with the IIS 6 Resource Kit, to generate a multi-threaded load that accesses both IIS processes in your web garden.

这篇关于Web Garden和静态对象难以理解的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆