HttpRequest代码中,加入了一些信息记录的函数,如下
实际运行过程中,已经把一些常用,容易同时使用的页面函数,都改造成了异步函数
但是涉及多人同时访问时,特别是我用微信群发模板消息出去后,用户短时间集中访问同一异步页面,还会造成拥堵排队现象
请帮我分析下,我这代码中,加了这些信息记录的函数,对程序的影响,对并发的影响是不是很大?怎么改善?
Dim stt As Date = Date.Now
Case "127.0.0.1","192.168.30.100"
'记录动作
Dim str As new StringBuilder
str.AppendLine("path=" & e.Path)
str.AppendLine("HttpMethod=" & e.Request.HttpMethod)
If e.Cookies.ContainsKey("pxopenid") Then '从cookie中获取微信用户id
str.AppendLine("cookies=" & e.Cookies("pxopenid"))
End If
For Each key As String In e.Values.Keys
str.AppendLine(key & "=" & e.Values(key) )
Next
Functions.Execute("txtProgress",str.ToString) '此代码用于窗口显示访问动态
Select Case e.Path
Case "wxTest.htm"
Functions.Execute("Http_WX_Test_openid",e)
Case 。。。。
End Select
catch ex As Exception
Functions.Execute("ErrLogText",ex) '记录错误日志
End Try
Dim t As TimeSpan = Date.Now - stt
Functions.Execute("weblog",e,t.TotalSeconds) '记录页面访问相关信息,包括路径path ,耗时等
weblog:
Dim e As RequestEventArgs = Args(0)
Dim times As Single=args(1)
Dim str As new StringBuilder
For Each key As String In e.Values.Keys
str.AppendLine(key & "=" & e.Values(key))
Next
Dim host As String=e.host
Dim path As String=e.path
Dim Type As String=e.Request.HttpMethod
Dim openid As String
If e.host=Vars("V_host") Then
If e.Cookies.ContainsKey("openid") Then '从cookie中获取微信用户id
Openid = Functions.Execute("CheckOpenid",e.Cookies("openid"))
End If
Else
If e.Cookies.ContainsKey("pxopenid") Then '从cookie中获取微信用户id
Openid = e.Cookies("pxopenid")
End If
End If
Dim cmd As new SQLCommand
cmd.C
cmd.CommandText = "Ins ert Into wxWeblog(host,path,CREATE_TIME,time,openid,type,remarks) Values(?,?,?,?,?,?,?)"
cmd.Parameters.Add("@11",host)
cmd.Parameters.Add("@22",path )
cmd.Parameters.Add("@66",now.Tostring.replace("-","").replace(" ","").replace(":",""))
cmd.Parameters.Add("@33",times)
cmd.Parameters.Add("@44",openid)
cmd.Parameters.Add("@55",Type)
cmd.Parameters.Add("@77",str.Tostring)
cmd.ExecuteNonQuery
txtProgress:
Dim stt As Date = Date.Now
Dim desc As String=args(0)
If Forms("Http服务设置").opened Then
Else
Forms("Http服务设置").open
End If
desc = desc +"|"+ format(Date.now,"yyyy-MM-dd HH:mm:ss.ffff")
Dim txtProgress As WinForm.TextBox = Forms("Http服务设置").Controls("txtProgress")
txtProgress.Text = desc & vbcrlf & txtProgress.Text '添加提示到文本框的第一行
Application.DoEvents()
Output.Logs("AppLogs").Add( vbCrLf & desc)
Output.Logs("AppLogs").Save(ProjectPath & "logs\APPlogs"+format(Date.today,"yyyy-MM-dd")+".txt",True) '日志位于当前项目目录里
Output.Logs("AppLogs").Clear
If desc.length>1000 Then
desc=""
End If
实际运行时的耗时:
此主题相关图片如下:qq截图20181213222640.png
