Google应用引擎不断重新启动Spring Boot应用,似乎没有明显原因。

huangapple 未分类评论46阅读模式
英文:

Google App Engine keeps restarting Spring Boot application all the time for no apparent reason

问题

我在Google的App Engine标准环境上运行着一个非常简单的Java 11 Spring Boot应用程序。问题是运行该应用程序的实例经常非常频繁地重新启动。有时甚至一天会有70次之多。

当我在App Engine的实例概览中观察实例时,确实是这样的。实例计数突然跳到零,然后在几分钟后启动一个新的实例。内存使用量似乎始终保持在256MB的限制范围内。

6小时内的实例计数:
https://i.stack.imgur.com/ngkRf.png

6小时内的内存使用情况:
https://i.stack.imgur.com/RyxIU.png

查看Google的日志查看器中的所有日志,我只看到以下没有附加信息的消息:

> 2020-04-08 10:21:52.626 EDT [start] 2020/04/08 14:21:52.626133
> 收到终止信号,退出

随后是Spring框架的明显打印,关于关闭servlet。

过了一会儿,当下一个HTTP请求到达时,请求被记录下来,但附带以下警告:

> 2020-04-08 10:25:24.974 EDT 该请求导致为您的应用程序启动了一个新进程,从而首次加载了您的应用程序代码。因此,此请求可能比您的应用程序的典型请求花费更长的时间并使用更多的CPU。

紧接着是:

> 2020-04-08 10:25:08.018 EDT [start] 2020/04/08 14:25:08.002384
> 正在启动应用程序
> 2020-04-08 10:25:08.021 EDT
> [start] 2020/04/08 14:25:08.016623 正在执行:/bin/sh -c exec serve streamtracker-0.0.1-SNAPSHOT.jar

然后,Spring Boot应用程序执行其正常的启动过程,常见的Spring日志出现。

在所有这些过程中,在日志查看器中没有任何关于App Engine实例出现问题或错误的提及。因此,我无法理解为什么实例会不断重新启动。这不可能是因为空闲,从日志中我可以看到,在强制关闭之前的两分钟内,最后一个HTTP请求已成功处理。

有没有办法可以找出Google为什么会不断重新启动我的应用程序?

英文:

I have a very simple Java 11 Spring Boot application running on Google's App Engine Standard environment. The problem is that the instance running the app keeps restarting very very often. Sometimes as often as 70 times per day.

When I observe the instance in App Engine's instance overview I see exactly that. The instance count jumps to zero just to start up a new instance a few minutes later. The memory usage always seems to stay well within the 256MB limit.

Instance count over 6h:
https://i.stack.imgur.com/ngkRf.png

Memory usage over 6h:
https://i.stack.imgur.com/RyxIU.png

Looking at all the logs available in Google's Log Viewer, all I see is the following message with no additional information:

> 2020-04-08 10:21:52.626 EDT [start] 2020/04/08 14:21:52.626133
> Quitting on terminated signal

Followed by the obvious prints from the Spring framework about shutting down the servelet.

After a bit when the next HTTP request arrives, the request is logged but gets the following warning attached:

> 2020-04-08 10:25:24.974 EDT This request caused a new process to be
> started for your application, and thus caused your application code to
> be loaded for the first time. This request may thus take longer and
> use more CPU than a typical request for your application.

Immediately followed by:

> 2020-04-08 10:25:08.018 EDT [start] 2020/04/08 14:25:08.002384
> Starting app
> 2020-04-08 10:25:08.021 EDT
> [start] 2020/04/08 14:25:08.016623 Executing: /bin/sh -c exec serve streamtracker-0.0.1-SNAPSHOT.jar

Then the Spring Boot app does its normal startup and the usual Spring logs appear.

During all of that, there is not a single mention of any problem or error from the App Engine instance in the Log Viewer. So I cannot understand why the instance is being restarted all the time. It cannot be due to being idle, I see from the logs that the last HTTP request got successfully served just two minutes before the forced shutdown.

Is there any way how I can find out why Google keeps restarting my application?

huangapple
  • 本文由 发表于 2020年4月9日 20:50:22
  • 转载请务必保留本文链接:https://java.coder-hub.com/61121586.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定