gpt4 book ai didi

java - App Engine 和 Firestore 的内存问题

转载 作者:行者123 更新时间:2023-12-02 08:45:00 31 4
gpt4 key购买 nike

我正在使用 Kotlin 和 Micronaut 开发一个 MS,它可以访问 Firestore 数据库。当我在本地运行此 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 中的属性修复,但现在每次我调用返回该 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 问题是我尝试为一个简单的应用程序使用一个非常小的实例,但即使这样我也需要更多的内存。

好的,一位 friend 帮我解决了这个问题。我使用的是一个非常小的实例,即使我没有收到内存限制的错误,这也是一个内存问题。

将我的实例更新到 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

我的管理员 friend 告诉我,这个实例更多地用于 python 脚本代码和类似的东西,而不是 JVM REST 服务器。

关于java - App Engine 和 Firestore 的内存问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61138315/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com