Appengine 中的应用程序大小突然变大(转到 1.14)

Application size in appengine suddenly much bigger (go 1.14)

我们正在使用带有 go114 运行时的 google appengine。我们的应用程序大小通常在 40mb 左右。突然之间,我们的应用程序版本的大小变成了 240mb,而我们这边没有任何变化。

奇怪的是,相同的代码版本导致一个环境仍然为 40mb,而另一个环境为 240mb。后面的版本也增加了第一个环境。

我们的代码没有任何可能影响这些的更改,但我也不知道是什么导致了应用引擎方面的问题。

有人知道是什么导致了应用程序大小的增加吗?

我发现了与您在此 google groups post 中遇到的问题类似的问题,但使用的是 Java SDK。我会说那里提到的原因也适用于你的情况:

There are a number of reasons which may contribute to the different sizes, particularly in the past, the size difference in the builds for the same application code has been seen to relate to different implementations of the functions (i.e. deploy) and the tools in each SDK and the plugins. Hence, to understand better the cause may require reviewing the differences between the plugins used and the App Engine SDK versions, and how the changes may have applied to your application.

话虽这么说,您可以打开一个 support case for Google Cloud 来检查导致该问题的原因,并获得有关如何在您的特定情况下缓解该问题的建议。

我打开了 Google 的票,得到了以下答案:

According to our App Engine product team, the previous version size was computed as the sum of the sizes of user code files, error blobs and static files.

When the infrastructure change was made, due to other dependencies, version size started being computed using the sizes of the user layers of the container (considering values such as raw_bytes, tar_bytes, file_bytes, etc) rather than just the size of the code itself. Since user layers may contain far more than just the code files, the version size appears significantly larger.

我在 App Engine 中的 python 网络应用程序遇到了同样的问题。

添加到 requirements.txt 的每个文件增加的应用程序大小远远超过文件的大小。

解决方案是从 requirements.txt 中取出文件并将其直接添加到模块文件夹中。

示例:google-cloud-recaptcha-enterprise 如果添加到 requirements.txt 则添加 20MB,如果包含在模块文件夹中则仅添加 100KB。

并不总是建议这样做,但可以作为严重情况下的解决方案。

另一件必须检查的事情是 .gcloudignore 文件