Server Load balancer-related

Source: Internet
Author: User
1. network load balancing working principle

Network Load Balancing uses a cluster of two or more host computers working together to provide high availability and scalability for servers. An Internet client uses an IP address or a group of addresses to access the cluster. Clients cannot distinguish clusters from single servers. Server ApplicationsProgramIt does not indicate that they are running on the cluster. However, a network load balancing cluster is very different from a single host running the application sequence of a single server, because even if a cluster host fails, it can also provide uninterrupted services. The cluster responds to client requests faster than a single host.

If a host fails or is offline, network load balancing redirects incoming network communication to a working cluster host, resulting in high availability. Existing connections to the offline host will be lost, but the Internet service is still available. In most cases (for example, for Web servers), the client software can automatically retry failed connections, and the client only has several seconds of delay when receiving the response.

Network Server Load balancer allocates incoming network communication between one or more virtual IP addresses (cluster IP addresses) assigned to the Network Server Load balancer cluster, resulting in changeable performance. Then, the host in the cluster simultaneously responds to different client requests or even multiple requests from the same client. For example, a Web browser can obtain multiple images on all webpages from different hosts in a network load balancing cluster. This increases the processing speed and shortens the response time to the client.

Network Load Balancing allows all cluster hosts on a single subnet to simultaneously detect incoming network communication with the cluster IP address. On each cluster host, the network load balancing driver acts as a filter between the cluster Adapter driver and the TCP/IP stack for communication between hosts.

Network Load Balancing adopts a completely distributedAlgorithmIng the IP address and port of the client to the cluster host in statistical mode. This process does not require any communication between hosts. When a data packet is found, all hosts execute this ing at the same time to quickly determine which master machine should process this package. The ing remains unchanged until the number of cluster hosts changes. Compared with a centralized load balancing application, the network load balancing filtering algorithm processes data packets more efficiently, because the former must modify and re-transmit data packets.

Distribution of cluster communication

Network load balancing controls the distribution of TCP and UDP communications between the selected hosts from the Internet client to the Group through the following methods: After network load balancing is configured, all hosts in the cluster receive incoming client requests sent to the cluster IP address. Network Load Balancing filters incoming data packets sent to the specified TCP and UDP ports before these data packets arrive at the TCP/IP software. Network Load Balancing manages TCP and UDP protocols in TCP/IP, so as to control their operations one by one.

