Wishlist 0 ¥0.00

IIS 之 在IIS7、IIS7.5中应用程序池最优配置方案

找到Web站点对应的应用程序池,“应用程序池” → 找到对应的“应用程序池” → 右键“高级设置...”

  

一、一般优化方案

  1、基本设置

  [1] 队列长度: 默认值1000,将原来的队列长度改为 65535。

  [2] 启动32位应用程序:默认值False,改为True, 否则安装一些32的组建或32位的php都会出错。

  [3] 托管管道模式:Integrated 或 Classsic。 

  

  2、高级设置

  [1] 闲置超时(分钟):默认20分钟,修改设长。

  [2] 快速故障防护 → 已启用 :默认True,改为False。 

  

  3、解决PEP第一次打开PEP速度慢

  回收间隔时间

  

  使用windows server 2008 r2解决回收假死的问题

  打开应用程序池 -> 高级设置 ->在“禁止重叠回收”里选择“true”,这样就有效避免了应用程序池回收假死问题。

  

二、支持同时10万个请求

  通过对IIS7的配置进行优化,调整IIS7应用池的队列长度,请求数限制,TCPIP连接数等方面,从而使WEB服务器的性能得以提升,保证WEB访问的访问流畅。

  站点碰到如下问题:

  Error Summary:

  HTTP Error 503.2 - Service Unavailable
  The serverRuntime@appConcurrentRequestLimit setting is being exceeded.

  Detailed Error Information:

  Module IIS Web Core
  Notification BeginRequest
  Handler StaticFile

  Error Code 0x00000000

  由于之前使用的是默认配置,服务器最多只能处理5000个同时请求,今天下午由于某种情况造成同时请求超过5000,从而出现了上面的错误。

  为了避免这样的错误,我们根据相关文档调整了设置,让服务器从设置上支持10万个并发请求。

  具体设置如下:

  1. 调整IIS 7应用程序池队列长度

  将原来的队列长度由默认值 1000 改为 65535。当然这里的队列长度你可以根据自己的 访问用户*1.5 来设置,例如:有2000用户,此处就可以设置为3000(3000=2000用户数*1.5)。

  2.  调整IIS 7的appConcurrentRequestLimit设置

  由原来的默认5000改为100000。

  [1] 在cmd中执行:

  c:\windows\system32\inetsrv\appcmd.exe set config /section:serverRuntime /appConcurrentRequestLimit:100000

  [2] 在%systemroot%\System32\inetsrv\config\applicationHost.config中可以查看到该设置:

  <serverRuntime appConcurrentRequestLimit="100000" />

  

  

  3. 调整machine.config中的processModel>requestQueueLimit的设置

  [1] 单击“开始”,然后单击“运行”,或者 windows + R。

  [2] 在“运行”对话框中,键入 notepad %systemroot%\Microsoft.Net\Framework64\v4.0.30319\CONFIG\machine.config,然后单击“确定”。(不同的.NET版本路径不一样,可以选择你自己当前想设置的.NET版本的config)

  [3] 找到如下所示的 processModel 元素:<processModel autoConfig="true" />

  [4] 将 processModel 元素替换为以下值:<processModel enable="true" requestQueueLimit="15000" />

  

  [5] 保存并关闭 Machine.config 文件。
  由原来的默认5000改为100000。

<configuration>
    <system.web>
        <processModel enable="true" requestQueueLimit="100000"/>

  参考文章:http://technet.microsoft.com/en-us/library/dd425294(office.13).aspx

  4. 修改注册表,调整IIS 7支持的同时TCPIP连接数

  由原来的默认5000改为100000。在cmd中执行:

  reg add HKLM\System\CurrentControlSet\Services\HTTP\Parameters /v MaxConnections /t REG_DWORD /d 100000

  

  可在注册表中查看

  

  5. 运行命令使用设置生效

  net stop http  & net start  http & iisreset

  完成上述5个设置,就可以支持10万个并发请求,博客园博客服务器已经启用上述设置。

  为了方法大家与自己使用,我把上面能用bat操作简单放到一个bat文件里面了。将下面的内容保存为do.bat文件运行就可以了,需要手工的自己操作

 

三、支持高并发的IIS Web服务器常用设置   

  适用的IIS版本:IIS 7.0, IIS 7.5, IIS 8.0

  适用的Windows Server版本:Windows Server 2008, Windows Server 2008 R2, Windows Server 2012

  1、应用程序池(Application Pool)的设置:

  [1] General->Queue Length设置为65535(队列长度所支持的最大值)
  [2] Process Model->Idle Time-out设置为0(不让应用程序池因为没有请求而回收)
  [3] Recycling->Regular Time Interval设置为0(禁用应用程序池定期自动回收)

  2、.Net Framework相关设置

  [1] 在machine.config中将
  < processModel autoConfig="true" />

  改为

  <processModel enable="true" requestQueueLimit="100000"/>

  (保存后该设置立即生效)

  [2] 打开C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\Browsers\Default.browser,找到<defaultBrowser id="Wml" parentID="Default" >,注释<capabilities>部分,然后在命令行中运行aspnet_regbrowsers -i。以解决text/vnd.wap.wml问题。

 

  设置命令:

  c:\windows\system32\inetsrv\appcmd.exe set config /section:serverRuntime /appConcurrentRequestLimit:100000
  设置结果:
  < serverRuntime appConcurrentRequestLimit="100000" />

  (保存后该设置立即生效)

  4、http.sys的设置

  注册表设置命令1(将最大连接数设置为10万):
  reg add HKLM\System\CurrentControlSet\Services\HTTP\Parameters /v MaxConnections /t REG_DWORD /d 100000

  注册表设置命令2(解决Bad Request - Request Too Long问题):

  reg add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\HTTP\Parameters /v MaxFieldLength /t REG_DWORD /d 32768
  reg add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\HTTP\Parameters /v MaxRequestBytes /t REG_DWORD /d 32768

  (需要在命令行运行 net stop http  & net start http & iisreset 使设置生效)

  5、针对负载均衡场景的设置

  在Url Rewrite Module中增加如下的规则:

 

  注意事项:添加该URL重写规则会造成IIS内核模式缓存不工作,详见微软的坑:Url重写竟然会引起IIS内核模式缓存不工作。

  6、 设置Cache-Control为public

  在web.config中添加如下配置:

复制代码
<configuration>
 <system.webServer>
  <staticContent>
   <clientCache cacheControlCustom="public" />
  </staticContent>
 </system.webServer>
</configuration>
复制代码
 

  在machine.config的<processModel>中添加如下设置:

< processModel enable="true" maxWorkerThreads="100" maxIoThreads="100" minWorkerThreads="50" minIoThreads="50"/>

 

如何设置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的时候,就需要输入账号密码才能发信。

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.