Web Farms and Web Garden Support
- 5 minutes to read
This document describes how to make web applications that use the ASP.NET Document Viewer and HTML5 Document Viewer work properly in a clustered web environment (also known as Web Farms or Web Garden).
Web farms and web garden technologies allow you to run a web application on several web servers (web farms), or on the same server but in different processes, each process executed using its own processor (web garden). This is specified by the Internet Information Services (IIS) settings of the server host on which you deploy your web application.
By using a clustered environment, you can significantly improve the performance of large web applications. This, however, requires that XtraReports share its data between multiple processes/servers when a report is generated, printed or exported.
HTML5 Document Viewer and Report Designer's Preview
If you use the HTML5 Document Viewer to display reports, do the following to adjust your Web reporting application to properly operate in web farms and the web garden:
Implement the ICachedReportSourceWebResolver interface to associate the report's unique name with a CachedReportSourceWeb object that possesses the corresponding report. The Document Viewer requests the provided CachedReportSourceWeb object to generate a report document.
Documents generated using the CachedReportSourceWeb object are cached in the MemoryDocumentStorage storage by default. Utilize file storage instead by calling the UseFileDocumentStorage(String, StorageSynchronizationMode) (.NET Framework)/ UseFileDocumentStorage(String, StorageSynchronizationMode) (.NET Core) method. Pass InterProcess as a method parameter.
(This step is required for the Report Designer's Preview) If the report includes interactive features, the Document Viewer recreates the document using the report instance that is stored in memory by default. Use the UseFileReportStorage(String, StorageSynchronizationMode) (.NET Framework)/ UseFileReportStorage(String, StorageSynchronizationMode) (.NET Core) method to specify a path to the directory to which the result of the report xml serialization will be saved and which the Document Viewer will use to recreate the document when the memory cache is empty. Pass InterProcess as a method parameter.
If the asynchronous export mode is enabled explicitly or content editing is enabled in an exported document, use the UseFileExportedDocumentStorage(String, StorageSynchronizationMode) (.NET Framework) / UseFileExportedDocumentStorage(String, StorageSynchronizationMode) (.NET Core) method to use file storage and the InterProcess synchronization mode.
Provide time settings for cleaning the in-memory cache that stores documents and reports. Create an instance of the CacheCleanerSettings object and register it in your application using the RegisterSingleton<T>(T) method.
Provide time settings for cleaning the file storage that stores documents, exported documents and reports. Create an instance of the StorageCleanerSettings object and register it in your application using the RegisterSingleton<T>(T) method.
ASP.NET Document Viewer
The ASPxDocumentViewer control introduces the FileStore design-time property to adjust your web application to properly operate in web farms and web garden.
The FileStore property provides the following settings:
Specifies the path to the directory, where XtraReports can store temporary files during report document generation. Note that this property can be set to either an absolute or a relative path.
By default it is set to ~/App_Data/XtraReports/FileStore.
Specifies the amount of time (in milliseconds), to store temporary files after their creation.
By default it is set to 120000.
Specifies the time interval between two sequential checks of the Directory for the files whose lifetime is greater than the KeepInterval, and which should be removed.
By default it is set to 60000.
If these properties are set to their default values, they are not serialized to the Web.config file. Therefore, if some or all these properties are set to a non-default value for any ReportViewer control in a project, they are added to the appSettings section of the Web.config file.
<appSettings> <add key="XtraReportsFileStore-Directory" value="~/MyFileStore" /> <add key="XtraReportsFileStore-CheckInterval" value="100000" /> <add key="XtraReportsFileStore-KeepInterval" value="200000" /> </appSettings>
The ReportViewer.FileStore property is available only at design time within Visual Studio. So, it can't be set via code, and instead, you can manually add these settings to the appSettings section of the Web.config file.
The directory specified by the FileStore.Directory property (or the XtraReportsFileStore-Directory key) should grant read and write permissions to the ASP.NET worker processes in your clustered environment. This process's user is called ASPNET in IIS 5.0 (Windows XP) or NETWORK_SERVICE in IIS 6.0 (Windows Server 2003) and IIS 7.0 (Windows Vista) or higher. There are some specifics when using this directory in web garden and web farms:
Naturally, it is necessary to give read/write permissions to the ASP.NET worker process only to the "~/App_Data/" directory (in case you don't change the default value of the FileStore.Directory property). So, XtraReports will create the "~/App_Data/XtraReports/FileStore" directory when necessary. However, if you don't want the ASP.NET worker process to have read/write access to the entire "~/App_Data/" directory, you can manually create the directory for a file store (e.g. "~/App_Data/XtraReports/FileStore") and give read/write permissions only for this directory.
In case of multiple servers in a web farm, it is necessary that the FileStore's directory should be created on a server, which can be accessed by other servers in this farm. So, you first need to create a shared directory on a shared server, and then give read/write permissions for it to the ASP.NET worker processes of all web servers in a farm.
Note that if the path specified by the FileStore.Directory property (or the XtraReportsFileStore-Directory key) isn't found by XtraReports, or the ASP.NET worker process doesn't succeed in writing temporary data into it, XtraReports tries to use the path returned by the CodegenDir property instead. In most situations, this approach works fine. However, use of this path is denied in the Medium Trust environment.