为什么我们使用Google Cloud Spanner为我们的资产库构建了一个写回缓存

When we were designing Alexandria, we wanted fast and reliable but also cost effective storage. From the beginning, we focused on read performance by having both in memory cache and GCS. Since only a very small portion of our libraries are actively used at any given moment by somebody uploading or picking media, for example while editing a website, we decided to keep the libraries in GCS and load them into an in-memory cache when they are needed. While GCS as long term storage is reliable and relatively cheap, the in-memory cache is fast and more expensive. We made that cost as little as possible by only loading libraries into the in-memory cache when they were in use. 

在设计Alexandria时,我们希望快速、可靠且具有成本效益的存储。从一开始,我们通过使用内存缓存和GCS来专注于读取性能。由于我们的库只有很小一部分在任何给定时刻由某人上传或选择媒体时活跃使用,例如在编辑网站时,我们决定将库保留在GCS中,并在需要时将其加载到内存缓存中。虽然GCS作为长期存储是可靠且相对便宜的,但内存缓存是快速且更昂贵的。我们通过仅在使用时将库加载到内存缓存中来尽可能降低成本。

So we were happy with the read performance. Write performance can be better, however. GCS is object storage and it’s not designed for low write latency. In its original state, every write operation in Alexandria needed to update one or more of the GCS objects (header, segments or trashcan) synchronously. For example, when a user deleted an asset, Alexandria deleted the asset record from its segment file and added it to the trash can. Alexandria could only confirm that the delete was successful after everything was persisted in GCS, so the performance of these writes to GCS was reflected in the response time the user saw for this delete operation.

所以我们对读取性能感到满意。然而,写入性能可以更好。GCS是对象存储,不适用于低写入延迟。在初始状态下,Alexandria中的每个写操作都需要同步更新一个或多个GCS对象(头部、段或垃圾桶)。例如,当用户删除一个资源时,Alexandria会从其段文件中删除资源记录并将其添加到垃圾桶中。只有在所有内容都持久保存在GCS中后,Alexandria才能确认删除操作成功,因此这些写入到GCS的性能会反映在用户对此删除操作所看到的响应时间中。

The first issue we ran into was GCS’s one write per second rate limit for a given object. This rate limit presents a problem for rapid updates to a single library, for example, when a user is doing a bulk upload, or when we're running a migration to import data into Alexandria. To work aro...

开通本站会员,查看完整译文。

- 위키
Copyright © 2011-2024 iteam. Current version is 2.137.1. UTC+08:00, 2024-11-08 23:56
浙ICP备14020137号-1 $방문자$