为“Airbnb”规模打造明信片

We take the listing of each booking request and fetch the city and country from the listing service and check to see if that destination was in our curated set of formatted destinations loaded into our i18n service. We then take the best fitting artwork and embed the localized destination text on it to generate the final postcard. If we don’t get a translation back, we fall back to serving the postcard without text.

我们获取每个预订请求的列表,并从列表服务中获取城市和国家,并检查该目的地是否在我们的精选格式化目的地集合中加载到我们的i18n服务中。然后,我们选择最合适的艺术品,并将本地化的目的地文本嵌入其中,生成最终的明信片。如果我们没有得到翻译,我们将返回没有文本的明信片。

Performance — Async Postcard Creation Flow

性能 - 异步明信片生成流程

Putting a localized destination and a Belo icon onto artwork is a time-consuming operation given the high resolution artwork we used. We knew the image processing flow could take over 8 seconds on average to process an image so we needed to come up with a way to make our postcard API respond quickly. We also wanted to transfer these generated postcards into our primary image storage so we could leverage our existing media serving infrastructure, which introduced an additional 1–2 seconds of latency.

将本地化目的地和Belo图标放在艺术品上是一个耗时的操作,因为我们使用的是高分辨率艺术品。我们知道图像处理流程平均需要超过8秒的时间来处理一张图片,因此我们需要想出一种方法使我们的明信片API能够快速响应。我们还希望将这些生成的明信片转移到我们的主要图像存储中,以便利用我们现有的媒体服务基础设施,这会引入额外的1-2秒延迟。

In order to still be performant, we went with a partly asynchronous approach where, during the live in product request, we only serve postcards that we’ve already generated and stored internally. If there was a request for a new postcard, we would instead return a fallback postcard and publish an event to a Kafka queue where an async consumer would call the processing service, wait for the asset to be generated and then transfer it into our system to be used for future requests.

为了保持性能,我们采用了部分异步的方法。在实时产品请求期间,我们只提供已经生成并存储在内部的明信片。如果有新的明信片请求,我们将返回一个备用明信片,并将事件发布到Kafka队列中,异步消费者将调用处理服务,等待生成资产,然后将其传输到我们的系统中,以供将来的请求使用。

As shown in the diagram below, we fetched the listing information and taxonomy information in parallel before computing the best matching artwork for ...

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

Home - Wiki
Copyright © 2011-2024 iteam. Current version is 2.139.0. UTC+08:00, 2024-12-22 23:31
浙ICP备14020137号-1 $Map of visitor$