In multicast mode, network load balancing supports the Internet Group Management Protocol (IGMP) to limit the exchange of streams. In addition to TCP and UDP Communication of the specified port and IGMP communication in multicast mode, network load balancing does not control any incoming IP communication. It does not filter other IP protocols (for example, ICMP or ARP), except in the following cases. Note that when using the cluster IP address, you should see repeated responses from specific point-to-point TCP/IP applications (such as PING. If necessary, these applications can use private IP addresses for each host to avoid this operation.

Aggregation

To coordinate its operations, the network load balancing host periodically exchanges detection signals within the cluster (for more information, see Internet Group Management Protocol (IGMP )). IP multicast allows the host to monitor the cluster status. When the cluster status changes (for example, when the host fails, leaves, or joins the cluster), network load balancing calls a process called "aggregation". In this process, the host exchanges a limited number of messages to determine the new consistent status of the cluster, and specify the highest host priority for the host, that is, as the new default host. When all cluster hosts are consistent in the correct new cluster status, they will record aggregation completion in Windows event logs. It generally takes less than 10 seconds to complete this process.

During aggregation, other hosts continue to process incoming network communication. Client requests to the working host are not affected. After the aggregation is completed, the communication aimed at the faulty host is resold to the active host. After load balancing, the communication will be re-divided among the still working hosts, so as to achieve better load balancing for specific TCP or UDP ports.

If a host is added to the cluster, aggregation allows the host to receive its own load balancing communication. Cluster Expansion does not affect ongoing cluster operations, and its implementation process is transparent to Internet clients and server applications. However, when "client similarity" is selected, it may affect client sessions across multiple TCP connections, because the client may be rereflected to different cluster hosts between connections. For more information about similarity, see network load balancing and controllable connections.

Network Load Balancing assumes that the host's normal operation time in the cluster is as long as it exchanges detection signals with other cluster hosts. If no response from any member is received by other hosts during multiple detection signal exchanges, aggregation is started to resend the load originally processed by the failed host.

You can control the message exchange period and the number of lost messages required to start aggregation. The default value is 1000 ms (1 second) and 5 lost message exchange periods. Because these parameters are not modified, you cannot configure them in the "Network Load Balancing properties" dialog box. If necessary, you can manually adjust them in the registry. Adjust the aggregation parameters to describe the process of completing this operation.

2,

ASP. NET provides a simple and easy-to-use session state model that allows you to store arbitrary data and objects across multiple Web requests. It uses a dictionary-based, in-Memory Object Reference (these object references exist in the IIS Process) cache to complete this operation. When using the in-process session Status mode, consider the following restrictions:

When the in-process session Status mode is used, if the aspnet_wp.exe or application domain restarts, the session status data will be lost. These reboots usually occur in the following situations:

In the <processmodel> element of the web. config file of the application, set an attribute that causes the new process to start when the condition is met, such as memorylimit.

Modify the global. asax or web. config file.

Change to the bin directory of the Web application.

Scan and modify files in the global. asax file, Web. config file, or bin directory of the Web application using anti-virus software.

If the network garden mode is enabled in the <processmodel> element of the web. config file of the application, do not use the in-process session state mode. Otherwise, random data will be lost.

There are also two types:

1: Set the http://www.dotnet247.com/247reference/msgs/58/290316.aspx on the first page

Asp.net's default configuration causes and solutions for inexplicable session loss

Under normal operation, the session will be lost for no reason. Because the program is constantly being operated, the possibility of session timeout is ruled out. In addition, the session timeout time is set to 60 minutes, and will not time out so quickly.

I searched the post on csdn this time and found many people discussing this issue. Then I googled it and found similar content on Microsoft's website.

Now I will write down the cause and solution.

Cause:

Because the Asp.net program is configured by default, the session settings in the web. config file are as follows:

<Sessionstate mode = 'inc' stateconnectionstring = 'tcpip = 127.0.0.1: 42424 'sqlconnectionstring = 'data source = 127.0.0.1; trusted_connection = Yes 'cookieless = 'true' timeout = '60'/> we will find that there is an attribute mode in the sessionstate tag, which can have three values: inproc and StateServer? Sqlserver (case sensitive ). The process is unstable. When some events occur, the process restarts, causing the loss of sessions stored in the process.

Under what circumstances will the process be restarted? MicrosoftArticleTold us:

1. memorylimit attribute of the processmodel label in the configuration file

2. The Global. asax or web. config file is changed.

3. The web program (DLL) in the bin folder is modified.

4. Anti-Virus Software scanned some. config files.

For more information, see PRB: Session variables are lost intermittently in ASP. NET applications.

Solution:

In the sessionstate label mentioned above, the mode attribute can have three values: StateServer and sqlserver. The two session types are both external, so when aspnet_wp.exe is restarted, the session will not be affected.

Set the mode to StateServer. StateServer is a service on the local machine. You can see the service named ASP. Net state service in the system service. It is not started by default. After we set the mode to StateServer, manually start the service.

In this way, we can use the stateservice of the Local Machine to store sessions. The session will not be lost unless the computer restarts or the stateservice breaks down (it is normal that the session is discarded due to session timeout ).

In addition, sessions can be saved through stateservice on other computers. The specific modification is as follows. Also in the sessionstate label, there is a stateconnectionstring = 'tcpip = 127.0.0.1: 8080' attribute, where there is an IP address, the default is the local machine (127.0.0.1 ), you can change it to the IP address of the computer that runs the stateservice service as you know, so that the Asp.net program located on different computers can communicate with each other.

If you have higher requirements and the session is not lost when the service period is restarted, you can set the mode to sqlserver and modify the sqlconnectionstring attribute. For information on how to use sqlserver to save sessions, visit here.

When you use StateServer or sqlserver to store a session, all objects to be saved to the session must be serialized except the basic data type (default data type, such as int and string. You only need to put the [serializable] label before the class to be serialized.

Working principle of session in ASP:

ASP sessions are process-dependent. The ASP sessionstate is stored in the iisprogress, and the program inetinfo.exe is also used. When the inetinfo.exe process crashes, the information is lost. In addition, restarting or disabling the IIS service will cause information loss.

Implementation of Asp.net session

The session of Asp.net is based on the httpmodule technology. The httpmodule can control the Request status before the request is processed. Because the session itself is used for status maintenance, therefore, it is more appropriate to use httpmodule for session.

Cause 1:

Files in the bin directory are rewritten. Asp.net has a mechanism. To ensure that the system runs normally after the DLL is re-compiled, it restarts a website process, which will cause session loss, therefore, if an Access database is in the bin directory or another file is rewritten by the system, session loss occurs.

Cause 2 :(This is often the case)

In the folder option, if the "Open folder window in a separate process" is not opened, once a new window is created, the system may consider it as a new session and cannot access the original session, therefore, you must enable this option. Otherwise, the session will be lost.

Cause 3:

It seems that most of the session loss is caused by the client, so you have to start from the client to see if the cookie has been opened.

Cause 4:

Is there a problem with the session time settings? Will it be lost due to timeout?

Cause 5:

The maximum number of cookies in IE (20 cookies per domain) may cause session loss.

Cause 6:

The Web garden mode and inproc mode are used to save the session

Solving lost experiences

1. Determine if it is caused by cause 1. You can track the modification time of a file in the bin every time you refresh the page.

2. for session read and write logs, each read and write session must be recorded, and the session operations of sessionid, session value, page, current function, and function must be recorded, this makes it much easier to find out the cause of the loss.

3. If this is allowed, we recommend that you use state server or SQL Server to save the session, which is not easy to lose.

4. AddCodeRecord the session creation time and end time. The session loss caused by timeout can be recorded in sessionend.

5. If some code uses client scripts, such as JavaScript to maintain the session status, you should try to debug the script to check whether the session is lost due to a script error.

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.