I am looking for information on how to create an ASP.NET web farm - that is, how to make an ASP.NET application (initially designed to work on a single web server) work on 2, 3, 10, etc. servers?
我正在寻找有关如何创建ASP.NET Web场的信息 - 也就是说,如何使ASP.NET应用程序(最初设计为在单个Web服务器上工作)在2,3,10等服务器上运行?
We created a web application which works fine when, say, there are 500 users at the same time. But now we need to make it work for 10 000 users (working with the web app at the same time).
我们创建了一个Web应用程序,当时有500个用户同时工作正常。但现在我们需要让它适用于10 000个用户(同时使用Web应用程序)。
So we need to set up 20 web servers and make something so that 10 000 users could work with the web app by typing "www.MyWebApp.ru" in their web browsers, though their requests would be handled by 20 web-servers, without their knowing that.
因此,我们需要设置20个Web服务器,并通过在其Web浏览器中键入“www.MyWebApp.ru”来使10 000个用户可以使用Web应用程序,尽管他们的请求将由20个Web服务器处理,他们知道这一点。
1) Is there special standard software to create an ASP.NET web farm?
1)是否有特殊的标准软件来创建ASP.NET Web场?
2) Or should we create a web farm ourselves, by transferring requests between different web servers manually (using ASP.NET / C#)?
2)或者我们是否应该通过手动(使用ASP.NET / C#)在不同Web服务器之间传输请求来自己创建Web场?
I found very little information on ASP.NET web farms and scalability on the web: in most cases, articles on scalability tell how to optimize and ASP.NET app and make it run faster. But I found no example of a "Hello world"-like ASP.NET web app running on 2 web servers.
我发现很少有关于ASP.NET Web场的信息和Web上的可伸缩性:在大多数情况下,关于可伸缩性的文章讲述了如何优化ASP.NET应用程序并使其运行得更快。但我没有找到在2个Web服务器上运行的“Hello world”类ASP.NET Web应用程序的示例。
Would be great if someone could post a link to an article or, better, tell about one's own experience in ASP.NET "web farming" and addressing scalability issues.
如果有人可以发布文章的链接,或者更好地讲述自己在ASP.NET“web耕作”中的经验并解决可扩展性问题,那将会很棒。
Thank you, Mikhail.
谢谢你,米哈伊尔。
4 个解决方案
#1
5
1) Is there special standard software to create an ASP.NET web farm?
1)是否有特殊的标准软件来创建ASP.NET Web场?
No.
没有。
2) Or should we create a web farm ourselves, by transferring requests between different web servers manually (using ASP.NET / C#)?
2)或者我们是否应该通过手动(使用ASP.NET / C#)在不同Web服务器之间传输请求来自己创建Web场?
No.
没有。
To build a web farm, you will need some form of load balancing. For up to 8 servers or so, you can use Network Load Balancing (NLB), which is built in to Windows. For more than 8 servers, you should use a hardware load balancer.
要构建Web场,您需要某种形式的负载平衡。对于最多8台服务器,您可以使用内置于Windows的网络负载平衡(NLB)。对于8台以上的服务器,您应该使用硬件负载平衡器。
However, load balancing is really just the tip of the iceberg. There are many other issues that you should address, including things like:
然而,负载平衡实际上只是冰山一角。还有许多其他问题需要解决,包括:
- State management (cookies, ViewState, session state, etc)
- 状态管理(cookie,ViewState,会话状态等)
- Caching and cache invalidation
- 缓存和缓存失效
- Database loading (managing round-trips, partitioning, disk subsystem, etc)
- 数据库加载(管理往返,分区,磁盘子系统等)
- Application pool management (WSRM, pool resets, partitioning)
- 应用程序池管理(WSRM,池重置,分区)
- Deployment
- 部署
- Monitoring
- 监控
In case it might be helpful, I cover many of these issues in my book: Ultra-Fast ASP.NET: Build Ultra-Fast and Ultra-Scalable web sites using ASP.NET and SQL Server.
如果它可能有用,我在本书中讨论了许多这些问题:超快速ASP.NET:使用ASP.NET和SQL Server构建超快速和超可扩展的网站。
#2
3
I'd say you should configure an NLB cluster (Network Load Balancing), which basically splits all requests between cluster nodes (And as an added benefit detects if things are down and stops sending them requests). There's features built into windows for this, but they don't compare to a hardware device for performance or scalability. If you're using Windows 2008 it really is simple to set one up. If you do this make sure you have a shared machine key or you'll start getting exceptions for viewstate being invalid (When 1 server submits the form and it posts to the other and they're using different keys to encode the data).
我会说你应该配置一个NLB集群(网络负载平衡),它基本上会在集群节点之间拆分所有请求(并且作为一个额外的好处来检测事情是否已关闭并停止发送请求)。 Windows中内置了这些功能,但它们与硬件设备的性能或可扩展性无法比较。如果你使用的是Windows 2008,那么设置它真的很简单。如果这样做,请确保您拥有共享计算机密钥,或者您将开始获取视图状态无效的异常(当1个服务器提交表单并且它发布到另一个并且他们使用不同的密钥对数据进行编码时)。
You can also use DNS round-robin but at 20 servers presumably in 1 datacenter I wouldn't see a point to going to such crazy lengths. If you've got multiple data centers though this is definitely worth considering (As NLB won't really work well between data centers).
您也可以使用DNS循环法,但在20个服务器上大概在1个数据中心,我不会看到这样疯狂的长度。如果你有多个数据中心,虽然这绝对值得考虑(因为NLB在数据中心之间不会很好地工作)。
You'll also want to be sure if a user swaps servers they don't loose their session. The simplest way would be to use a Session State database (Configurable in the web.config, or you can do it server-wide in IIS's configs). If you don't use sessions though just turn them off in the Pages directive of the web.config and call it a day. You could also use a session state server, but I don't have any experience with this.
您还需要确保用户是否交换服务器,而不会丢失其会话。最简单的方法是使用会话状态数据库(在web.config中可配置,或者您可以在IIS的配置中在服务器范围内执行此操作)。如果您不使用会话,只需在web.config的Pages指令中关闭它们并将其称为一天。您也可以使用会话状态服务器,但我对此没有任何经验。
It may also be worth considering spending some time optimizing the code or adding caching directives to static content - it can be very cost-effective even if you only trim the need for a few of those servers.
考虑花一些时间优化代码或将缓存指令添加到静态内容也是值得考虑的 - 即使您只需要减少对这些服务器中的一些服务器的需求,它也可能非常划算。
Hope that helps.
希望有所帮助。
#3
2
If you keep your server stateless, it is easy with a good router that implements some round-Robbin protocol (that send each call to the single published server ip to a different web server).
如果你的服务器保持无状态,那么很好的路由器可以实现一些循环Robbin协议(将每个调用发送到单个已发布服务器的ip到不同的Web服务器)。
if it is not stateless (like - if a login is required, or ssl) than you need to keep each session to the same server.
如果它不是无状态的(比如 - 如果需要登录,或ssl),则需要将每个会话保持在同一服务器上。
Here is some info about MS Application Request Routing - you will get everything there:
以下是有关MS应用程序请求路由的一些信息 - 您将获得所有内容:
IIS负载平衡
#4
0
I would not recommend #2. You will do much better off with a load balancer.
我不建议#2。使用负载均衡器可以做得更好。
Pay attention to session state management. Unless you configure the load balancer to keep each user on the same web server, you will have to use the session state server or database.
注意会话状态管理。除非您将负载均衡器配置为使每个用户保持在同一Web服务器上,否则您将必须使用会话状态服务器或数据库。
Also, check your code's usage of Application and Cache variables. These will be different on every web server. If those values are static, you may not have a problem. But if they can change, you can end up with different values on each web server.
另外,检查代码对Application和Cache变量的使用情况。这些在每个Web服务器上都会有所不同。如果这些值是静态的,则可能没有问题。但是,如果它们可以更改,您可以在每个Web服务器上获得不同的值。
There used to be a problem with ViewState in 1.x, as explained here. I'm not sure if this problem still exists.
在1.x中,ViewState一直存在问题,如此处所述。我不确定这个问题是否仍然存在。
Then, there are some changes that you need to make to the Machine Key in web.config, as explained here.
然后,您需要对web.config中的Machine Key进行一些更改,如此处所述。
#1
5
1) Is there special standard software to create an ASP.NET web farm?
1)是否有特殊的标准软件来创建ASP.NET Web场?
No.
没有。
2) Or should we create a web farm ourselves, by transferring requests between different web servers manually (using ASP.NET / C#)?
2)或者我们是否应该通过手动(使用ASP.NET / C#)在不同Web服务器之间传输请求来自己创建Web场?
No.
没有。
To build a web farm, you will need some form of load balancing. For up to 8 servers or so, you can use Network Load Balancing (NLB), which is built in to Windows. For more than 8 servers, you should use a hardware load balancer.
要构建Web场,您需要某种形式的负载平衡。对于最多8台服务器,您可以使用内置于Windows的网络负载平衡(NLB)。对于8台以上的服务器,您应该使用硬件负载平衡器。
However, load balancing is really just the tip of the iceberg. There are many other issues that you should address, including things like:
然而,负载平衡实际上只是冰山一角。还有许多其他问题需要解决,包括:
- State management (cookies, ViewState, session state, etc)
- 状态管理(cookie,ViewState,会话状态等)
- Caching and cache invalidation
- 缓存和缓存失效
- Database loading (managing round-trips, partitioning, disk subsystem, etc)
- 数据库加载(管理往返,分区,磁盘子系统等)
- Application pool management (WSRM, pool resets, partitioning)
- 应用程序池管理(WSRM,池重置,分区)
- Deployment
- 部署
- Monitoring
- 监控
In case it might be helpful, I cover many of these issues in my book: Ultra-Fast ASP.NET: Build Ultra-Fast and Ultra-Scalable web sites using ASP.NET and SQL Server.
如果它可能有用,我在本书中讨论了许多这些问题:超快速ASP.NET:使用ASP.NET和SQL Server构建超快速和超可扩展的网站。
#2
3
I'd say you should configure an NLB cluster (Network Load Balancing), which basically splits all requests between cluster nodes (And as an added benefit detects if things are down and stops sending them requests). There's features built into windows for this, but they don't compare to a hardware device for performance or scalability. If you're using Windows 2008 it really is simple to set one up. If you do this make sure you have a shared machine key or you'll start getting exceptions for viewstate being invalid (When 1 server submits the form and it posts to the other and they're using different keys to encode the data).
我会说你应该配置一个NLB集群(网络负载平衡),它基本上会在集群节点之间拆分所有请求(并且作为一个额外的好处来检测事情是否已关闭并停止发送请求)。 Windows中内置了这些功能,但它们与硬件设备的性能或可扩展性无法比较。如果你使用的是Windows 2008,那么设置它真的很简单。如果这样做,请确保您拥有共享计算机密钥,或者您将开始获取视图状态无效的异常(当1个服务器提交表单并且它发布到另一个并且他们使用不同的密钥对数据进行编码时)。
You can also use DNS round-robin but at 20 servers presumably in 1 datacenter I wouldn't see a point to going to such crazy lengths. If you've got multiple data centers though this is definitely worth considering (As NLB won't really work well between data centers).
您也可以使用DNS循环法,但在20个服务器上大概在1个数据中心,我不会看到这样疯狂的长度。如果你有多个数据中心,虽然这绝对值得考虑(因为NLB在数据中心之间不会很好地工作)。
You'll also want to be sure if a user swaps servers they don't loose their session. The simplest way would be to use a Session State database (Configurable in the web.config, or you can do it server-wide in IIS's configs). If you don't use sessions though just turn them off in the Pages directive of the web.config and call it a day. You could also use a session state server, but I don't have any experience with this.
您还需要确保用户是否交换服务器,而不会丢失其会话。最简单的方法是使用会话状态数据库(在web.config中可配置,或者您可以在IIS的配置中在服务器范围内执行此操作)。如果您不使用会话,只需在web.config的Pages指令中关闭它们并将其称为一天。您也可以使用会话状态服务器,但我对此没有任何经验。
It may also be worth considering spending some time optimizing the code or adding caching directives to static content - it can be very cost-effective even if you only trim the need for a few of those servers.
考虑花一些时间优化代码或将缓存指令添加到静态内容也是值得考虑的 - 即使您只需要减少对这些服务器中的一些服务器的需求,它也可能非常划算。
Hope that helps.
希望有所帮助。
#3
2
If you keep your server stateless, it is easy with a good router that implements some round-Robbin protocol (that send each call to the single published server ip to a different web server).
如果你的服务器保持无状态,那么很好的路由器可以实现一些循环Robbin协议(将每个调用发送到单个已发布服务器的ip到不同的Web服务器)。
if it is not stateless (like - if a login is required, or ssl) than you need to keep each session to the same server.
如果它不是无状态的(比如 - 如果需要登录,或ssl),则需要将每个会话保持在同一服务器上。
Here is some info about MS Application Request Routing - you will get everything there:
以下是有关MS应用程序请求路由的一些信息 - 您将获得所有内容:
IIS负载平衡
#4
0
I would not recommend #2. You will do much better off with a load balancer.
我不建议#2。使用负载均衡器可以做得更好。
Pay attention to session state management. Unless you configure the load balancer to keep each user on the same web server, you will have to use the session state server or database.
注意会话状态管理。除非您将负载均衡器配置为使每个用户保持在同一Web服务器上,否则您将必须使用会话状态服务器或数据库。
Also, check your code's usage of Application and Cache variables. These will be different on every web server. If those values are static, you may not have a problem. But if they can change, you can end up with different values on each web server.
另外,检查代码对Application和Cache变量的使用情况。这些在每个Web服务器上都会有所不同。如果这些值是静态的,则可能没有问题。但是,如果它们可以更改,您可以在每个Web服务器上获得不同的值。
There used to be a problem with ViewState in 1.x, as explained here. I'm not sure if this problem still exists.
在1.x中,ViewState一直存在问题,如此处所述。我不确定这个问题是否仍然存在。
Then, there are some changes that you need to make to the Machine Key in web.config, as explained here.
然后,您需要对web.config中的Machine Key进行一些更改,如此处所述。