一行代码花费了$8,000

TLDR

TLDR

Due to a bug, our screen recorder app - screen.studio app kept downloading the auto-update file repeatedly, every 5 minutes for every single user. The update file is approximately 250MB. This resulted in 9 million file downloads and more than 2 petabytes (2,000,000 gigabytes) of traffic on Google Cloud.

由于一个错误,我们的屏幕录制应用程序 - screen.studio 应用程序不断重复下载自动更新文件,每个用户每5分钟一次。更新文件大约为250MB。这导致了900万次文件下载和超过2PB(2,000,000GB)的Google Cloud流量。

Image without caption

This screenshot might not look so scary at first, but take a look at the scale of it. For over a month, we generated at least 100Mib/s (a second!) and, at times, almost 1GiB/s of traffic (every single second!)

这张截图乍一看可能并不那么可怕,但看看它的规模。在一个多月的时间里,我们每秒生成至少100Mib/s的流量(每秒!),有时几乎达到1GiB/s的流量(每一秒!)

That bug was painfully simple and stupid.

那个错误简单得令人痛苦且愚蠢。

Screen Studio is a screen recorder for macOS. It is desktop app. It means we need some auto-updater to allow users to install the latest app version easily.

Screen Studio 是一款适用于 macOS 的屏幕录制软件。它是桌面应用程序。这意味着我们需要一些自动更新程序,以便用户能够轻松安装最新的应用版本。

The app checks for the update every 5 minutes or when the user activates the app.

应用程序每 5 分钟检查一次更新,或者在用户激活应用程序时检查。

Normally, when the app detected the update - it downloaded it and stopped the 5 minutes interval until the user installed it and restarted it.

通常,当应用程序检测到更新时,它会下载更新并停止5分钟的间隔,直到用户安装并重新启动它。

Tragic refactor

悲惨的重构

The problem with the auto-updater we had was that it would prompt the user to update the app as soon as it became available. This resulted in a popup appearing while users were recording the screen, which obviously provided a bad experience as it interrupted the recording the user was making.

我们遇到的自动更新程序的问题是,它会在应用程序可用时立即提示用户更新。这导致在用户录制屏幕时弹出窗口出现,显然提供了糟糕的体验,因为它打断了用户的录制。

While refactoring it, I forgot to add the code to stop the 5-minute interval after the new version file was available and downloaded.

在重构时,我忘记添加代码以在新版本文件可用并下载后停止5分钟的间隔。

It meant the app was downloading the same 250MB file, over and over again, every 5 minutes.

这意味着该应用程序每5分钟下载同一个250MB的文件,一遍又一遍。

Tragic context - app running in the ba...

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

trang chủ - Wiki
Copyright © 2011-2025 iteam. Current version is 2.143.0. UTC+08:00, 2025-05-03 13:43
浙ICP备14020137号-1 $bản đồ khách truy cập$