如何创建 ASP.NET 网络场?
我正在寻找有关如何创建 ASP.NET Web Farm 的信息 - 即如何使 ASP.NET 应用程序(最初设计为在单个 Web 服务器上工作)在 2、3 上运行、 10 台等服务器?
我们创建了一个 Web 应用程序,当同时有 500 个用户时,该应用程序运行良好。但现在我们需要让它为 10000 个用户工作(同时使用网络应用程序)。
因此,我们需要设置 20 个 Web 服务器,并进行一些操作,以便 10 000 个用户可以通过在 Web 浏览器中键入“www.MyWebApp.ru”来使用 Web 应用程序,尽管他们的请求将得到处理由 20 个网络服务器在他们不知情的情况下进行。
1) 是否有特殊的标准软件来创建ASP.NET网络场?
2) 或者我们应该自己创建一个网络场,通过手动在不同的 Web 服务器之间传输请求(使用 ASP.NET / C#)?
我发现有关 ASP.NET Web 场和网络可扩展性的信息非常少:在大多数情况下,有关可扩展性的文章会告诉您如何优化 ASP.NET 应用程序并使其运行得更快。但我没有找到在2 个 Web 服务器上运行“Hello world”之类的 ASP.NET Web 应用程序的示例。
如果有人可以发布一篇文章的链接,或者更好的是讲述自己在 ASP.NET“网络农业”和解决可扩展性问题方面的经验,那就太好了。
谢谢你, 米哈伊尔.
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?
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).
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.
1) Is there special standard software to create an ASP.NET web farm?
2) Or should we create a web farm ourselves, by transferring requests between different web servers manually (using ASP.NET / C#)?
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.
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.
Thank you,
Mikhail.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
不。
不。
要构建网络场,您将需要某种形式的负载平衡。对于最多 8 台服务器左右,您可以使用 Windows 内置的网络负载平衡 (NLB)。对于超过 8 台服务器,您应该使用硬件负载平衡器。
然而,负载平衡实际上只是冰山一角。还有许多其他问题需要解决,包括:
如果可能有帮助,我在书中介绍了许多这些问题:超快速 ASP.NET:使用 ASP.NET 和 SQL Server 构建超快速和超可扩展的网站。
No.
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.
However, load balancing is really just the tip of the iceberg. There are many other issues that you should address, including things like:
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.
我想说你应该配置一个NLB集群(网络负载平衡),它基本上在集群节点之间分割所有请求(并且作为一个额外的好处可以检测事情是否发生故障并停止向它们发送请求)。 Windows 中内置了一些功能,但它们在性能或可扩展性方面无法与硬件设备相比。如果您使用的是 Windows 2008,那么设置起来确实很简单。如果您这样做,请确保您拥有共享的机器密钥 否则您将开始收到视图状态无效的异常(当一台服务器提交表单并将其发布到另一台服务器并且它们使用不同的密钥对数据进行编码时)。
您还可以使用 DNS 循环,但在 1 个数据中心内大概有 20 台服务器时,我认为没有必要采取如此疯狂的长度。如果您有多个数据中心,那么这绝对值得考虑(因为 NLB 在数据中心之间并不能很好地工作)。
您还需要确保如果用户交换服务器,他们不会丢失会话。最简单的方法是使用会话状态数据库(可在 web.config 中配置,或者您可以在 IIS 的配置中在服务器范围内进行配置)。如果您不使用会话,只需在 web.config 的 Pages 指令中将其关闭即可。您也可以使用会话状态服务器,但我对此没有任何经验。
也许还值得考虑花一些时间优化代码或向静态内容添加缓存指令 - 即使您只减少对其中一些服务器的需求,它也可能非常经济高效。
希望有帮助。
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).
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).
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.
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.
如果你保持你的服务器无状态,那么使用一个好的路由器来实现一些循环协议(将对单个发布的服务器 IP 的每个调用发送到不同的 Web 服务器)是很容易的。
如果它不是无状态的(例如 - 如果需要登录,或 ssl),那么您需要将每个会话保持在同一服务器上。
以下是有关 MS 应用程序请求路由的一些信息 - 您将在那里获得所有内容:
IIS 负载均衡
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).
if it is not stateless (like - if a login is required, or ssl) than you need to keep each session to the same server.
Here is some info about MS Application Request Routing - you will get everything there:
IIS Load balancing
我不会推荐#2。使用负载均衡器你会做得更好。
注意会话状态管理。除非您将负载平衡器配置为将每个用户保留在同一 Web 服务器上,否则您将必须使用会话状态服务器或数据库。
另外,检查代码对应用程序和缓存变量的使用情况。这些在每个网络服务器上都会有所不同。如果这些值是静态的,则可能不会有问题。但如果它们可以改变,您最终可能会在每个 Web 服务器上得到不同的值。
1.x 中的 ViewState 曾经存在问题,如此处所述 。我不确定这个问题是否仍然存在。
然后,您需要对 web.config 中的计算机密钥进行一些更改,如下所述 这里。
I would not recommend #2. You will do much better off with a load balancer.
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.
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.
There used to be a problem with ViewState in 1.x, as explained here. I'm not sure if this problem still exists.
Then, there are some changes that you need to make to the Machine Key in web.config, as explained here.