Recently we’ve been receiving a great deal of questions about the best way to incorporate Telerik’s ASP.NET controls in a Load Balanced Environment. We have opted to shed some light on the subject in this blog post. More and more web developers decide to distribute workload over multiple computers, network connections, or other tools, because this is one of the most effective ways to prevent overload, minimize the response time and at precisely the same time achieve optimum resource usage and maximize network throughput. Brace yourself for a short journey through the internet backend ecosystem.
What is a WebGarden
WebGarden is the situation in which one physical machine is employed for several worker processes running simultaneously. Each worker process is responsible for handling all kinds of requests, answers, session information, cache data, etc. and all the ASP.NET functionality inside IIS runs under the range of the worker process. By default, every program pool includes one worker process. A WebSite containing multiple worker processes is known as a WebGarden.
Put simply — if you increase the number of worker processes for a specified ApplicationPool you get a WebGarden asp net hosting uk.
What is a WebFarm
WebFarm is known as a hosting environment comprising multiple web servers. All servers within this architecture are connected through a virtual IP supporting a Load Balancer, which tracks the requests to the servers inside the WebFarm. Whenever a client request is received, it is going to undergo the Load Balancer (LB) and subsequently, based on the load of each server, the LB will disperse the petition to the corresponding server. To be able to share the same Session data and one, all servers should be configured to use identical machine essential.
What is a Machine key and how to configure it
In standard applications it is configured automatically and it is different for every single WebApplication.
In a WebFarm setup, but to get your website running properly on most of the machines you must manually create certain values for validation and decryption keys and you need to utilize those values on all computers at the WebFarm (i.e. configure the in all web.config files using the very same values).
The main reason for using one and the exact same machine key is that the inconsistency in the SessionState — the Session depends a lot on the device essential to keep all of the needed data in the SessionState. Each server will get only his Session data Should you keep the keys with the mechanically generated values and this will lead to discrepancies between the loaded resources. If a reason is to use different machine secrets, a custom implementation of session state should be provided.
You can see bellow the way the Telerik’s ASP.NET ImageEditor may look if the machine key is not set manually, making the control not able to load its resources correctly:
The basic Actions you should follow to be able to manually configure the keys, are:
Open IIS Manager in one of those servers and navigate to the WebApplication you want to manage to create its Machine Key. In Features View, double-click Machine Key:
On the Machine Key page, so as to generate special validation and decryption key values to get a WebFarm, you have to clear”Create a Exceptional key for every application” for both validation and decryption keys as well as to clear”Automatically generate at runtime”:
Click Generate Keys in the Actions pane to create specific key values:generate-machine-key-3
The generated keys will be displayed from the center pane:
All you have to do then is to replicate the aforementioned generated device key and add it to the web.config files of this application in all your servers.
Integrating RadControls in WebFarm/WebGarden
Ultimately — we get to the main purpose of this post:–RRB- There are some configurations That Have to be made so as to create RadControls function correctly in a Load Balanced Environment:
ImageStorageLocation — if the control supports this property (e.g. Telerik’s ASP.NET Captcha, ImageEditor, etc.) it has to be set to”Session”. Default the image saved in the Cache. If more than one server (worker procedure ) is used to sponsor the page, the images should be taken from the Session because it’s shared among all the machines/applications. For instance:
The HttpHandler and Handler definitions to your Telerik.Web.UI.WebResource (from the web.config file) ought to be modified manually by placing the kind of this HttpHandler to be equal to type=”Telerik.Web.UI.WebResourceSession”:
I’ll say this once again, since it is vital – when the program is operating in a WebFarm, the device key in the web.config file of servers must be one and the same (configured manually in one of those software ), e.g:
Access the same resources from all possible servers / applications — if the database or shared documents are modified only in one place you may have issues later, so they need to be shared among all apps/machines. This is valid even in the event that you don’t possess one RadControl around. This is carried out by using a common database (e.g. for grids) or a custom made content provider for controllers like FileExplorer, so that they don’t attempt to utilize local resources which will not be synced, but the common ones.
In the end if our short journey we understand a whole lot more of the encompassing web ecosystem. You provide your customers the best possible experience and should take whole advantage of it. Leave a comment below if this helped you get started or you have had!