A web farm is a collection of server computers that host a single Web site.The purpose of creating a web farm is to distribute the web application load across multiple machines.
The state of a web application is usually stored in a session state repository. A web application that is hosted in a web farm must either share its session state repository between the separate servers or make sure that all requests associated with a specific session are routed always to the same physical server. The latter method, though, has performance disadvantages, because it cannot grant that requests will be spread uniformly through the web farm.
A common approach to solve the problem is to use an SQL Server or StateServer as a session state repository. Microsoft IIS natively supports this mode.
Nevron web controls can be used in a stateful or stateless manner. Here is a list of the possible control configurations and their applicability in web farm hosted applications
This is the default configuration of the Nevron web controls. The HTML rendering of the control and the rendering of the chart/diagram image are performed separately. First the HTML is generated as a part of the web page and is sent to the client; next, the web browser requests the chart/diagram image from the server and the image is generated by an HTTP handler. In between the state of the web control is stored in the session.
This scenario can be used in a web farm with a session state that is stored in SQL Server or StateServer. The main disadvantage of this approach is that the SQL Server and StateServer modes are slower.
The HTML rendering of the control and the rendering of the chart/diagram image are performed in one pass. The HTML is generated as a part of the web page and in the same time the image is generated and stored to the server’s file system. When the web browser displays the web page, the image is loaded from the file that was stored at the server.
This scenario provides an efficient way to use the Nevron web controls in a web farm by setting a UNC location as a temp folder that is used by all web farm servers as a temporary images folder. There are certain implications, related to the UNC location access permissions, though.
Because by default the IIS ASP.NET process is running under a local user account – either Network Service or ASPNET, and because these accounts have auto generated random passwords, all write operations to a shared folder on another computer will fail, even if the remote Network Service or ASPNET account has full control granted for the shared folder.
For IO operations over the network to succeed, the UNC location must have the corresponding permissions granted for a domain account under which also runs the ASP.NET process, or, respectively a local account, which has exactly the same name and password as the local account, under which runs the ASP.NET process.
A UNC location to be used as a temporary images folder, a virtual directory must be created (say it’s name is NevronTemp) under the web site’s root that is configured from the IIS management console as “A share located on another computer”. A user account will be required by the IIS for the UNC location. This user account must be the same account, under which the ASP.NET process is running, as described in the previous paragraph.
To synchronize the user accounts of the ASP.NET process and the UNC location, you can either change the process account specified in the machine.config file with a domain account (see the <processModel …>…</processModel> section), or synchronize the passwords of all local Network Service / ASPNET accounts on the web farm servers. Please refer to the Microsoft documentation for details on both tasks.
When all permissions are granted and synchronized, the following lines of code are required in your chart/diagram initialization:
C# |
Copy Code
|
---|---|
myControl.ImageAcquisitionMode = ClientSideImageAcquisitionMode.TempFile;
myControl.ServerSettings.TemporaryFileSettings.VirtualTempDirectory = "~/NevronTemp";
|
Visual Basic |
Copy Code
|
---|---|
MyControl.ImageAcquisitionMode = ClientSideImageAcquisitionMode.TempFile
MyControl.ServerSettings.TemporaryFileSettings.VirtualTempDirectory = "~/NevronTemp"
|
In AJAX mode the HTML rendering of the control and the rendering of the chart/diagram image are generally unrelated. The HTML is generated once as a part of the web page and is sent to the client. The state of the control is stored permanently in the session state and is used every time the image of the control must be regenerated. The web browser requests the chart/diagram image from the server repeatedly and the image is generated and sent through an HTTP handler.
With AJAX enabled, Nevron recommends in-proc session state storage with a load balancing pattern that associates single server with each session. The session state can be also stored in SQL Server or StateServer. When using SQL Server, though, the estimated size of the session state in cases of higher web site load must be considered.
The main benefit of this approach is that the web control does not maintain server side state. Therefore it is natively suitable for web farm environments.
There are two ways to directly stream an image to the web browser: from ASP.NET code inside a web form; and using an HTTP Handler. Both methods are explored in details in the Direct Image Streaming topic.