Wishlist 0 ¥0.00

如何设置IIS程序池的回收时间,才能最大程度的减少对用户的影响?

作为.Net开发人员,其实对IIS的应用程序池知之甚少,前段时间被问到一个问题:

对于互联网web应用,如何在用户毫无感知的情况下回收程序池?(对用户产生最小的影响)

 

简单理解IIS应用程序池

应用程序池可以看成是计算机分配给Web应用程序的内存的容器。

网络上有人这样比喻:如果是水,那么应用程序池就是,Web应用程序就是鱼缸里的金鱼。多个Web应用程序可以放在同一个应用程序池里面,也就是说一个鱼缸可以养多条金鱼。如果金鱼多了,鱼缸的的空间有限,那么金鱼之间就会争抢生存空间,不是很坚固的鱼缸就会破裂,所有的金鱼(网站)就会受到影响,即内存不足,造成内存溢出的问题。如果时间久了,鱼缸里面的水质就会变差,金鱼就好像生活在臭水沟里,因此我们需要定期换水(回收程序池)。 

 

程序池自动回收优化

IIS的程序池默认回收间隔是1740分钟(29小时),在自动回收过程中,应用程序池将会清空,保留在内存中的数据将会被清理(相当于IIS重启)。对于互联网应用程序,为了减少服务器的负担,也许会选择将大量数据暂存在内存中,回收会造成内存数据丢失,如果没有及时保存到数据库中,可能导致应用程序出问题。如果遇到系统使用高峰期,回收将可能导致一段时间应用程序无响应(出现假死状态),给予用户一种很不好的体验。 在优化应用程序池之前,我们应用先了解下程序池的几个配置信息:

发生配置更改时禁止回收:如果为True,应用程序池在发生配置更改时将不会回收。 
固定时间间隔(分钟):超过设置的时间后,应用程序池回收,为0意味着应用程序池不会按固定间隔回收。 系统默认设置的时间是1740分钟(29小时)。 
禁用重叠回收: 如果为true,将发生应用程序池回收,以便在创建另一个工作进程之前退出现有工作进程。 
请求限制: 应用程序池在回收之前可以处理的最大请求数。如果值为0,则表示应用程序池可以处理的请求数没有限制。 
生成回收事件日志条目: 每发生一次指定的回收事件时便产生一个事件日志条目,里面的明细设置不一一介绍。

问题分析:每1740分钟(29小时)回收一次是否合理?

不太合理,这个周期内,有可能应用程序处于访问高峰期。因为每天的回收时间都是不一样的,很有可能在高峰期回收,就会造成短时间内网站访问出现问题。因此,要避免最大程度的减少对用户的影响,我们需要充分的分析应用程序的访问情况,例如哪个时间段是高峰,哪个时间段访问人数最少。了解到这些后,应用程序部署人员就应该设定固定的回收时间,例如一个网站凌晨两点访问人数是最少的,那么它可以设置“特定回收时间”在凌晨两点,应用程序池里面的特定时间是支持设定多个的,请注意。 

 

Configure SMTP E-mail (IIS 7)

Applies To: Windows 7, Windows Server 2008, Windows Server 2008 R2, Windows Vista

Configure SMTP e-mail in IIS when you want to deliver e-mail messages from your site. Mail can be delivered immediately or it can be delivered to a file location on disk where it can be retrieved for delivery later. For example, a company can provide an e-mail link for sending feedback messages or for requesting information.

Note

The e-mail configuration settings are consumed by the classes in the System.Net.Mail namespace. ASP.NET applications must use this namespace in for the configuration settings to have any effect.

Note

The SMTP server is not installed by default. SMTP can be added through the Features Summary area of the Server Manager tool in Windows Server® 2008.

Prerequisites

For information about the levels at which you can perform this procedure, and the modules, handlers, and permissions that are required to perform this procedure, see SMTP E-mail Feature Requirements (IIS 7).

Exceptions to feature requirements

  • None

To configure SMTP e-mail for a Web application

You can perform this procedure by using the user interface (UI), by running Appcmd.exe commands in a command-line window, by editing configuration files directly, or by writing WMI scripts.

User Interface

