一个访问数据库比较慢的asp执行完之前,其它的asp页面也无法被执行了?
以前好像没感觉,年前换了一个好一点的服务器,这种阻塞现象反而很明显了
asp解释器应该是多线程的吧(因为使用了session的原因,只能单进程)
怎么会因为一个asp的慢也阻塞其它所有的asp呢?
都是一个服务器上同时跑win2003+sql2005+iis
老机器是dell的超线程+2G内存
新机器是ibm的2cpux4核x超线程+16G内存
同样的win2003下,能否有一个版本较新的asp解释器呢?是不是微软已经不再升级asp解释器了?
搜了半天,iis7就是不能安装到win2003的!!
但是win2008的激活什么的又是一个障碍。。。。。。
如果能把asp解释器开源,也许会有人不断完善、加强它。。。。。。。
一个测试的asp,大家可以简单的试一试,会不会互相阻塞:
<%Response.Expires=0
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>sql延时测试</title>
</head>
<body>
<%
n=request("n")
d=request("d")
if is_null(n) then n=5
if is_null(d) then d="00:00:01"
i=1
%>n=<%=n%><br>d=<%=d%><br><%
for i=1 to n
%>
<%=i%> now=<%=now()%><br>
<%
's=SQLretOne("waitfor '00:00:03' select getdate() as fret ")
s=SQLretOne("sqldelay('"&d&"')") 'sqldelay存储过程,就是执行了上面的sql
debugstr(i & ":" & s)
next
%>
</body>
</html>
'返回单记录单字段的数据
Function SQLretOne(sql)
dim conn1
set Conn1 = Server.CreateObject("ADODB.Connection")
'conn.CursorLocation=1
conn1.open connstr
Set rsData=Server.CreateObject("ADODB.Recordset")
'response.Write("<!--- "&sql&" --->")
rsData.Open sql, conn1, 1, 1
if rsData.eof then
SQLretOne=""
else
set f=rsData.Fields
set f=f.item(0)
SQLretOne=f.value
'response.Write(SQLretOne)
end if
rsData.close
conn1.close
Set Conn1=Nothing
End Function
我的试验(同时在2个页面刷新这个asp)结果是:
n=10
d=00:00:1
1 now=2010-10-11 12:52:37
{debug:[1:2010-10-11 12:52:38]No=1}
2 now=2010-10-11 12:52:38
{debug:[2:2010-10-11 12:52:39]No=2}
3 now=2010-10-11 12:52:39
{debug:[3:2010-10-11 12:52:40]No=3}
4 now=2010-10-11 12:52:40
{debug:[4:2010-10-11 12:52:41]No=4}
5 now=2010-10-11 12:52:41
{debug:[5:2010-10-11 12:52:42]No=5}
6 now=2010-10-11 12:52:42
{debug:[6:2010-10-11 12:52:43]No=6}
7 now=2010-10-11 12:52:43
{debug:[7:2010-10-11 12:52:44]No=7}
8 now=2010-10-11 12:52:44
{debug:[8:2010-10-11 12:52:45]No=8}
9 now=2010-10-11 12:52:45
{debug:[9:2010-10-11 12:52:46]No=9}
10 now=2010-10-11 12:52:46
{debug:[10:2010-10-11 12:52:47]No=10}
——这个页面(最多晚半秒钟刷新)是在上面的页面执行完成后才开始执行的:
n=10
d=00:00:1
1 now=2010-10-11 12:52:47
{debug:[1:2010-10-11 12:52:48]No=1}
2 now=2010-10-11 12:52:48
{debug:[2:2010-10-11 12:52:49]No=2}
3 now=2010-10-11 12:52:49
{debug:[3:2010-10-11 12:52:50]No=3}
4 now=2010-10-11 12:52:50
{debug:[4:2010-10-11 12:52:51]No=4}
5 now=2010-10-11 12:52:51
{debug:[5:2010-10-11 12:52:52]No=5}
6 now=2010-10-11 12:52:52
{debug:[6:2010-10-11 12:52:53]No=6}
7 now=2010-10-11 12:52:53
{debug:[7:2010-10-11 12:52:54]No=7}
8 now=2010-10-11 12:52:54
{debug:[8:2010-10-11 12:52:55]No=8}
9 now=2010-10-11 12:52:55
{debug:[9:2010-10-11 12:52:56]No=9}
10 now=2010-10-11 12:52:56
{debug:[10:2010-10-11 12:52:57]No=10}
这个现象是asp必然,还是我的iis没配好或asp(ado操作数据库)没写好?
asp的老手们应该肯定知道吧?
——asp就这样!
——或 肯定是 iis没配好!
——或 肯定是asp没写好!
有网页说下面的后2个参数改为0,0是单向、只读,效率最高
rsData.Open sql, conn1, 1, 1
但是,我改为0,0,则不管循环几次,都只会出现一条结果。。。。。。。