Windows 7 to do 7-layer soft load experience sharing (1)

  
This article will introduce you to do some analysis of the 7-layer soft load under Windows, you are interested in the load of this piece, you can come and see. 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 external network protocol used in the analysis http.sys (HttpApi.dll, HttpListener) built-in mechanism, http.sys HTTP connection management at the kernel level and Protocol resolution, performance should be guaranteed.

2, RealServer internal network connection management and use HttpWebRequest fight pack built-in mechanisms, but there are problems

a) Connection Manager: Default Proxy to RealServer will send a request to 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) the fight package: HttpListener after reception of a packet has been parsed into objects while automatically, but also to re-form themselves into these packets sent to the RealServer HttpWebRequest format, which involves 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 the conventional web applications (resource access classes), Request small, Response great, but also through Proxy, but also for memory copies when RealServer return Response, this is also very affecting 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 agreement request and response must be paired, connected to a default request out on the transmission until after the next to receive a response after sending a request corresponding to the request, although there Http1.1 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, the asynchronous transmission and reception request is a normal response HttpListener APM mode (BeginXXX, EndXXX format), which generates a large number of asynchronous mode and destruction IAsyncRequest object when called frequently, thereby increasing the pressure of GC And the IAsyncRequest object does not yet provide a custom pooled interface. If the HttpListener provides a new event-based asynchronous mode (XXXAsync (eventargs) mode, refer to the Socket.ReceiveAsync method) will solve this problem.

6, since the addition is HttpLisenter .Net wrapper class, execution in user mode, kernel mode and HTTP.SYS is running, receiving the request, returns a response will be between two user mode and kernel mode Switching, thus reducing performance, if you can directly perform 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 recovery, improve reliability, consider the following program loads the soft front

1.7 layer have Layer 4 load device, the load multiple soft layer 7 Station, 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 layers are soft. The load can continue to work. Because the 4-layer load has the keepalive function, it can detect which 7-layer soft load is down and does not forward the request.

2.7 Double-layer soft load do hot standby, the soft layer 7 load direct access to external networks, normally by the primary server processes the request, if the primary server goes down, the backup server discovery, ARP spoofing acquired by the main The original IP of the server is used to attract the request to the backup server (the hardware may support the sharing of a Mac address between the primary and backup machines if supported), and the short-time request may fail when the active/standby switchover occurs.

Taken together, the second option is not some cottage and insurance, give priority to the first option.
Copyright © Windows knowledge All Rights Reserved