To Use the UI

  1. Open IIS Manager and navigate to the level you want to manage. For information about opening IIS Manager, see Open IIS Manager (IIS 7). For information about navigating to locations in the UI, see Navigation in IIS Manager (IIS 7).

  2. In Features View, double-click SMTP E-mail.

  3. On the SMTP E-mail page, type the e-mail address of the sender in the E-mail address text box.

  4. On the SMTP E-mail page, select one of the following delivery methods:

    1. Deliver e-mail to SMTP server: to deliver e-mail messages immediately. This requires an operational SMTP server for which the user has credentials.

    2. Store e-mail in pickup directory: to store e-mails in a file location on disk for later delivery by an application such as an ASP.NET application, or by a user, such as an administrator.

  5. If Deliver e-mail to SMTP server is selected, do the following:

    1. Type the unique name of your SMTP server in the SMTP Server text box or select the Use localhost box to set the name to LocalHost. Setting the name to LocalHost means that ASP.NET will use an SMTP server on the local computer. Typically, this is the default SMTP virtual server.

    2. Enter a TCP port in the Port text box. Port 25 is the SMTP standard TCP port and is the default setting. More than one virtual server can use the same TCP port if all servers are configured by using different IP addresses.

    3. Under Authentication Settings, specify the authentication mode and credentials if your SMTP server requires these.

  6. If Store e-mail in pickup directory is selected, type the batch e-mail location in the Store e-mail in pickup directory text box.

  7. Click Apply in the Actions pane.

Command-line

Deliver e-mail messages immediately

To configure SMTP e-mail to deliver e-mail messages immediately, use the following syntax:

**appcmd set config /commit:WEBROOT /section:smtp /from:**string **/deliveryMethod:network /network.port:**int /network.defaultCredentials:True|**False /network.host:**string **/network.userName:**string **/network.password:**string

The variable **from **string is the e-mail address of the sender. The variable /deliveryMethod:network configures IIS to deliver e-mail messages immediately. The variable **/network.port **int sets the TCP port that is used by IIS to deliver e-mail messages. The variable **/network.host **string specifies the host used for SMTP transactions. The variable network.defaultCredentials:True|False enables or disables authentication using the default network credentials. If defaultCredentials is set to True, Kerberos or NTLM will be used if the server supports these protocols. The variables **network.userName:**string and **network. password:**string set a Basic authentication user name and password.

Store e-mails for later delivery

To configure SMTP e-mail to store e-mails in a file location on disk for later delivery by an application, such as an ASP.NET application, or by a user, such as an administrator, use the following syntax:

**appcmd set config /commit:WEBROOT /section:smtp /from:**string /deliveryMethod:PickupDirectoryFromIis|**SpecifiedPickupDirectory /SpecifiedPickupDirectory:**string

The variable from string is the e-mail address of the sender. The variable/deliveryMethod:PickupDirectoryFromIis|SpecifiedPickupDirectory configures IIS to store e-mails in a file location on disk for later delivery. The variable **/SpecifiedPickupDirectory **string sets the file location on disk in which to store the e-mail messages for later delivery.

Note

When you use Appcmd.exe to configure the <mailSettings> element at the global level in IIS 7, you must specify /commit:WEBROOT in the command so that configuration changes are made to the root Web.config file instead of ApplicationHost.config.

For more information about Appcmd.exe, see Appcmd.exe (IIS 7).

Configuration

The procedure in this topic affects the following configuration elements:

  • <mailSettings>

For more information about IIS 7 configuration, see IIS 7.0: IIS Settings Schema on MSDN.

WMI

Use the following WMI classes, methods, or properties to perform this procedure:

  • SmtpMailSettingsSection

For more information about WMI and IIS, see Windows Management Instrumentation (WMI) in IIS 7. For more information about the classes, methods, or properties associated with this procedure, see the IIS WMI Provider Reference on the MSDN site.

IIS6的SMTP

1、安装。Windows2003的IIS6集成了SMTP服务,非常好用,不过默认没有安装,请安装之。开始-〉设置-〉控制面板-〉添加或删除程序-〉添加/删除Windows组件-〉应用程序服务器-〉Internet信息服务(IIS)-〉SMTP Service,打勾,然后确定到底。


