我将 GAE 用于需要大量内存的繁重任务。我收到以下错误:
Exceeded soft memory limit of 512 MB with 561 MB
after servicing 3 requests total.
Consider setting a larger instance class in app.yaml.
Run Code Online (Sandbox Code Playgroud)
由于任务很昂贵,我假设两个应用程序可以在一个实例中工作。但它不适用于三个应用程序:
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.
Run Code Online (Sandbox Code Playgroud)
我目前的设置:
runtime: nodejs8
instance_class: B4
basic_scaling:
max_instances: 10
idle_timeout: 1m
Run Code Online (Sandbox Code Playgroud)
我也尝试过这些设置:
runtime: nodejs8
instance_class: F4
automatic_scaling:
target_cpu_utilization: 0.5
max_instances: 10
Run Code Online (Sandbox Code Playgroud)
执行任务失败是“超出软内存限制”。所以,为了解决这个错误,我认为应该根据“内存利用率”而不是“cpu利用率”来进行横向扩展。
当内存使用率超过限制时,如何进行横向扩展?
动态实例调度程序的决策不基于实例内存使用情况。来自缩放动态实例:
App Engine 调度程序决定是否使用现有实例(空闲实例或接受并发请求的实例)来处理每个新请求,将请求放入待处理请求队列中,或者为该请求启动一个新实例。该决定考虑了可用实例的数量、应用程序处理请求的速度(其延迟)以及启动新实例所需的时间。
您收到的错误消息都显示在错误发生之前正在处理的请求数量非常少,这表明内存匮乏非常严重。
尚不清楚的是,高内存使用率是否来自单个请求,或者是否与多个并发请求相关 - 即请求同时命中一个实例(或者对于内存释放机制来说彼此太接近,如果任何,跟上)。但这可以通过实验来确定。
target_throughput_utilization如果多个并发传入请求导致实例内存使用量超过阈值,您可以尝试通过控制和/或max_concurrent_requests旋钮来处理它:
设置并发请求数量的吞吐量阈值,在此之后将启动更多实例来处理流量。
设置调度程序生成新实例之前实例可以接受的最大并发请求。
如果即使实例没有同时处理多个请求(或者如果您希望能够同时服务更多实例 - 通常是为了降低成本),但仍达到内存限制,则解决该问题的唯一方法是使用具有更多内存的实例类。F4你尝试过的和类B4都有 512M,尝试F4_1G/ B4_1G,两者都有 1G。
| 归档时间: |
|
| 查看次数: |
1157 次 |
| 最近记录: |