Take an example of accessing the Web.
Assuming a host, its memory is 4g,2 CPU, if the server receives 1000 static requests (each request occupies 2M space), 50 dynamic requests (each request consumes 10M space), the space occupied nearly to the server's memory limit, when the server processing request is very slow, It is difficult to meet customer needs.
Workaround: Scale on (extend up), expand memory and CPU, and process requests by invoking a well-performing host. Defects: can only be used within a certain range, and the price is difficult to accept.
Scale out (scaled out), plus server. That is, the load balancer.
LB: Load Balancer Cluster
650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M00/84/67/wKiom1ePsayCmimLAAAjDXWMcJY476.png-wh_500x0-wm_3 -wmp_4-s_449041825.png "title=" 1.png "alt=" Wkiom1epsaycmimlaaajdxwmcjy476.png-wh_50 "/>
As shown in the request access front end server, the front End server distributes the request to 3 servers in the background for processing.
3 servers, the user request may be only one, how to implement the user request to 3 servers?
With DNS A records, different resolutions return different return values (load balancing). The front-end server sends the request to the backend server through some scheduling algorithm. (RR: Rotation, request the first time to 1, the second to 2, the third to 3, and so on), assuming that 1 of the performance is 2 and 3 times, in order to consider fairness and efficiency, ANI, so with (WRR: weighted rotation algorithm, the 1th server set weight twice, the other 2 sets weight two. )
If the user sends a post to the 1 server, the second visit when the request is distributed to 2 servers, the posts can not be seen, in order to resolve the above problems, the user will be sent to the 1 server to save the posts to the database, so that when the re-access request is distributed to the 2 server is, By retrieving the database to obtain the data, it allows the request to retrieve information regardless of the server to which it arrives.
Note: Where are the uploaded attachments saved to? such as uploading images, the image itself cannot be saved to the database, you can save the uploaded attachment to another Device (NFS), the database saves the attachment link, if the request to access the attachment, you can access the database saved links to get the required attachments. The paging file should not be placed on the NFS server and should be on-premises. If you need to update the page, through the Rsync service to the 1th host file directory as an update directory, after the 1 update notify 2 and 3, let them copy the file in the past, which will not cause the page out of sync. The working schematic is as follows:
650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M01/84/67/wKiom1ePtgTTxK4qAABX10DGXPA974.png-wh_500x0-wm_3 -wmp_4-s_3866471242.png "title=" 2.png "alt=" Wkiom1eptgttxk4qaabx10dgxpa974.png-wh_50 "/>
HA: Highly Available cluster
If there is only one front-end server, if the front-end server hangs, the entire cluster hangs, which is obviously unreasonable.
Add a front end server, one as primary, one as secondary, the master hangs up later, secondary work. This is called High availability Clustering (HA).
Two front-end servers through heartbeat detection to determine whether the work, if secondary detect primary heartbeat, will think primary is dead, will be robbed of resources over the dispatch.
Heartbeat: Every second or half a second pass, can receive a heartbeat, prove to be alive.
650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M01/84/67/wKiom1ePuObDE9ELAABb5mJgv0I510.png-wh_500x0-wm_3 -wmp_4-s_2192698916.png "title=" 3.png "alt=" Wkiom1epuobde9elaabb5mjgv0i510.png-wh_50 "/>
The difference between HA and lb:
LB has a certain high availability, but not a highly available cluster, because the backend server does not have heartbeat detection; LB is focused on improving the concurrency of services, and HA is based on the ability to improve the service's always on-line capability.
If the 3rd host is hung, the scheduler will re-distribute the request to 1 and 2, so it will not work because 1 hosts are hung.
How to get the front end server to know that the backend server is dead and will not send it a request?
The front-end server has a heartbeat check (health check) on the backend server.
How to measure availability? Online Time/(online time + failure time), generally we use a host of 99%.
NFS, shared storage devices, storage of content shared by front-end machines, and limited concurrency capabilities.
650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M02/84/69/wKiom1eQMu3CaTOGAABB5kRBYGQ437.png-wh_500x0-wm_3 -wmp_4-s_187085767.png "title=" 6.png "alt=" Wkiom1eqmu3catogaabb5krbygq437.png-wh_50 "/>
The first diagram, the DAS storage mode, when the first server writes, NFS notifies the second server by the lock and rejects the second server write to prevent the storage device from breaking down.
The second diagram, NAS storage mode, a server a process, while writing to the raid device, first on the respective server memory write, and then merge to the shared device, the first server to write 2 rows, the second server deletes 10 rows, merging will cause data loss. This is obviously not good and needs to be managed through the fence mechanism.
when vip< Span style= "font-family: ' The song Body '; > When you access a cluster, a node in the cluster gets the vip vip vip , continue to serve it, the data will not be lost. The disadvantage of this is that if one node in the cluster fails to communicate, the other node in the cluster must ensure that the failed node is isolated from the shared resource being accessed in order to regain access to the vip Span style= "font-family: ' Times New Roman ';" >fence mechanism to complete.
650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M00/84/69/wKiom1eQNoexPOfiAAAjwrYmPR8952.png-wh_500x0-wm_3 -wmp_4-s_3581483408.png "title=" 7.png "alt=" Wkiom1eqnoexpofiaaajwrympr8952.png-wh_50 "/>
Between the two hosts through the heartbeat detection is still alive.
This article is from the "11721816" blog, please be sure to keep this source http://11731816.blog.51cto.com/11721816/1828296
Classification, characteristics and differences of clusters