App Engine 和 Firestore 的内存问题
Memory issue with App Engine and Firestore
我正在使用 Kotlin
和访问 Firestore 数据库的 Micronaut 开发一个 MS。当我在本地 运行 这个 MS 时,我可以让它在 128M 下工作,因为它非常简单,只需将数据读写到 Firestore,而不是大量数据,非常小的数据,如下所示:
{
"project": "DUMMY",
"columns": [
{
"name": "TODO",
"taskStatus": "TODO"
},
{
"name": "IN_PROGRESS",
"taskStatus": "IN_PROGRESS"
},
{
"name": "DONE",
"taskStatus": "DONE"
}
],
"tasks": {}
}
我在 F1 实例 (256 MB 600 MHz) 的 App Engine Standard 中 运行 在我的 app.yaml
中使用此属性
runtime: java11
instance_class: F1 # 256 MB 600 MHz
entrypoint: java -Xmx200m -jar MY_JAR.jar
service: data-connector
env_variables:
JAVA_TOOL_OPTIONS: "-Xmx230m"
GAE_MEMORY_MB: 128M
automatic_scaling:
max_instances: 1
max_idle_instances: 1
我知道处理内存的所有属性都不是必需的,但我拼命尝试让它工作,并且尝试了很多解决方案,因为我的第一条错误消息是:
Exceeded soft memory limit of 256 MB with 263 MB after servicing 1 requests total. Consider setting a larger instance class in app.yaml.
app.yaml
中的属性未修复以下错误,但现在每次我调用 return JSON
时都会收到此错误
2020-04-10 12:09:15.953 CEST
While handling this request, the process that handled this request was found to be using too much memory and was terminated. This is likely to cause a new process to be used for the next request to your application. If you see this message frequently, you may have a memory leak in your application or may be using an instance with insufficient memory. Consider setting a larger instance class in app.yaml.
它总是在第一个请求中持续更长时间,我认为是由于某些 Firestore 配置,但问题是我无法让它工作,总是得到同样的错误。
你知道我可能做错了什么或者我需要解决这个问题吗?
TL;DR 问题是我试图为一个简单的应用程序使用一个非常小的实例,但即使这样我也需要更多内存。
好的,朋友帮我解决了这个问题。我使用的是一个非常小的实例,即使我没有收到内存限制错误,那也是内存问题。
将我的实例更新为 F2 (512 MB 1.2 GHz) 解决了问题,并使用 siege 测试了我的应用程序,得到了非常好的性能:
Transactions: 5012 hits
Availability: 100.00 %
Elapsed time: 59.47 secs
Data transferred: 0.45 MB
Response time: 0.30 secs
Transaction rate: 84.28 trans/sec
Throughput: 0.01 MB/sec
Concurrency: 24.95
Successful transactions: 3946
Failed transactions: 0
Longest transaction: 1.08
Shortest transaction: 0.09
我的系统操作朋友告诉我,这个实例更多的是 python 脚本代码和类似的东西,而不是 JVM REST 服务器。
我正在使用 Kotlin
和访问 Firestore 数据库的 Micronaut 开发一个 MS。当我在本地 运行 这个 MS 时,我可以让它在 128M 下工作,因为它非常简单,只需将数据读写到 Firestore,而不是大量数据,非常小的数据,如下所示:
{
"project": "DUMMY",
"columns": [
{
"name": "TODO",
"taskStatus": "TODO"
},
{
"name": "IN_PROGRESS",
"taskStatus": "IN_PROGRESS"
},
{
"name": "DONE",
"taskStatus": "DONE"
}
],
"tasks": {}
}
我在 F1 实例 (256 MB 600 MHz) 的 App Engine Standard 中 运行 在我的 app.yaml
中使用此属性runtime: java11
instance_class: F1 # 256 MB 600 MHz
entrypoint: java -Xmx200m -jar MY_JAR.jar
service: data-connector
env_variables:
JAVA_TOOL_OPTIONS: "-Xmx230m"
GAE_MEMORY_MB: 128M
automatic_scaling:
max_instances: 1
max_idle_instances: 1
我知道处理内存的所有属性都不是必需的,但我拼命尝试让它工作,并且尝试了很多解决方案,因为我的第一条错误消息是:
Exceeded soft memory limit of 256 MB with 263 MB after servicing 1 requests total. Consider setting a larger instance class in app.yaml.
app.yaml
中的属性未修复以下错误,但现在每次我调用 return JSON
时都会收到此错误
2020-04-10 12:09:15.953 CEST
While handling this request, the process that handled this request was found to be using too much memory and was terminated. This is likely to cause a new process to be used for the next request to your application. If you see this message frequently, you may have a memory leak in your application or may be using an instance with insufficient memory. Consider setting a larger instance class in app.yaml.
它总是在第一个请求中持续更长时间,我认为是由于某些 Firestore 配置,但问题是我无法让它工作,总是得到同样的错误。
你知道我可能做错了什么或者我需要解决这个问题吗?
TL;DR 问题是我试图为一个简单的应用程序使用一个非常小的实例,但即使这样我也需要更多内存。
好的,朋友帮我解决了这个问题。我使用的是一个非常小的实例,即使我没有收到内存限制错误,那也是内存问题。
将我的实例更新为 F2 (512 MB 1.2 GHz) 解决了问题,并使用 siege 测试了我的应用程序,得到了非常好的性能:
Transactions: 5012 hits
Availability: 100.00 %
Elapsed time: 59.47 secs
Data transferred: 0.45 MB
Response time: 0.30 secs
Transaction rate: 84.28 trans/sec
Throughput: 0.01 MB/sec
Concurrency: 24.95
Successful transactions: 3946
Failed transactions: 0
Longest transaction: 1.08
Shortest transaction: 0.09
我的系统操作朋友告诉我,这个实例更多的是 python 脚本代码和类似的东西,而不是 JVM REST 服务器。