使用Vitess对Shop应用的Rails后端进行水平扩展

We experienced hockey stick growth after we launched the Shop app. We were glued to our dashboards and saw millions of users onboard onto the app. This was gratifying, but we were becoming more nervous as our backend was pushed closer to its limit.

在我们推出Shop应用后,我们经历了指数增长。我们一直盯着仪表盘,看着数百万用户加入应用。这是令人满意的,但随着我们的后端接近极限,我们变得更加紧张。

We wrote the backend in Ruby on Rails, and used a MySQL database (Shopify managed system called KateSQL). The first order of business was to identify the bottlenecks. We iterated, horizontally scaling our background job system, caching system, and used a horizontally scaled Message bus where appropriate. We then invested into detecting the usual suspects: slow queries, limited connections etc. We also dropped the “The” from “The Shop app” because it was cleaner.

我们使用Ruby on Rails编写了后端,并使用了一个MySQL数据库(Shopify管理的名为KateSQL的系统)。首要任务是识别瓶颈。我们进行了迭代,对后台作业系统、缓存系统进行了水平扩展,并在适当的情况下使用了水平扩展的消息总线。然后,我们投入了精力来检测通常的问题:慢查询、连接限制等。我们还从“The Shop app”中删除了“The”,因为这样更简洁。

As MySQL is the primary datastore, this would become the main bottleneck as well. To deal with this, we started off by splitting the primary database into separate parts – Rails makes it easy to interact with multiple databases. We identified groups of large tables that could exist on separate databases, and used GhostFerry to move a few tables onto a new database. We also created new databases for tables in separate domains – this had the added benefit of limiting the blast radius of issues with one domain impacting others.

由于MySQL是主要数据存储,它也会成为主要的瓶颈。为了解决这个问题,我们首先将主数据库拆分为不同的部分 - Rails可以轻松地与多个数据库进行交互。我们确定了可以存在于不同数据库中的大型表的组,并使用GhostFerry将一些表移动到新的数据库中。我们还为不同域中的表创建了新的数据库 - 这还有一个额外的好处,即限制了一个域的问题对其他域的影响范围。

As the app further grew, we were starting to hit the limit of a single MySQL. We started planning for the next phase of our growth. We were holding off on sharding the primary database as we were weary of the complexity it would add. As time went on, the disk size grew to many Terabytes, schema migrations would take weeks, and we were throttling more back...

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

首页 - Wiki
Copyright © 2011-2024 iteam. Current version is 2.124.0. UTC+08:00, 2024-05-02 20:03
浙ICP备14020137号-1 $访客地图$