由于内存限制,部署在Google Cloud App Engine中的Spring Boot应用无法启动 [英] Spring Boot app deployed in Google Cloud App Engine not starting up because of memory limit

查看:67
本文介绍了由于内存限制,部署在Google Cloud App Engine中的Spring Boot应用无法启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Google Cloud App Engine中部署的Spring Boot应用程序遇到问题.该应用程序是使用JPA和JWT的API,并已连接到存储在Google Cloud SQL中的MySQL数据库.

I'm having a problem with a Spring Boot application deployed in Google Cloud App Engine. The app is an API that uses JPA and JWT and is connected to a MySQL database stored in Google Cloud SQL.

问题在于,由于内存限制,应用程序被卡住了.每次请求后,我都会在日志中收到以下消息:

The problem is that the applicacion gets stuck because of memory limit. After every request, I get this messages in the log:

  • 为总计0个请求提供服务后,超出了256 MB的软件内存限制和298 MB.考虑在app.yaml中设置更大的实例类.
  • 此请求使您的应用程序启动了一个新过程,从而导致您的应用程序代码首次被加载.因此,与您的应用程序的典型请求相比,此请求可能花费更长的时间并使用更多的CPU.
  • 在处理此请求时,发现处理此请求的进程使用了​​过多的内存并被终止.这很可能导致新流程用于您的应用程序的下一个请求.如果您经常看到此消息,则可能是应用程序内存泄漏或正在使用内存不足的实例.考虑在app.yaml中设置更大的实例类.

我尝试修改文件 src/main/appengine/app.yaml ,以设置不同的配置(具有更多的内存),但是每次更改后我都看不出任何区别.就像这个文件被忽略了.

I tried to modify the file src/main/appengine/app.yaml file in order to set a different configuration (with more memory) but I don't see any difference after every change. It's like this file was ignored.

这是我当前的 app.yaml :

runtime: java
env: flex
runtime_config:
  jdk: openjdk8
env_variables:
  SPRING_PROFILES_ACTIVE: "gcp,mysql"
  # JAVA_GC_OPTS: -XX:+UseSerialGC
  # JAVA_USER_OPTS: -XX:MaxRAM=200m

# With -XX:+UseSerialGC This will perform garbage collection inline with the thread allocating the heap memory instead of a dedicated GC thread(s)
# With -Xss512k This will limit each threads stack memory to 512KB instead of the default 1MB
# With -XX:MaxRAM=72m

handlers:
- url: /.*
  script: this field is required, but ignored
beta_settings:
  cloud_sql_instances: guitar-tab-manager-api:europe-west3:guitar-tab-manager-db

# manual_scaling:
#   instances: 1

# instance_class: F4
# manual_scaling:
#   instances: 1

# instance_class: F2
# basic_scaling:
#   max_instances: 5
#   idle_timeout: 10m

instance_class: F2
# automatic_scaling:
#   target_cpu_utilization: 0.65
#   min_instances: 5
#   max_instances: 100
#   min_pending_latency: 30ms  # default value
#   max_pending_latency: automatic
#   max_concurrent_requests: 50

我尝试应用不同的配置,但似乎无济于事.也许有人可以帮忙.预先感谢.

I tried to apply different configurations but nothing seems to work. Maybe someone can help. Thanks in advance.

推荐答案

对于任何来这里的人:

我让它在不同的环境下工作.代替Flex,我按照配置

I got it working using a different environment. Instead of flex, I changed the environment to standard with java8 following the configuration explained here. The weird thing is that now the app consumes more memory than before (about 300Mb), but now it's working without issues. Note that app.yaml is not used anymore, and now the application is deployed as a WAR.

谢谢

这篇关于由于内存限制,部署在Google Cloud App Engine中的Spring Boot应用无法启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