IIS application pool _ cache collection, iis application pool collection

Source: Internet
Author: User

IIS application pool _ cache collection, iis application pool collection

Recently, due to my company's business, I need to store the questions and answers of the questionnaire into the cache, which has increased the loading speed of the questionnaire and reduced the pressure on the database.

Cache key code (company code has been encapsulated and only key code is pasted here ):

HttpRuntime. Cache. Insert (key, value, new CacheDependency (dependencyFile), Cache. NoAbsoluteExpiration, slidingExpiration, CacheItemPriority. High, onRemoveCallBack );

The cache is stored in the IIS application pool, which uses the relative cache time mode. It is unrealistic to wait for enough time to perform the operation. Therefore, the cache is used to query information online and ask colleagues, two solutions are found:

1-manually recycle the application pool on the corresponding server IIS (cache data is cleared and used after impact evaluation)
2-after modifying the configuration file of the project, the collection time of the IIS application pool will be triggered. (This can be set in the advanced settings of the IIS application pool)

/// <Summary> /// insert a cache object (relative expiration time, cache dependency) /// </summary> /// <param name = "key"> </param> /// <param name = "value"> </param> /// <param name = "slidingExpiration"> relative expiration time </param> /// <param name = "dependencyFile"> file dependency </param> /// <param name =" onRemoveCallBack "> processing method after the cache disappears </param> public static void Insert (string key, object value, TimeSpan slidingExpiration, string dependencyFile, CacheItemRemovedCallback onRemoveCallBack) {GenerateFile (dependencyFile); HttpRuntime. cache. insert (key, value, new CacheDependency (dependencyFile), Cache. noAbsoluteExpiration, slidingExpiration, CacheItemPriority. high, onRemoveCallBack );}

 

 

Article: http://www.cnblogs.com/guohu/p/5209209.html

 

IIS can be set to automatically recycle at a scheduled time, which is 1740 minutes by default, that is, 29 hours. IIS automatic recovery is equivalent to IIS restart on the server, memory in the application pool is cleared, and all data is cleared. It is equivalent to IIS restart. on the server side of the measurement and rapid development platform, in order to reduce the burden on the database, A lot of information is saved in the memory, which is not suitable for frequent recovery. Because recovery will cause all data in memory on the server side to be lost. If the data is not saved to the database in time, it may cause program problems. If the system is not suitable for recycling during peak hours, recycling may result in dozens of seconds of no response from IIS. This is a bad experience for working staff, it may be caused by problems such as network or disconnection. Therefore, based on the above analysis, we need to set IIS to recycle regularly within the specified time.
The measurement quick development platform (hereinafter referred to as the measurement platform) uses the Webservice method to build the server. Therefore, you need to correctly configure IIS (Internet Information Service) to ensure reliable and stable operation of the server, to provide customers with a better user experience. To protect server resources, IIS has an application pool recycle function, and is already set to recycle once every 1740 minutes (29 hours) by default. To better set this attribute, we need to master the IIS recycle function settings and adjust them according to the actual situation of the application to achieve the best effect of system operation.
In the IIS application pool recycle, find the corresponding application pool and click Advanced Settings to view the recycle settings (this article takes IIS7 under windows2008R2 as an example, similar to Windows2012 ).

(Figure 1)

Recycling is prohibited in case of configuration changes: If it is True, the application pool will not be recycled when configuration changes occur.
Fixed interval (minutes ):After the set time is exceeded, the application pool is recycled. If the value is 0, the application pool is not recycled at a fixed interval. The default setting time is 1740 (29 hours ).
Disable overlap collection:If this parameter is set to true, the application pool is reclaimed to exit the existing workflow before another workflow is created.
Request restrictions:The maximum number of requests that can be processed by the application pool before collection. If the value is 0, there is no limit on the number of requests that can be processed by the application pool.
Generate collection event log entries:Each time a specified collection event occurs, an event log entry is generated. The detailed settings are not described in detail.

According to the server configuration of the measurement platform, the default 1740-minute Recycle Process Policy of IIS is not reasonable, because every 1740-minute recycle may be in the peak hours when users use the system, to avoid uncontrollable problems during peak hours, we recommend that you recycle IIS every Saturday night (such as and.

If we perform the recycle setting in the advanced settings of the IIS application pool, there are only two methods, one is fixed interval, and the other is manual collection. Fixed interval settings, which are not very easy to set in the middle of the night, to ensure that the week is collected late on Saturday. We recommend that you use the windows "Task Scheduler" to configure a script program for scheduled task execution in the operating system for IIS collection, which is easy to set and flexible to adjust. To use scripts to execute IIS functions, you must check "IIS management scripts and Tools" in the management tool when installing and configuring IIS (SEE ).

With vbs scripts and batch files, combined with the task scheduler, IIS recycling is ensured at every Saturday night.

Recyclepool. vbsFile Content:

AppPoolName = WScript. Arguments (0)

Set oWebAdmin = GetObject ("winmgmts: root \ WebAdministration ")

Set oAppPool = oWebAdmin. Get ("ApplicationPool. Name = '" + appPoolName + "'")

OAppPool. Recycle

Set fso = createobject ("scripting. filesystemobject ")

If (fso. fileexists ("d: \ appPool \ recycleIISPool. log") then

'1-forreading, 2-forwriting, 8-appending

Set file = fso. opentextfile ("d: \ appPool \ recycleIISPool. log", 8, ture)

Else

Set file = fso. createtextfile ("d: \ appPool \ recycleIISPool. log", 8, ture)

End if

'Write (x) write x characters, writeline write line breaks, writeblanklines (n) write N empty lines

File. writeline now & "application pool" & appPoolName & "" has been recycled successfully. "

File. close

Recyclepool. batFile Content:

Cscript D: \ appPool \ recyclepool. vbs platweb

 

With vbs scripts and batch files, combined with the task scheduler, IIS recycling is ensured at every Saturday night.

The scheduled IIS task is successfully executed in windows.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.