Guide to IIS 5: deep understanding of socket pooling)

Source: Internet
Author: User
Tags windows support metabase

Many of you may have encountered this problem: when starting IIS, you will find that IIS binds the service port (such as TCP 80) configured in the web site to all IP addresses of the computer, not just the IP address assigned to the web site, why?

This feature is calledSocket pooling (socket pool).Socket)It is a combination of IP addresses and ports for network communication. When any application needs to be allowed with other applications on the network, it must have corresponding sockets, for example, if a Web site listens to a customer's HTTP request, it is bound to the corresponding socket (IP address and port, for example, the port is a standard TCP 80. In IIS 4.0, Microsoft found that when multiple web sites are bound to different IP addresses through different sockets, they occupy a large amount of system resources. Therefore, in IIS 5.0, Microsoft introducedSocket pool)This concept works like this: When IIS is started, the Service ports configured for all web sites are bound to all IP addresses of the Computer (run netstat-ano to see, the IP addresses listened on by these Web Service ports represent the"0.0.0.0Regardless of whether or not these IP addresses are assigned to these web sites, IIS calls these socketsSocket poolIIS then allocates the socket in the socket pool to the corresponding web site according to the Web site configuration, this avoids the need for different sockets when different web sites occupy the same Web Service port with different IP addresses, thus reducing the occupation of system resources and improving IIS performance.

Note that,The IP address assigned by the web site is allocated from the IIS socket pool.Therefore, you cannot allocate IP addresses that are not available in the socket pool to the web site. This will make the web site unable to work.

All IIS components haveSocket poolingFeatures. Although this improves IIS performance, other applications cannot bind ports to these IP addresses. For example, if a Web site listens to TCP port 80, IIS listens to TCP port 80 on all IP addresses when it is started. If a Web Service is published in the ISA firewall, if you want to listen to TCP port 80 on the corresponding IP address (for example, the IP address of an external interface), the port binding of the ISA firewall will fail because IIS has occupied these ports.

In this article, I will mainly introduce how to handle the socket pooling (socket pool) of Web Services in IIS 6. Note that I am using"Symptom", Because I thinkSocket poolingThis is not a problem, although many people think so. If no other application needs to occupy the port in the IIS socket pool, you do not need to perform any processing on the socket pooling.

Remember the new architecture of IIS 6 described in "IIS 6 new features" in "IIS user guide? In IIS 5, socket pooling appears as a configurable attribute of metabase. in IIS 6, it is composed of HTTP. sys is used to listen for HTTP requests sent by the customer, so it is also used to processSocket pool. HTTP. sys usesIP address inclusion listTo determine the IP address of the HTTP request you want to listen to, read this list at each startup, and configure it according to this list. By default, this IP address contains a list that does not contain any IP addresses. Therefore, HTTP. sys listens to all IP addresses of the local computer. This IP address list cannot be configured through the IIS console or by modifying metabase. xml. You must use the Windows support tool provided by Microsoft.Httpcfg.

The httpcfg tool is used for HTTP. sys configuration. It is used as a Windows support tool and is attached to the installation disc of Windows Server 2003. First, install the Windows support tool. On the Windows Server 2003 installation disc, double-click the support. MSI file under "disc root directory/support/tools/" and follow the prompts to install the tool.

ClickStart,All programs, PointingWindows support toolsAnd then selectCommand PromptNow you can run httpcfg.

I will show you how to bind two IP addresses to a Web server, as shown in.10.1.1.9,10.1.1.10The default Web Service port of the website in IIS is TCP 80. Therefore, HTTP. sys listens to port 80 of all IP addresses.

Now, first query the IP address inclusion list of HTTP. sys and run the following command:

Httpcfg query iplisten

As shown in, error code 1168 returned indicates that no matching element is found. This means that the IP address contains no elements in the list. Therefore, HTTP. sys listens to all IP addresses of the local computer.

Now we add an IP address to the IP address inclusion list. For example, if I want HTTP. sys to only listen to the IP address 10.1.1.9, run the following command:

Httpcfg set iplisten-I 10.1.1.9

As shown in, returned error code 0 indicates successful completion. Because HTTP. sys only reads the list of IP addresses at startup, We need to restart HTTP. sys.

Run the following command to restart HTTP. SYS:

Net stop HTTP/y

Net start w3svc

As shown in, HTTP. sys is restarted successfully.

Query the IP addresses that contain the list and HTTP. sys listening Web Service ports, as shown in.10.1.1.9.

 

In IIS, we try to assign an IP address that is not included in the HTTP. sys IP address list for the web site. For example10.1.1.10,

At this point, you will find that the web site has stopped service. When you try to start it, the error message is displayed.Cannot access network location.

In addition, if you need to access the web site through localhost, you need to add the loopback IP address 127.0.0.1 to the IP address inclusion list, as shown in:

 

Finally, if you want to restore the socket pool, delete all IP addresses in the IP address list and run the following command:

Httpcfg Delete iplisten-I 127.0.0.1

Httpcfg Delete iplisten-I 10.1.1.9

Shows the result,

 

Restart HTTP. sys.

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.