我们即将推出一个拥有12,000-15,000活跃用户的网站(大约2000个并发用户)。在性能测试期间,我们遇到了一些CPU瓶颈,最后我们有一个非常简单的aspx页面,我们可以按如下方式重现这个问题。
<%@ Page Language="vb" AutoEventWireup="false" Inherits="System.Web.UI.Page" trace="false" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Sub pp(ByVal s As Object, ByVal e As EventArgs) Handles MyBase.Load
If Page.IsPostBack Then Exit Sub
Dim lst As New List(Of String)
For I = 1 To 10
For Each c As Control In Me.Form.Controls
lst.Add(c.ID)
Next
Next
'r1.DataSource = Lst
'r1.DataBind()
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div><asp:Button ID="b1" Text="Button" runat="server"/>
<asp:Button ID="Button5" Text="Button" runat="server"/>
<asp:Button ID="Button6" Text="Button" runat="server"/>
<asp:Button ID="Button7" Text="Button" runat="server"/>
<asp:Button ID="Button8" Text="Button" runat="server"/>
<asp:Button ID="Button9" Text="Button" runat="server"/>
<asp:Button ID="Button10" Text="Button" runat="server"/>
<asp:Button ID="Button11" Text="Button" runat="server"/>
<asp:Button ID="Button12" Text="Button" runat="server"/>
<asp:Button ID="Button13" Text="Button" runat="server"/>
<asp:Button ID="Button14" Text="Button" runat="server"/>
<asp:Button ID="Button15" Text="Button" runat="server"/>
<asp:Button ID="Button16" Text="Button" runat="server"/>
<asp:Button ID="Button17" Text="Button" runat="server"/>
<asp:Button ID="Button18" Text="Button" runat="server"/>
<asp:Repeater ID="r1" runat="server">
<ItemTemplate>
<%#DataBinder.Eval(Container, "DataItem")%>
</ItemTemplate>
</asp:Repeater>
</div>
</form>
</body>
</html>
注意:
trace="true"
)以0.3秒完成,包括渲染。每秒请求数:154.13 [#/ sec](平均值)
当我们增加CPU核心时,这个数字会增加,但仍然是100%利用
如果我们注释掉以下数据绑定语句的响应完全不同:
r1.DataSource = l
r1.DataBind()
每秒请求数:2510.95 [#/ sec](平均值)
我们被困住了。欢迎任何建议。