信息技术的发展,渗透到人们各类活动的方方面面,应对的问题五花八门,纷繁错杂,催生了面向各种业务而非常复杂的软件系统。架构的核心目的就在于解决软件系统的复杂性问题,在互联网分布式系统下的大体量的业务,其复杂性尤其高,主要来自下面几个方面:
架构是一个庞大的话题,设计原则、抽象方法、业务解耦、领域模型、模块划分等等,每一个方面都是大有文章。不过,一般来说,不管多么复杂的软件系统,都可以抽象为“基于数据的一系列处理逻辑组合,供目标用户接入使用的系统”,接入、逻辑、数据,这就是本文讨论的“基础架构”,如下图所示。基础架构着重关注高可用、高性能、高扩展的要求,本文将从后台的视角展开,看看这几个要素对于基础架构的设计影响。
The development of information technology has penetrated into all aspects of people's activities, dealing with a wide variety of complex issues, and has given rise to very complex software systems for various businesses. The core purpose of the architecture is to solve the complexity problem of the software system. The complexity of large-scale business under the Internet distributed system is particularly high, mainly from the following aspects:
Architecture is a huge topic, and there are a lot of articles in each aspect, such as design principles, abstract methods, business decoupling, domain models, module division, etc. However, generally speaking, no matter how complex the software system is, it can be abstracted as "a series of processing logic combinations based on data, for target users to access and use the system", access, logic, data, this is the "infrastructure" discussed in this article, as shown in the figure below. The infrastructure focuses on the requirements of high availability, high performance, and high scalability. This article will start from the perspective of the background to see how these factors affect the design of the infrastructure.
需要考虑异地多活的业务,大概率是要把高可用当作核心目标,高可用重点关注的是软件系统面对故障的应对方案。互联网分布式系统的任何组成部分,都不是百分百绝对可靠的,总是会有发生故障的可能,要保障系统的可用性,就需要针对故障做容灾设计。容灾的本质,在于提供冗余以避免单点故障问题,当系统的某个组成部分发生故障时,可以由冗余部分接管服务使服务整体不受(或少受)影响。
在业务发展的不同阶段,业务体量和规模决定其对于灾难的接受程度是不同的,容灾要应对的单点故障类型也不一样:
解决城市级别的单点故障,也就是本文题目中的“异地多活”了。城市单点问题,和单机器、单机房的单点问题,有着巨大的不同。城市在台风、地震、洪水等极端剧烈灾害时成为单点,而这些灾害往往影响大片区域,该区域内的多个城市会一起受到牵连。所以,要解决城市单点问题,就需要将冗余做到距离较远的另一个区域,例如同属于珠三角城市圈的广州深圳,同属于京津唐城市圈的北京天津,同属于长三角城市圈的上海杭州,聚集在一个城市圈内的城市,往往共享了很多基础设施,这样的距离不能满足容灾的需要。要达到异地多活的容灾目标,基本都需要将服务分别部署在千里之外,例如深圳上海分布,北京上海分布等。
For businesses that need to consider multi-site active-active, high availability is likely to be the core goal. High availability focuses on the response plan of the software system to failures. No component of the Internet distributed system is 100% reliable. There is always the possibility of failure. To ensure the availability of the system, disaster recovery design is required for failures. The essence of disaster recovery is to provide redundancy to avoid single point failure problems. When a component of the system fails, the redundant part can take over the service so that the service as a whole is not (or less) affected.
At different stages of business development, the business volume and scale determine its acceptance of disasters, and the types of single point failures that disaster recovery needs to deal with are also different:
Solving the city-level single point failure is the "multi-site active" in the title of this article. The city single point problem is very different from the single point problem of a single machine or a single computer room. Cities become single points when facing extreme disasters such as typhoons, earthquakes, and floods. These disasters often affect large areas, and multiple cities in the area will be affected together. Therefore, to solve the single point problem in cities, redundancy needs to be done in another area that is farther away. For example, Guangzhou and Shenzhen belong to the Pearl River Delta urban circle, Beijing and Tianjin belong to the Beijing-Tianjin-Tangshan urban circle, and Shanghai and Hangzhou belong to the Yangtze River Delta urban circle. Cities gathered in an urban circle often share a lot of infrastructure, and such distances cannot meet the needs of disaster recovery. To achieve the disaster recovery goal of multi-site active-active, it is basically necessary to deploy services thousands of miles away, such as Shenzhen and Shanghai, Beijing and Shanghai, etc.
3.1 核心在于数据层的写操作
在基础架构中,一般来说,逻辑层负责计算,是无状态的,可以做到无缝切换接管。逻辑层服务的根本是对数据的读取、处理、写入,数据层的故障,涉及到数据的同步、搬迁、恢复,要保证其完整性和一致性才可以切换投入使用,所以,基础架构的容灾关键在于数据层。
数据层的操作涉及读和写,因为读操作不涉及到数据状态的变更,可以通过副本的方式方便扩展,而写操作为了保证写入数据在多份冗余之间的完整性和一致性,需要做数据复制,所以,数据层的关键,在于写请求的处理上。
3.2 写时延在跨城时发生质变
跨城的写时延发生质变是因为,在做跨城级别之前的容灾时,基本上所有业务对于时延都是能接受的,数据的复制直接采用同步的方式即可。在做跨城的时候,业务是否能接受更高的时延,就需要慎重斟酌了,而这也将影响具体的应对方案。
更长的距离意味着更长的时延,通过 ping 工具,测得的时延情况大致是:
3.1 The core lies in the write operation of the data layer
**In the infrastructure, generally speaking, the logic layer is responsible for computing, is stateless, and can achieve seamless switching and takeover. The fundamental service of the logic layer is to read, process, and write data. The failure of the data layer involves synchronization, relocation, and recovery of data. Its integrity and consistency must be guaranteed before it can be switched and put into use. Therefore, the key to disaster recovery of the infrastructure lies in the data layer. **
The operation of the data layer involves reading and writing. Because the read operation does not involve changes in the data state, it can be easily expanded through copies. In order to ensure the integrity and consistency of the written data between multiple redundancies, the write operation needs to replicate the data. Therefore, the key to the data layer lies in the processing of write requests.
3.2 The write latency changes qualitatively when crossing cities
The write latency of the cross-city changes qualitatively because, when doing disaster recovery before the cross-city level, basically all businesses are acceptable to the latency, and data replication can be directly synchronized. When doing cross-city, whether the business can accept higher latency needs to be carefully considered, which will also affect the specific response plan.
Longer distance means longer latency. The latency measured by the ping tool is roughly as follows:
当时延达到 30ms 的级别,业务可用性面临另一个层面的考验,业务是否能接受数据写入的跨城耗时,这里不单单是 30ms 的问题:
如果业务能够接受跨城写时延,那么问题就退化到同城容灾,直接采用跨城同步复制即可。如果不能够接受写入延时,就不能走长距离跨城的同步复制,必须找退而求其次的方案,下面聊聊两种考虑方向。
When the latency reaches 30ms, business availability faces another level of test: whether the business can accept the cross-city time consumption of data writing. This is not just a 30ms issue:
If the business can accept cross-city write latency, then the problem degenerates to disaster recovery in the same city, and cross-city synchronous replication can be used directly. If the write latency is not acceptable, long-distance cross-city synchronous replication cannot be used, and a second-best solution must be found. The following discusses two considerations.
3.3 同步复制缩短距离降目标
缩短距离,不做千里之外,而是选择做距离较近的跨城,例如做广州-深圳、上海-杭州、北京-天津的跨城,距离在100-200公里,时延在5-7ms,这样依然可以用同步复制的方式,但是,如前面提到的,这种方式是达不到跨城异地多活的真实目标的。
3.4 异步复制就近分片做有损
不做同步复制,首先要做的就是将数据根据地理位置做分片,异地多活不能接受延时的情况下,不同业务的分片规则可能会有差异,例如某多、某东、某宝的电商业务,和饿某某和某团的外卖业务的分片规则肯定是不同的,但基本上都是基于用户地理位置来做的:让离哪个城市近的用户数据尽量放到对应城市去。如下图所示,针对用户做了就近分片后,数据写入不需要做跨城同步复制,写入主写点后,直接对外返回成功,而不需要等数据同步到异地。
3.3 Synchronous replication shortens distance and reduces targets
Shorten the distance, do not do it thousands of miles away, but choose to do it across cities with shorter distances, such as Guangzhou-Shenzhen, Shanghai-Hangzhou, Beijing-Tianjin, with a distance of 100-200 kilometers and a latency of 5-7ms. In this way, synchronous replication can still be used, but as mentioned earlier, this method cannot achieve the real goal of cross-city multi-site active.
3.4 Asynchronous replication is lossy for nearby sharding
Without synchronous replication, the first thing to do is to shard the data according to the geographical location. When multi-site active cannot accept latency, the sharding rules of different businesses may be different. For example, the e-commerce business of a certain company, a certain company, and a certain treasure, and the sharding rules of the takeaway business of a certain company and a certain group are definitely different, but they are basically based on the user's geographical location: let the user data close to a certain city be placed in the corresponding city as much as possible. As shown in the figure below, after the nearby sharding is done for the user, the data writing does not need to be synchronized across cities. After writing to the main write point, it is directly returned to the outside successfully without waiting for the data to be synchronized to the remote location.
采用异步复制,这样必然会出现灾难发生时数据没有及时复制到异地的情况,如下图所示:
With asynchronous replication, data will inevitably not be replicated to a remote location in time when a disaster occurs, as shown in the following figure:
对于数据一致性要求不高的业务,例如微博、视频等,可以接受数据重复的情况,自由切换即可,结合一些业务层的去重逻辑,例如结合灾难情况,将灾难发生期间的重复数据做一些去重,基本也就够用了。
对于数据一致性要求高的业务,例如金融、支付等,就必须要保证在做灾难切换的时候,为了将影响的数据尽量减少,需要根据业务的特点,圈出来可能影响的数据,并针对这些相关数据的所属用户的相关操作拒绝服务。下文的数据复制架构中会提到。
For businesses with low data consistency requirements, such as Weibo and video, data duplication can be accepted and switched freely. Combined with some deduplication logic at the business layer, such as disaster situations, duplicate data during the disaster period can be deduplicated, which is basically enough.
For businesses with high data consistency requirements, such as finance and payment, it is necessary to ensure that when doing disaster switching, in order to minimize the affected data, it is necessary to circle the data that may be affected according to the characteristics of the business, and refuse services for the related operations of the users of these related data. This will be mentioned in the data replication architecture below.
写请求量大,单个写入点的容量扛不住,这种情况下,就不能让所有数据的写入都归到同一个写入点来处理,需要做分片,将完整的数据拆分成几部分,各个部分分别有独立的写入点。单纯考虑写量大,并不要求做就近分片,但是就近分片还是能收获一些益处,例如减少 30ms 的耗时等,所以,一般也还是会做就近的分片。下图所示的写量大拆分片的情况,数据写入的时候,等把数据同步复制到异地之后,才认为请求处理成功,给上层返回。
The write request volume is large and the capacity of a single write point cannot handle it. In this case, all data writes cannot be processed at the same write point. Sharding is required to split the complete data into several parts, each with an independent write point. Considering the large write volume alone, it is not required to do sharding nearby, but sharding nearby can still gain some benefits, such as reducing the time consumption by 30ms, so sharding nearby is generally still done. In the case of sharding due to large write volume shown in the figure below, when data is written, the request is considered to be successfully processed only after the data is synchronously copied to a different location, and it is returned to the upper layer.
另外,写量大的业务产生的数据如果是膨胀型的(例如,电商业务的订单数据),会随着时间累积,数据量不断增加。这类数据往往多呈现为流水型特征,写入一段时间后即不会再次访问或更新;对访问频率很低甚至为 0 的数据,其占用的在线业务库存储空间,造成了大量硬件资源浪费,堆高企业的 IT 成本。这种情况根据膨胀的情况,做分库分表以及老数据存档即可,不会产生数据分片而需要实例隔离的这种影响。
In addition, if the data generated by a business with a large write volume is of the inflated type (for example, order data of an e-commerce business), the data volume will continue to increase as time goes by. This type of data often presents a stream-type feature, and will not be accessed or updated again after being written for a period of time; for data with a very low or even zero access frequency, the online business database storage space it occupies causes a large amount of hardware resources to be wasted, and the IT costs of the enterprise are increased. In this case, according to the expansion situation, it is sufficient to shard the database and table and archive the old data, without the impact of data sharding and the need for instance isolation.
做隔离,是为了减少故障/异常情况下对整个业务系统的影响,核心思想就是“不要把鸡蛋放在一个篮子里”。这个对于数据层的影响和上文“写量大拆分片”的效果是一样的,即把全部数据分片拆分成多份,每一份出问题的时候不影响其他数据。做隔离,其实与异地多活的跨城容灾关系不大,在做同城容灾的时候,也是一种常用手段。
业务系统,除了自身的数据层之外,往往还涉及其他的依赖,例如相关的基础组件,更底层的一些服务,运营操作平台等。所以,做隔离的时候,往往不局限于数据层的隔离,而是会把各种依赖,甚至上层的逻辑层也统一囊括进来整体考虑。这种串联上下依赖的隔离方案,名字比较多,例如“单元化”、“SET 化”、“条带化”等。下图是示意图:
Isolation is done to reduce the impact of failures/abnormal situations on the entire business system. The core idea is "don't put all your eggs in one basket". The impact on the data layer is the same as the effect of "sharding when writing a lot of data" mentioned above, that is, all data shards are split into multiple copies, and when a problem occurs in each copy, it does not affect other data. Isolation is actually not related to cross-city disaster recovery with multi-active in different locations. It is also a common method when doing disaster recovery in the same city.
In addition to its own data layer, business systems often involve other dependencies, such as related basic components, some lower-level services, and operating platforms. Therefore, when isolating, it is often not limited to the isolation of the data layer, but will include various dependencies, even the upper-level logic layer, as a whole. This isolation solution that connects upper and lower dependencies in series has many names, such as "unitization", "SETization", "striping", etc. The following figure is a schematic diagram:
在讨论数据模型的时候,常常会聊到“读多写少”、“读写频繁”、“读写分离”等情况,可见,读也是决定数据模型的重要因素。不过,和上面写延时、写量级、隔离性等因素会导致数据分片不同,读的影响主要在副本管理、缓存机制和连接管理上。读是一个后置的二级考虑因素,即首先确定是否要做分片之后,再基于分片的基础来考虑。
6.1 读时延可就近
读操作,根据业务场景的需要,可以分为两种情况:
一般来说,业务对于读操作的时延要求相较写操作有更严苛的要求,例如,写一条微博,发布一段视频,下定一件商品,发起一笔转账,用户对于适当等待是有所预期,而看微博、刷视频、浏览商品、查看账户余额等操作,用户如果感到卡顿,基本上就要流失了。大部分的读场景,都可以接受适当延迟,看不到最新的内容,用户基本上“刷新一下”就可以了。理清楚场景需要,读时延的解决方案就很明显了:提供离用户更近的副本供读取。如下图所示,从上海到访的用户,访问上海的备份副本即可,不需要到深圳去读取数据。
When discussing data models, we often talk about "more reading and less writing", "frequent reading and writing", "read-write separation" and other situations. It can be seen that reading is also an important factor in determining the data model. However, unlike the above factors such as write latency, write volume, isolation, etc. that lead to data sharding, the impact of reading is mainly on replica management, cache mechanism and connection management. Reading is a post-secondary consideration, that is, after first determining whether to do sharding, then consider it based on the basis of sharding.
6.1 Read latency can be close
Read operations can be divided into two situations according to the needs of business scenarios:
Generally speaking, the latency requirements for read operations are more stringent than those for write operations. For example, when writing a Weibo post, posting a video, ordering a product, or initiating a transfer, users expect to wait for a while. However, if users feel a lag when reading Weibo, watching videos, browsing products, or checking account balances, they will basically lose their users. For most read scenarios, appropriate delays are acceptable. Users can basically just "refresh" the data if they cannot see the latest content. Once the scenario requirements are clarified, the solution to read latency is obvious: provide a copy closer to the user for reading. As shown in the figure below, users visiting from Shanghai can access the backup copy in Shanghai and do not need to go to Shenzhen to read data.
6.2 读量大扩副本
和上文“读时延可就近”类似,这里依然讨论的是能够接受适当延迟读的场景。很多业务都是读多写少,大量的读请求,可以通过扩充副本来满足。不过,需要注意,当副本扩展到一定规模后,由于需要做读副本的数据复制,会增加对写点的负载,可以通过级联同步的方式来解决。另外,还会通过添加缓存的方式来进一步提升读请求的吞吐量,这里不做展开了。总体来说,读量一般都不会像写延时和写量一样产生数据分片而需要实例隔离的这种影响。下图是级联复制的示意。
6.2 Expanding replicas for large read volumes
Similar to the above "Read latency can be close", here we are still discussing scenarios where appropriate delayed reads are acceptable. Many businesses have more reads than writes, and a large number of read requests can be met by expanding replicas. However, it should be noted that when the replicas are expanded to a certain scale, the load on the write point will increase due to the need to replicate the data of the read replicas, which can be solved by cascading synchronization. In addition, the throughput of read requests can be further improved by adding caches, which will not be expanded here. In general, read volumes generally do not cause data fragmentation and require instance isolation like write latency and write volume. The following figure is a schematic diagram of cascading replication.
6.3 连接多加代理
数据层是业务的根本,虽然通过分片、副本、缓存等操作,将落到 DB 的请求量减少到可接受的地步,但是逻辑层作为数据层的调用方,还是不可避免的需要建立和数据层 DB 的连接,如果逻辑层的调用方过多,则会需要和 DB 构建更多的连接数。增加连接数能够增加 DB 的并发度,支持更多的调用方,提升吞吐量。但是,数据库的性能并不是可以无限扩展的,当达到一个阈值以后,由于高并发导致的资源抢占、线程上下文切换,反而会导致数据库的整体性能下降。比较普遍的做法,是为数据层 DB 添加一层代理,避免逻辑层调用方直连 DB,由代理来收拢和 DB 之间的连接。
6.3 Add more proxies to connect
The data layer is the foundation of the business. Although the number of requests to the DB can be reduced to an acceptable level through operations such as sharding, replicas, and caching, the logic layer, as the caller of the data layer, still inevitably needs to establish a connection with the data layer DB. If there are too many callers in the logic layer, more connections will need to be established with the DB. Increasing the number of connections can increase the concurrency of the DB, support more callers, and improve throughput. However, the performance of the database is not infinitely scalable. When a threshold is reached, resource preemption and thread context switching caused by high concurrency will cause the overall performance of the database to decline. A more common practice is to add a layer of proxy to the data layer DB to prevent the logic layer caller from directly connecting to the DB, and let the proxy collect the connection between the DB and the logic layer.
上文的讨论中,对于数据的复制,都是采用了一主一备的简化表述。事实上,要达到容灾的效果,一主一备是不够的,下面来看一下几种典型的数据复制架构。
7.1 三地五中心
要想达到容灾的效果,基本上都是要用到多数派协议的方式来做,比较经典的模式是三地五中心架构:
In the above discussion, the data replication is simplified as one master and one backup. In fact, one master and one backup is not enough to achieve the effect of disaster recovery. Let's take a look at several typical data replication architectures.
7.1 Three locations and five centers
To achieve the effect of disaster recovery, it is basically necessary to use the majority protocol method. The more classic model is the three-location five-center architecture:
7.2 三地三中心
三地三中心,可以形成最小的多数派,也能满足容灾需要,不过考虑到下面几点,一般都没有采纳:
7.2 Three Locations and Three Centers
Three locations and three centers can form the smallest majority and meet the needs of disaster recovery. However, considering the following points, it is generally not adopted:
7.3 同城三中心
在不能接受跨城时延的场景中,会用到同城三中心的复制架构。
7.3 Three centers in the same city
In scenarios where cross-city latency is unacceptable, a replication architecture of three centers in the same city will be used.
在多个城市配备多套互为对等的同城三中心,可以做到有损的跨城容灾,如下图所示:
By equipping multiple sets of three-centers in multiple cities with peers, lossy cross-city disaster recovery can be achieved, as shown in the following figure:
7.4 双主互复制
双主互复制的架构,是每一个实例中都有完整的数据,不过,每一个主里面在一个时刻只处理其中一部分数据的写入,规避写冲突。
7.4 Dual-master mutual replication
In the dual-master mutual replication architecture, each instance has complete data. However, each master only processes the writing of a part of the data at a time to avoid write conflicts.
这种模式,在做跨城容灾的时候,通过记录同步时间位点的方式来决定跨城容灾时候的数据写入逻辑,也是有损的:
维护一个统一的时间位点发生器,每次写操作,都记录时间位点,新增记录记为 Ti(insert);
数据做异步复制的时候,记录复制到的时间位点,记为 Ts(sync);
发生故障时,将故障所在的实例禁写,禁写时间记为 Tb(ban);
有损的情况:
This mode is also lossy when performing cross-city disaster recovery. The data writing logic during cross-city disaster recovery is determined by recording the synchronization time point:
7.5 未同步名单
前面提到的对等同城三中心和双主互复制,都有可能产生重复数据,根源在于不知道哪些数据没有同步到。如果可以明确知道哪些数据没有复制到位,那么就可以针对性的拒绝这些没有复制到位的数据的操作。
业务接受不了 N 次跨城带来的 N 倍 60ms 的影响,但是一般,能接受一次跨城 30ms 的延时,这种模式的工作机制是:
7.5 Unsynchronized list
The aforementioned three-center peer-to-peer same-city and dual-master mutual replication may generate duplicate data. The root cause is that we don’t know which data is not synchronized. If we can clearly know which data is not replicated in place, we can specifically reject the operation of these unreplicated data.
The business cannot accept the impact of N times 60ms brought by N cross-city operations, but generally, it can accept a 30ms delay in one cross-city operation. The working mechanism of this mode is:
考虑从上面分析的几种因素,不同业务的数据形态可能不同,可以分为三类:
下面来看看这三种模式对路由的影响。
8.1 跨城全局数据就近路由
数据不分片,写入点只有一个,多副本的方式提供就近读取。这种情况,路由适合全链路就近的方式,按照机房-城市-全局的优先级就近选取路由。如果考虑逻辑层的隔离,也可以在接入层进行路由分流,不过,意义并不大,因为,对于全局数据来说,就近访问,已经具备了较好的隔离性。
Considering the factors analyzed above, the data forms of different businesses may be different and can be divided into three categories:
Let's take a look at the impact of these three modes on routing.
8.1 Nearby routing of global data across cities
Data is not sharded, there is only one write point, and multiple copies are used to provide nearby reading. In this case, routing is suitable for the full-link nearby method, and the route is selected nearby according to the priority of the computer room-city-global. If the isolation of the logical layer is considered, routing diversion can also be performed at the access layer, but it is not very meaningful, because for global data, nearby access already has good isolation.
8.2 就近分片数据接入分流
就近分片数据,重点在于解决写请求穿行N次写操作的跨城时延问题,所以,需要在业务执行写请求之前,把请求提前路由到数据所在的城市(机房),这样穿行的 N 次写操作就是同城(同机房)操作,免去了跨城的耗时。这就要求在执行具体写请求的逻辑层之上做路由分流,考虑到逻辑层的隔离,一般都会把路由分流放在接入层做。读请求也可以和写请求采用同样的路由策略,这样针对同一个分片的读写请求就都在一处了。每一个分片里面的同城三中心的复制架构,在下图中省略了。
8.2 Access and diversion of data in the nearest shard
The key point of data sharding in the nearest shard is to solve the problem of cross-city latency of write requests going through N write operations. Therefore, it is necessary to route the request to the city (computer room) where the data is located before the business executes the write request. In this way, the N write operations going through are operations in the same city (same computer room), eliminating the time-consuming cross-city operation. This requires routing and diversion on the logical layer that executes specific write requests. Considering the isolation of the logical layer, routing and diversion are generally placed in the access layer. Read requests can also use the same routing strategy as write requests, so that read and write requests for the same shard are all in one place. The replication architecture of the three centers in the same city in each shard is omitted in the figure below.
8.3 跨城分片数据接入分流
跨城分片数据能够接受跨城延时,针对写操作是支持跨城同步的,在已经做了分片的基础上,出于就近和影响隔离的考虑,基本上都会做就近,在拆分片的时候,将用户做聚集,并把各个分片的主写点分布到不同城市和机房。跨城分片数据对于路由的影响和就近分片基本上差不多。差别在于跨城分片需要引入第三个城市做数据的完整容灾,如下图的天津,第三城市一般只是为了形成数据容灾的多数派,不会做流量接入,也不会考虑做分片就近部署。
8.3 Cross-city shard data access and diversion
Cross-city shard data can accept cross-city delays, and supports cross-city synchronization for write operations. On the basis of sharding, for the consideration of proximity and impact isolation, it is basically done in proximity. When splitting shards, users are gathered and the main write points of each shard are distributed to different cities and computer rooms. The impact of cross-city shard data on routing is basically the same as that of proximity sharding. The difference is that cross-city sharding requires the introduction of a third city for complete data disaster recovery. For example, in Tianjin in the figure below, the third city is generally only for the purpose of forming the majority of data disaster recovery, and will not provide traffic access, nor will it consider sharding for proximity deployment.
在具体进行架构设计的时候,可以参考如下步骤考量评估。下图中只是聊到了本文描述到的一些比较普遍的关键信息,刨除了很多也许在某些业务场景看来是决定性的因素,例如成本,在做多个跨城三地五中心分片的情况下,比只做就近同城三中心,吞吐量可能下降,而机器资源却上升,也有可能会成为决定采用哪种模型的决定性因素。总之,架构设计是一个非常复杂的过程,要考虑的因素繁杂多样,还是要根据业务具体情况具体分析。
When designing the architecture, you can refer to the following steps for consideration and evaluation. The figure below only talks about some of the more common key information described in this article, excluding many factors that may be decisive in some business scenarios, such as cost. In the case of multiple cross-city three-site five-center shards, the throughput may decrease, while the machine resources increase compared to only three centers in the same city, which may also become a decisive factor in deciding which model to adopt. In short, architecture design is a very complex process, and there are many and varied factors to consider, so it is necessary to analyze it according to the specific business situation.
All comments