Experience sharing of 7-layer soft load under Windows

  
                

This article will introduce you to do some analysis of the 7-layer soft load under Windows. If you are interested in this load, you can take a look. In fact, the so-called four layers are load balancing based on IP+ ports; the seventh layer is load balancing based on application layer information such as URLs; you have a shallow impression on the 7th layer, then everyone has the experience of doing 7 layers of soft load can be discussed Share it, of course, it is best under the windows platform.

Performance Analysis

1. Connection management and protocol resolution for external network use http.sys (HttpApi.dll, HttpListener) built-in mechanism, http.sys for HTTP connection management at the kernel level and Protocol resolution, performance should be guaranteed.

2, the connection management and consolidation of the intranet RealServer using HttpWebRequest built-in mechanism, but the following problems

a) Connection management: the default proxy to send a request to RealServer will establish a new connection After receiving the response, the connection will be removed, which means that a large number of connections will be established between the Proxy and the RealServer, but due to the limitation of the port (65535), the outbound connection cannot be too much. To solve this problem, you can try to enable KeepAlive to solve RealServer.

b) Package: After the HttpListener receives the package, it will automatically resolve to the object, but also re-splicing the package into the HttpWebRequest format and send it to RealServer, which includes copying Uri, HttpHeader, Cookies, Body, etc., the amount of data is quite large, copying the memory in the memory for a certain loss performance. This issue should be unavoidable.

3, if it is a regular web application (resource access class), Request is small, Response is very large, RealServer also needs to go through the Proxy when returning Response, but also to copy the memory, this also affects performance. Then Layer 7 can't do the DirectRoute mechanism of LVS (you need to modify the mac address of the network packet), and the state transition of IP tunnel and TCP needs to modify the TCP/IP protocol stack of the operating system. Given the cost, the issue is not circumvented.

4, Http protocol specifies that the request and response must appear in pairs, by default, after sending a request on a connection, you must wait until the response corresponding to the request is received before sending the next request, although Http1.1 has The pipeline function can send requests in batches without waiting for a response first, but there are also many restrictions, such as specifying that POST should not use a pipeline, the first time a connection is sent, the pipeline mechanism cannot be used, and there are requests for each batch of requests. The number is not well determined. After the request is sent in batches, if the connection is broken, multiple requests will fail, and so on. The HTTP protocol does not match the request and response by CallID and Cseq like the SIP protocol, so that the request and response can be sent and received asynchronously, so when the Http protocol stack is implemented, the response is synchronously waited, and then the next batch of requests can be sent on the connection. This will inevitably affect performance.

5, HttpListener asynchronous receiving request and send response is the ordinary APM mode (BeginXXX, EndXXX format), this asynchronous mode will generate and destroy a large number of IAsyncRequest objects when frequently called, thereby increasing the pressure on the GC And the IAsyncRequest object does not yet provide a custom pooled interface. If HttpListener provides a new event-based asynchronous mode (XXXAsync (eventargs) mode, refer to the Socket.ReceiveAsync method) will solve this problem.

6. In addition, since HttpLisenter is a .NET wrapper class, it is executed in user mode, while HTTP.SYS is running in kernel mode. When accepting a request, the return response will be performed between the user state and the kernel state. Switching, thus reducing performance, if you can directly carry out 7-layer forwarding in the kernel state, LVS (KTCPVS) can achieve kernel-based content-based 7-layer forwarding under Linux, and may need to do TDI or NDIS development under Windows. Checking some information is too complicated, so I don't think about it first.

Reliability Analysis

For disaster tolerance and reliability, consider the following scheme

1. There must be 4 layers of load devices in front of the 7-layer soft load, 7 layers of soft Load multiple, and share the hash policy, the 4-layer device performs random load according to Session, so that all 7-layer soft load machines can correctly handle any request, and after a 7-layer soft load is down, the remaining 7 Layer soft load can continue to work. Because the 4-layer load has keepalive function, it can detect which 7-layer soft load is down, and does not forward requests to it.

2. The 7-layer soft load is double-clicked hot standby, and the 7-layer soft load is directly connected to the external network. Under normal circumstances, the request is processed by the primary server. If the primary server is down, the backup server discovers and then spoofs through ARP. Obtain the original IP address of the primary server to attract the request to the backup server. If the hardware supports support, you may consider that the primary and backup devices share a MAC address. The active/standby switchover may cause a short-term request failure.

Considering the second option, there are some cottages and no insurance, giving priority to the first option. Previous1234Next page Total 4 pages

Copyright © Windows knowledge All Rights Reserved