Background

今天,Wayfire使用SQL Server来存储我们的客户数据。我们有一个分叉的架构,由许多碎片组成,这些碎片在整个美国和欧洲的多个数据中心传播。在过去的几年里,我们一直推动了这一基础设施的极限,造成了以下问题:

  1. 由于我们分叉策略中达到最大节点数量,难度缩放
  2. 尝试增加可用性时添加了复杂性
  3. 由于许可成本,不断增加的价格

We have been evaluatingGoogle Cloud Spanner作为我们当前架构的潜在替代品。

扳手是一种分布式关系数据库管理系统(RDMS),它允许易于水平缩放,高可用性,外部一致性,并降低成本。作为我们努力评估其可行性的一部分,我们完成了可用的性能测试实例配置。每个配置提供了一个不同的geographic layout of its replicas, and we worked to quantify the increase in query times due to geographic distance between a sampling of available GCP locations and Spanner’s replicas.

Methodology

所有Spanner的多区域实例配置都由多个GCP区域跨各种地理位置的复制品分布组成。执行某些操作时,需要扳手以与客户端跨越世界的区域中的副本通信。我们希望确定执行此类业务的确切延迟损失。

We performed four core performance tests:Insert,更新,强大Read,和陈旧读书。All tests were conducted using a stand-alone Java application run on a CentOS VM in five sample GCP regions:us-east4(弗吉尼亚州),us-central1(Iowa),美国西部(Oregon),欧洲 - 西4.(Netherlands), and欧洲 - 西3.(Frankfurt). The application used the Spanner Database Client supplied by theSpring Data Cloud Spannerclient library to connect to the Spanner instances.

测试在九个不同的扳手上运行实例配置each with a single node. During each test suite run, all tests were performed simultaneously on a single client using a single instance configuration within a 30 minute time span. We excluded a 15 minute connection warming period from our measurements, resulting in us sampling the final 15 minutes of each 30 minute run. The Spanner instances had no additional load outside of the tests being run. The reported results are all using the mean of their respective datasets.

架构

下面的模式用于数据库,今天在SQL Server中的客户数据表模式的非常简化版本:

Operations

扳手有两种不同的阅读类型,陈旧强大。The former is a read of data from a timestamp in the past and the latter is a read of the most up-to-date data.强大reads require the serving replica to communicate with the leader replica to ensure it’s up to date. This requires a round-trip to a potentially geographically distant region.陈旧reads need only hit the closest readable replica without communication with the leader, thus reducing latency. The amount of staleness is configurable, but Google suggests using a staleness of15 secondsfor optimal benefit. This is the value we used in all陈旧读取测试。

写道

To complete a write, the Spanner replica handling the request must interface with the leader replica, which in turn initiates a投票上whether the write can occur. The vote requires communication with additional geographically distant replicas. All of this back-and-forth results in significant latency costs for write requests in most instance configurations.

延迟分析

以下是我们的核心读取和写入操作测试的时序数据,从我们的5个示例客户端区域到所有9个实例配置。如上所述,定时的差异主要是由于客户端到扳手副本的地理延迟。根据实例配置,某些客户端在地理上远离必要的副本以进行操作,而其他客户则共享相同的GCP区域。

nam-eur-asia1

Thenam-eur-asia1configuration’s leader region is in us-central1 (Iowa). Inserts, updates, and most强大reads are required to interface with the Spanner leader replica, so for these operations we see very high latency from the European clients in欧洲 - 西3.欧洲 - 西4.,来自东部和西海岸复制品的中等延迟,us-east4美国西部,低延迟US-Central1,the same GCP region as the lead Spanner replica.

同样地,陈旧读取必须与最近的可读副本交谈,并在nam-eur-asia1配置,一个人非常接近欧洲客户和us-central1。Thisresults in minimal latency for all three in our陈旧读取测试。另一方面,us-east4美国西部在爱荷华州拥有他们最近的可读性副本,从而导致上面看到的过度延迟。

NAM3,NAM6和EUR3

nam3

NAM6.

EUR3.

One can see similar geographic latency patterns forEUR3.,nam3,和NAM6.实例配置。在北美配置中,跨大陆延迟最容易注意到。例如,领导者复制品nam3配置是us-east4,而且美国西部客户在写作或强大的阅读以来,客户显示最大的延迟,因为前往领导者来自西海岸到东海岸。

The European configuration shows much less latency impact as the leader is located in欧洲 - 西部(比利时)which is nearby both European clients in欧洲 - 西3.(Frankfurt) and欧洲 - 西4.(Netherlands); however, neither client is co-located with the Spanner leader replica so the minimum latency for writes and strong reads is still higher than other configurations.

区域配置

对于我们的区域配置测试,我们实际使用五种不同的实例配置。每个配置都具有其所有复制品,其都位于与正在测试的客户端相同的GCP区域中。查看这些配置允许我们基本上从等式中删除地理延迟。

The most significant difference to note in these results is that write operations are much faster than that of multi-region instance configurations whose leaders are co-located with a client. Initially one might expect the latency to be the same since the leader and client are in the same GCP region for both configurations, but considering the inner workings of Spanner, this difference makes sense. When a client makes a write request to a Spanner replica it is first passed along to the leader replica. Then the leader will then initiate a vote between the other read/write and witness replicas who, in a multi-region configuration, are likely geographically distant from the leader. A regional configuration doesn’t have to take this round-trip, resulting in less latency for the operation.

结论

From our testing, it’s clear that the geographic latency impact of switching to Google Cloud Spanner would be significant, especially when compared to similar timings from on-prem SQL Server infrastructure. In Spanner’s best case (NAM6.with client inus-central1),读取和写入时间是SQL Server的双倍,并在其最坏的情况下(nam-eur-asia1with client in欧洲 - 西3.),延迟高达15倍。但是,重要的是要注意,由于服务器之间的地理延迟,任何分布式RDM都预计会有一些绩效命中。毕竟,光只能如此迅速行驶。还有可能使用陈旧读取的延迟等待延迟作为默认查询选项,推动允许同时查询执行和增加查询缓存的架构,并使用Google优化到一个客户端GCP区域的扳手实例配置产品。

Of course, latency is only one piece of the puzzle when comparing database management systems. Overall, we expect Spanner to reduce costs and maintenance time due to its fully managed nature, ease of scaling, and high availability. We also expect benefits from strong global and intracontinental consistency for our different use cases — something that would be very difficult to achieve with SQL Server. By carefully selecting instance configurations based on use case and taking into consideration the potential for improvements through latency mitigation techniques, it is our opinion that the many benefits of this relational database management system outweigh the increased latency cost.

摄影者Mackenzie WeberUnsplash