locked
Can Asynchronous Call (Thread) can be improved and How to use caching of ssrs for better performace RRS feed

  • Question

  • User-1778011532 posted

    Dear All,

    I have used Thread for Asynchronous Call. Can this be improved using threadpool since a thread is created for each report when user generate report. 

    Here Web server and Report server are different server.

    How to use SSRS cache feature in C# Code. 

    Can TPL be used to utilise mutiprocessot in a web server as well as report server?

    Kindly guide me.

    Sample code is given below.

    protected void Button1_Click(object sender, EventArgs e)

    {
    string strapppath = Request.PhysicalApplicationPath;

    Thread thread = new Thread(() => GenerateReport(strapppath));

    thread.Start();

    }

    public void GenerateReport(string tprApppath)

    {

    ReportViewer MyReportViewer = new ReportViewer();

    MyReportViewer.ServerReport.ReportServerCredentials = new ReportServerNetworkCredentials();
    MyReportViewer.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote;
    MyReportViewer.ServerReport.ReportServerUrl = new Uri(System.Configuration.ConfigurationManager.AppSettings["ReportServerPath"].ToString());
    MyReportViewer.ServerReport.ReportPath = @"/Report1";
    MyReportViewer.ShowParameterPrompts = false;

    Byte[] mybyte = MyReportViewer.ServerReport.Render();

    FileStream fs = System.IO.File.Create(strFileName);
    fs.Write(mybyte, 0, mybyte.Length);
    fs.Close();

    }

    Thanks and Regards

    Palanivelrajan

    Tuesday, March 18, 2014 3:32 AM

Answers

  • User1140095199 posted

    Hi,

    I have used Thread for Asynchronous Call. Can this be improved using threadpool since a thread is created for each report when user generate report. 

    The .NET Framework 4.5 introduced a simplified approach to the task-based asynchronous programming model (which was introduced as part of the Task Parallel Library API in .NET 4.0) via the utilization of the two new keywords:  “async” and “await” in C# (Async and Await in VB.NET). For detailed information, see Asynchronous Programming with Async and Await (C# and Visual Basic)  on MSDN.These new keywords can be utilized when making asynchronous calls to the SQL Server Reporting Services web service.

    Take a look at the following article it has complete walthrough on how to render SSRS Report Asynchronously using Async/Await Keywords.

    http://blog.softartisans.com/2013/07/24/how-to-render-an-ssrs-report-asynchronously-using-the-asyncawait-keywords-in-c-5-0-with-net-4-5/

    How to use SSRS cache feature in C# Code. 

    Actually, SSRS does implement session level caching for each user request “under the covers” to improve report performance and to provide a consistent experience across a single browser session. Data remains consistent during the report session and is unaffected by changes in the underlying data source.

    On top of that we can implement 2 forms of caching in Reporting Services: Temporary Cached Reports and Report Snapshots.

     Temporary Cached Reports- The report server will cache one instance of a report based on the report name. However, if a report can contain different data based on query parameters, multiple versions of the report may be cached at any time.  if ten users open the report, only the first request results in report processing. The report is subsequently cached, and the remaining nine users view the cached report. Cached reports are removed from the cache at intervals that you define. You can specify intervals in minutes, or you can schedule a specific date and time to empty the cache. Not all reports can be cached. If a report prompts users for credentials or uses Windows Authentication, it cannot be cached unless you change the data source to use stored credentials instead.

    Report Snapshots -   A report snapshot is usually created and refreshed on a schedule, allowing you to time exactly when report and data processing will occur. If a report is based on queries that take a long time to run, or on queries that use data from a data source that you prefer no one access during certain hours, you should run the report as a snapshot. A report snapshot is stored in the intermediary form in the ReportServer database, where it is subsequently retrieved when a user or subscription requests the report. When a report snapshot is updated, it is overwritten with a new instance. The report server does not save previous versions of a report snapshot unless you specifically set options to add it to report history.

    For more information:

    Caching SSRS Reports for Performance - http://blogs.technet.com/b/rob/archive/2010/02/11/caching-ssrs-reports-for-performance.aspx

    Best Regards!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, March 18, 2014 10:21 PM