Some understanding of distributed and cluster

Some understanding of distributed and cluster

distributed functions:
1. Improve availability (you can't ask users in Beijing to access the servers in Guangzhou (the network speed is slow)).
2. Improve system performance, users in different regions access servers in different regions.
3. In terms of data storage, the storage capacity can be increased.
4. Reduce the pressure on a single database.


The role of the cluster:
1. It can perform load balancing, and distribute the multi-user requests to the servers in the cluster for processing, (this request is processed by this server, and the other request is processed by another server)
2. If in terms of data storage, It can improve the reliability of data, one is down and the other is in.



Web load balancing
1. HTTP redirection
When a user sends a request, the web server returns a new url by modifying the Location tag in the HTTP response header , and then the browser continues to request this new url,
which a page redirection. Through redirection, the goal of "load balancing" is achieved.

This redirect is very easy to implement and can be customized with various strategies. However, it does not perform well under large-scale traffic. Moreover, the user experience is not good, and the actual request
is redirected, which increases the network delay.


2. Reverse proxy load balancing
The core work of the reverse proxy service is to forward HTTP requests, playing the role of relay between the browser and the background web server. There are many softwares that can do reverse proxy,
one is Nginx.




In reverse proxy, a common problem is the session data stored by the web server, because the general load balancing strategy is to randomly assign requests. the request of the same logged-in user,
There is no guarantee that they will be allocated to the same Web machine, which will lead to the problem that the session cannot be found.
There are two main solutions:
1. Configure the forwarding rules of the reverse proxy, so that the request of the same user must fall on the same machine (by analyzing the cookie). The complex forwarding rules will consume more CPU and increase the
Added the burden of proxy server.
2. Store information such as sessions in an independent service, such as redis/memchache. This solution is recommended.


3. IP load balancing
When the load balancing server receives the IP packet from the client, it will modify the destination IP address or port of the IP packet, and then deliver it to the internal network intact, and the data packet will flow into the actual web
server. After the actual server processing is completed, it will deliver the data packet back to the load balancing server, which then modifies the target IP address to the user IP address, and finally returns to the client.



4. DNS load balancing
A domain name can be configured to correspond to multiple IPs. When DNS, you can get the server that is closest to you in the DNS information and choose to make a request with that server.



Summary:
database clustering is to improve reliability (backup) , to improve throughput (each can serve data (but requires consistency, otherwise data may not be up-to-date)).

Database distribution improves data capacity and partition management.

But now most large systems are distributed and done in conjunction with clusters.


Reference to the original text: http://kb.cnblogs.com/page/509402/

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327018036&siteId=291194637