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.
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.
扳手有两种不同的阅读类型，陈旧和强大。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.
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和美国西部在爱荷华州拥有他们最近的可读性副本，从而导致上面看到的过度延迟。
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.
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.