2、配置SMTP服务器。开始-〉设置-〉控制面板-〉管理工具-〉Internet信息服务(IIS)管理器-〉展开本地计算机目录,再最下面找到“默认的SMTP”展开-〉域-〉右键,新建域-〉“远程”下一步-〉名称填“*.com”完成-〉双击“*.com”域-〉“允许将传入邮件中继到此域”打勾,确定。


3、配置邮件客户端。实在懒得装FoxPro了,就用Outlook Express试验了。打开Outlook-〉“工具”菜单-〉账户-〉“邮件”选项卡-〉更改默认的或者新建一个,然后进属性-〉“姓名”、“电子邮件地址”项随便填-〉“服务器”选项卡-〉“接收邮件(POP3)”随便填,“发送邮件(SMTP)”填写“127.0.0.1”,“接收邮件服务器”的“帐户名”随便填-〉确定到底。


4、测试。用刚刚配置好的邮件客户端发送一封信到你的邮箱,注意:一定要把你的邮箱的自动过滤功能关掉或者级别降低,不然会收不到。比如微软的hotmail(Windows Live Mail),你需要进入“选项”里面,把过滤级别调到“低”,这样才能收到。 

5、如何让客户端通过认证才能使用此SMTP。你需要在Windows里面新建一个账户,Users级的权限就行,Administrator不能当作认证用途。然后在你的SMTP服务器上点右键,属性-〉访问-〉身份验证,把“匿名”的勾去掉,把“基本身份验证”的勾打上,然后确定到底。这样,客户端使用此SMTP的时候,就需要输入账号密码才能发信。

windows2008设置IIS服务器定时自动重启的方法

  我们在使用windows2008下IIS服务器时会经常出现资源耗尽的现象,运行一段时间下来就会出现访问服务器上的网站时提示数据库连接出错,重启IIS后网站又能正常访问了,这个问题可能困扰了很多站长朋友。经过不断的实践找到了一个比较笨,但是有效的方法,那就是设置windows2008IIS服务器定时自动重启,在Windows的任务计划中指定一个时间让 IIS服务器自动重启。

设置IIS服务器定时自动重启的方法:(这里我以Windows Server 2008为例)

1、首先开启Windows的任务计划服务Task Scheduler,如果你没有关闭该服务的话,默认是开启的;如果你关闭了该服务,那开启Task Scheduler服务方法如下:

开始→管理工具→服务→在右边的窗口中找到Task Scheduler服务,将其启动类型设为自动,服务状态设为开启即可,相关截图如下所示:

2、开始→程序→附件→系统工具→任务计划程序→点击“创建基本计划”,此时将弹出任务计划向导,填写任务名称,比如:IIS定时重启,相关截图如下所示:

3、点击下一步,进入“任务触发器”页面,选择“每天”,如图:

4、点击下一步,设置开始时间以及重启IIS服务器的具体时间,一般建议夜里执行重启命令,这样不影响网站的正常访问,如下图所示:

5、点击下一步,选择“启动程序”,如图:

6、点击下一步,进入启动程序设置,点击浏览选择:C:\Windows\System32\iisreset.exe 大家应该知道iisreset.exe是IIS服务器的重启程序。如图所示:

7、点击下一步,进入摘要页面,如图所示:

8、点击完成即可

   最后要说,通过设置IIS服务器定时自动重启可以有效解决服务器资源耗尽导致无法访问的问题,此方法适用任何系统(winxp/win7/win8,windows server2000/2003/2008/2010),笔者就不一一举例,设置方法都是大同小异。

About Us

Since 1996, our company has been focusing on domain name registration, web hosting, server hosting, website construction, e-commerce and other Internet services, and constantly practicing the concept of "providing enterprise-level solutions and providing personalized service support". As a Dell Authorized Solution Provider, we also provide hardware product solutions associated with the company's services.
 

Contact Us

Address: No. 2, Jingwu Road, Zhengzhou City, Henan Province

Phone: 0086-371-63520088 

QQ:76257322

Website: 800188.com

E-mail: This email address is being protected from spambots. You need JavaScript enabled to view it.