In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "what is the design strategy of database distributed system". The content of the explanation in this article is simple and clear, and it is easy to learn and understand. let's study and learn "what is the design strategy of database distributed system"!
One: distributed system design strategy
The essence of distributed system is to achieve better throughput, performance and availability by storing low-cost hardware together.
In a distributed environment, there are several issues of common concern, which we call design strategies:
How do I detect that the current node is still alive?
How to ensure high availability?
Fault tolerant processing
Load balancing
1.1: heartbeat detection Why heartbeat detection?
In a distributed environment, there are a large number of Node, which share the task of running, computing, or program logic processing. Then there is a very important question, how to determine whether a node is malfunctioning or even unable to work?
How to detect heartbeat?
Heartbeat detection: a way to detect whether the node is working properly by reporting the current node status to other nodes at a fixed frequency.
If Server does not receive Node3's heartbeat, Server thinks Node3 is missing. However, when you lose contact, you are not sure whether it is caused by Node 3. It is possible that the Node3 is busy, resulting in a call detection timeout, or a link failure or flash break between Server and Node3.
Therefore, the heartbeat is not omnipotent, receive the heartbeat can confirm that the node is normal, but do not receive the heartbeat can not be considered that the node has been declared "dead". In order to solve this situation, periodic detection heartbeat mechanism and cumulative failure detection mechanism are introduced.
Periodic heartbeat detection mechanism: the Server initiates a monitoring request to the Node cluster every t seconds, sets the timeout, and judges "death" if the timeout is exceeded.
Cumulative failure detection mechanism: on the basis of periodic detection heartbeat mechanism, the return situation of nodes in a certain period (including timeout and correct return) is counted, and the "death" probability of nodes is calculated. In addition, a node that declares "dying" can initiate a limited number of retries for further judgment. The periodic heartbeat detection mechanism and cumulative failure detection mechanism can help to judge whether the node is "dead". If the node is judged to be "dead", the node can be kicked out of the cluster.
1.2: highly available design
High availability design: whether a system can provide available services for a long time.
There are three common design patterns of system high availability: active standby (Master-SLave), Active-Active (standby) and Cluster (cluster).
Active / standby mode (used more)
The active / standby mode is Active-Standby mode. When the host goes down, the standby machine takes over all the work of the host. After the host returns to normal, it switches the service to the host to run automatically (hot standby) or manual (cold standby) as set by the user.
Take the database as an example: in the database part, it is called MS schema. MS mode is Master/Slave mode, which is commonly used in database high availability schemes, such as MySQL, Redis and so on. MS mode is used to realize master-slave replication. Ensure high availability, as shown in the figure.
Once binary logging is enabled in a MySQL database, as master, all operations in its database will be recorded in the binary log in the way of "events". Other databases as slave maintain communication with the main server through an I / O thread, and monitor the changes in the master binary log files. If changes are found in the master binary log files, the changes will be copied to their own relay logs. Then a SQL thread of slave executes the relevant "events" into its own database to achieve consistency between the slave database and the master database, that is, master-slave replication.
Interoperability mode (less used)
Mutual standby mode means that two hosts run their respective services at the same time and monitor each other.
In the highly available part of the database, the common interoperability is the MM mode. MM mode, or Multi-Master mode, means that there are multiple master in a system, each master has read-write capability, and versions are merged according to timestamp or business logic.
Cluster mode
Cluster mode means that there are multiple nodes running and service requests can be shared through the master node. Such as Zookeeper. The cluster mode needs to solve the problem of high availability of the master node itself, and generally adopts the active / standby mode.
1.3: fault tolerance
Fault tolerance indicates whether a system has security, stability, robustness, and the ability to tolerate errors.
Take cache traversal as an example:
Using the cache in a project usually checks whether it exists in the cache, returns the cache directly if it exists, queries the database directly if it does not exist, and then caches the query results. At this time, if a certain data we query does not exist in the cache, it will cause every request to query DB, so the cache will lose its meaning. When the traffic is heavy, or someone will maliciously attack it, there will be trouble.
A more ingenious solution is to set the non-existent key to a value in advance. For example, key= "null", write cache. That is, you can directly return null when querying the key, but note that you need to set the expiration time, otherwise it will be wrong to return null when the data exists.
1.4: load balancing
Load balancing: the key is to use multiple cluster servers to share computing tasks and distribute network requests and computing to different server nodes available in the cluster, so as to achieve high availability and better user operation experience.
Load balancers are divided into hard loads (hardware solutions such as F5) and soft loads (software solutions: LVS, HAProxy, Nginx).
Take Nginx as an example, the common load balancing strategies are:
Polling: distribute client Web requests to different back-end servers in turn, according to the order in the Nginx configuration file.
Least connections: who currently has the fewest connections and distributes them to whom.
Ip address hash: make sure that the same IP request can be forwarded to the same backend node for processing to facilitate session retention.
Weight-based load balancing: configure Nginx to distribute more requests to high-configuration back-end servers and relatively few requests to low-configuration servers.
Thank you for your reading. the above is the content of "what is the design strategy of database distributed system". After the study of this article, I believe you have a deeper understanding of what the design strategy of database distributed system is. The specific use of the situation also needs to be verified by practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.