Advantages / Disadvantages of Increasing AppPool Latency on Azure

I'm going to run the ASP.NET MVC3 web application for production, however, as a complex application, it requires LONG to run. Obviously, I don’t want my users to wait more than a minute for their first request to go through the AppPool timeout.

From my research, I found that there are two ways to deal with this:

Launch a work role or another process - polling a website every 19 minutes to prevent warming up.

Change timeout from 20 minutes by default . To something much more.

Since solution 2 seems like a better idea, I just wonder what will be the disadvantages of this, will I have a lack of memory, etc.?

Thanks.

+4
source share
3 answers

Personally, I would change the timeout, but both of them should work: effectively they will have the same effect, preventing the closure of work processes.

I believe that the timeout should avoid IIS, saving resources that are not needed for servers with a large number of websites that are easy to use. Given that heavily used sites (like this one!) Do not shut down workflows, I don’t think you will see memory problems.

+1
source

Can I use the IIS autorun feature? There is a message here that introduces this idea.

You would have IIS 7.5 and Win2k8 R2 with the Azure OS 2 family. You just need to script / automate any steps and configuration settings.

+3
source

I am doing this with a background thread that requests a keepalive url every 15 minutes. This not only simplifies the application, but also immediately heats up the application at any time when the web role or virtual machine is restarted or rebuilt.

This is all possible because web roles are really work roles that also use IIS stuff. That way, you can still use all the standard job role hooks in the web role.

I got an idea from this blog post , but changed the code to complete a few extra warm-up tasks.

Firstly, I have a class that inherits from RoleEntryPoint (it does some other things besides this warming task, and I removed them for simplicity):

public class WebRole : RoleEntryPoint { // other unrelated member variables appear here... private WarmUp _warmUp; public override bool OnStart() { // other startup stuff appears here... _warmUp = new WarmUp(); _warmUp.Start(); return base.OnStart(); } } 

This WarmUp class uses all the real warm-up logic. When it starts, it types several URLs on the local IP address of the instance (vs public, load balance hostname) to get the information in memory so that the first people use it to get the fastest response time. Then it bypasses and removes one keepalive URL (again in the local instance of the role), which does no work and just serves to prevent IIS from closing the application pool as unoccupied.

 public class WarmUp { private Thread worker; public void Start() { worker = new Thread(new ThreadStart(Run)); worker.IsBackground = true; worker.Start(); } private void Run() { var endpoint = RoleEnvironment.CurrentRoleInstance.InstanceEndpoints["http"]; // "http" has to match the endpointName in your ServiceDefinition.csdef file. var pages = new string[] { "/", "/help", "/signin", "/register", "/faqs" }; foreach (var page in pages) { try { var address = String.Format("{0}://{1}:{2}{3}", endpoint.Protocol, endpoint.IPEndpoint.Address, endpoint.IPEndpoint.Port, page); var webClient = new WebClient(); webClient.DownloadString(address); Debug.WriteLine(string.Format("Warmed {0}", address)); } catch (Exception ex) { Debug.WriteLine(ex.ToString()); } } var keepalive = String.Format("{0}://{1}:{2}{3}", endpoint.Protocol, endpoint.IPEndpoint.Address, endpoint.IPEndpoint.Port, "/keepalive"); while (true) { try { var webClient = new WebClient(); webClient.DownloadString(keepalive); Debug.WriteLine(string.Format("Pinged {0}", keepalive)); } catch (Exception ex) { //absorb } Thread.Sleep(900000); // 15 minutes } } } 
+2
source

Source: https://habr.com/ru/post/1388521/


All Articles