Shopify如何动态路由店面流量

In 2019 we set out to rewrite the Shopify storefront implementation. Our goal was to make it faster. We talked about the strategies we used to achieve that goal in a previous post about optimizing server-side rendering and implementing efficient caching. To build on that post, I’ll go into detail on how the Storefront Renderer team tweaked our load balancers to shift traffic between the legacy storefront and the new storefront.

在2019年,我们开始重写Shopify店面的实施。我们的目标是让它更快。我们在之前关于优化服务器端渲染和实施高效缓存的文章中谈到了我们用来实现这一目标的策略。在这篇文章的基础上,我将详细介绍店面渲染器团队如何调整我们的负载均衡器,在传统店面和新店面之间转移流量。

First, let's take a look at the technologies we used. For our load balancer, we’re running nginx with OpenResty. We previously discussed how scriptable load balancers are our secret weapon for surviving spikes of high traffic. We built our storefront verification system with Lua modules and used that system to ensure our new storefront achieved parity with our legacy storefront. The system to permanently shift traffic to the new storefront, once parity was achieved, was also built with Lua. Our chatbot, spy, is our front end for interacting with the load balancers via our control plane.

首先,让我们看一下我们使用的技术。对于我们的负载平衡器,我们正在运行带有OpenResty的nginx。我们以前讨论过,可编写脚本的负载平衡器是我们在高流量高峰期生存的秘密武器。我们用Lua模块建立了我们的店面验证系统,并使用该系统来确保我们的新店面与我们的传统店面达到同等水平。一旦实现平价,将流量永久转移到新店面的系统也是用Lua建立的。我们的聊天机器人,spy,是我们通过控制平面与负载均衡器互动的前端。

At the beginning of the project, we predicted the need to constantly update which requests were supported by the new storefront as we continued to migrate features. We decided to build a rule system that allows us to add new routing rules easily.

在项目开始时,我们预测需要不断地更新哪些请求被新店面支持,因为我们继续迁移功能。我们决定建立一个规则系统,使我们能够轻松地添加新的路由规则。

Starting out, we kept the rules in a Lua file in our nginx repository, and kept the enabled/disabled status in our control plane. This allowed us to quickly disable a rule without having to wait for a deploy if something went wrong. It proved successful, and at this point in the project, enabling and disabling rules was a breeze. However, our workflow for changin...

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

首页 - Wiki
Copyright © 2011-2024 iteam. Current version is 2.137.1. UTC+08:00, 2024-11-22 14:12
浙ICP备14020137号-1 $访客地图$