IIS加载报表查看器时速度慢

时间:2016-10-18 00:01:49

标签: c# iis reporting-services reportviewer

我们正在运行IIS& SSRS在同一个生产服务器上,有两种类型的报告 - 一种是通过Report Viewer运行,连接到SSRS(远程模式),另一种是调用SSRS Web服务来生成PDF。

对于这两种报告类型,加载页面时变得非常慢,耗时超过20秒。在服务器负载繁重期间最明显的是,在IIS中回收应用程序池后缓慢会消失,但一段时间后会恢复(应用程序池设置为每天凌晨3点回收)。

我检查了SSRS的执行日志 - 对于所有报告,数据检索+处理+渲染的时间不会超过2秒,SSRS的http日志表明当页面变为IIS时没有来自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);
}

网络服务:

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;
    }
}

1 个答案:

答案 0 :(得分:1)

就我而言。 IIS Express 非常快。但是在 IIS 8.5 下慢得不能接受! 我的解决方案:

  • 创建一个新的应用程序池,例如。 ".NET CLR 版本 v4.0.30319", "经典"
  • 在网络中将应用程序池更改为新的应用程序池。
相关问题