IIS加载报表查看器缓慢
本文关键字:缓慢 加载 报表 IIS | 更新日期: 2023-09-27 18:13:23
我们正在运行IIS &;SSRS在同一生产服务器上,并且有两种类型的报表—一种通过报表查看器运行,连接到SSRS(远程模式),另一种调用SSRS web服务生成pdf。
对于这两种报告类型,在加载页面时变得非常慢,最多需要20秒。这在服务器负载较重的时期最为明显,在IIS中回收应用程序池后,缓慢会消失,但过一段时间后又会恢复(应用程序池被设置为每天凌晨3点回收)。
我检查了SSRS的执行日志-对于所有报告,数据检索+处理+呈现的时间将不超过2秒,SSRS的http日志表明,当页面变得无响应时,没有来自IIS的请求-一旦请求到达,它加载得非常快。通过报表管理器运行的报表也非常快。
SSRS似乎不是罪魁祸首,似乎是IIS中的某些东西引起的。
有没有人遇到过类似的问题,或者可以给我指出正确的诊断方向?
许多谢谢。ReportViewer:
public abstract class ReportPageBase : System.Web.UI.Page
{
protected void GenerateReport(ReportViewer reportViewer)
{
var reportParameters = new List<ReportParameter>();
reportViewer.Visible = true;
reportViewer.ServerReport.ReportServerUrl = new Uri(Util.ReportServerUrl);
reportViewer.ServerReport.ReportServerCredentials = new ReportServerCredentials();
ParametersOverride(ref reportParameters);
reportViewer.ServerReport.SetParameters(reportParameters);
}
protected abstract void ParametersOverride(ref List<ReportParameter> reportParameters);
}
Web服务:public static class ReportExporter
{
public static Stream GetExportStream(string reportName, string format, ReportExecutionService.ParameterValue[] paramVals)
{
var rs = new ReportingService2005SoapClient();
var rsExec = new ReportExecutionServiceSoapClient();
var username = ConfigurationManager.AppSettings["ReportViewerUser"];
var password = ConfigurationManager.AppSettings["ReportViewerPassword"];
var domain = ConfigurationManager.AppSettings["ReportViewerDomain"];
var folderPath = ConfigurationManager.AppSettings["ReportViewerFoler"];
System.Net.NetworkCredential networkCredential = new System.Net.NetworkCredential(username, password, domain);
rs.ClientCredentials.Windows.ClientCredential = networkCredential;
rsExec.ClientCredentials.Windows.ClientCredential = networkCredential;
rs.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
rsExec.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
var _reportName = (folderPath ?? @"/") + reportName.Trim();
string historyID = null;
// gets the parameters
rs.GetReportParameters(_reportName, historyID, forRendering, values, credentials, out parameters);
// load the report
ExecutionInfo executionInfo = null;
ReportExecutionService.ServerInfoHeader serverInfoHeader = null;
ExecutionHeader header = new ExecutionHeader();
rsExec.LoadReport(null, _reportName, historyID, out serverInfoHeader, out executionInfo);
header.ExecutionID = executionInfo.ExecutionID;
rsExec.SetExecutionParameters(header, null, paramVals, "en-us", out executionInfo);
byte[] result = null;
string[] streamIds = null;
string encoding = String.Empty;
string mimeType = String.Empty;
string extension = String.Empty;
ReportExecutionService.Warning[] warnings = null;
rsExec.Render(header,
null,
format,
null,
out result,
out extension,
out mimeType,
out encoding,
out warnings,
out streamIds);
var memstream = new MemoryStream(result);
return memstream;
}
}
在我的例子中。IIS Express非常快。但是在IIS 8.5中慢得不可接受!我的解决方案:
- 创建新的应用程序池。"。. NET CLR版本v4.0.30319", "Classic"
- 将web中的Application pool更改为新的。