我的Appengine标准(java11)上的首次请求响应时间长(+ 40秒) [英] Long response time for first request (+40 seconds) on my appengine standard (java11)

查看:75
本文介绍了我的Appengine标准(java11)上的首次请求响应时间长(+ 40秒)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚将我的应用程序部署在应用程序引擎(www.mibar.es)中,当长时间不使用它时,唤醒并处理第一个请求需要40秒钟以上的时间.在那之后,需要花费一秒钟的时间来处理下一个请求.我该如何减少时间?为什么不总是准备好?我该如何使其始终处于准备状态?

我没有在GCP控制台上显示任何错误,也没有搜索关于我发现的与解决方案

使用当前的设置,预计会在一段时间后发生.如果您的应用程序未收到任何请求,它将缩减为0个实例,因此,一旦请求到达,它就必须再次创建一个实例来满足流量需求,并且此延迟"会添加到请求中.

当您的应用程序负载增加时,热身请求将有助于加快创建实例的过程.但是正如文档所述,有时会发出加载请求,而不是发出预热请求,特别是在应用程序有0个实例在服务且必须创建另一个实例的情况下:

在某些情况下,而是发送加载请求:例如,如果实例是第一个正在启动的实例,或者流量急剧增加

要解决此问题,您至少可以运行1个实例,甚至可以使用min_idle_instances.

I've just deployed my app in the app engine (www.mibar.es) and when it is not in use for a long while, it takes more than 40 seconds for it to wake up and serve the first request. After that one, it takes a second to serve the next requests. How can I reduce that time? Why is not always ready? How can I make it to be always ready?

I doesn't show any error on the GCP console and searching for this same problem I've found out about https://cloud.google.com/appengine/docs/standard/java11/configuring-warmup-requests#enabling_warmup_requests

So this should be included in the yaml file for:

inbound_services:
- warmup

And I wonder if there is anything else that I should do or if anyone has had the same problem:

runtime: java11
env: standard
instance_class: F4
handlers:
  - url: /(.*)
    script: auto
    secure: always
  - url: .*
    script: auto
automatic_scaling:
  min_idle_instances: automatic
  max_idle_instances: automatic
  min_pending_latency: automatic
  max_pending_latency: automatic
  max_instances: 1
network: {}

New UPDATED config Yaml with min-instances 1 that still takes +30 to send first request:


runtime: java11
env: standard
instance_class: F4
handlers:
  - url: /(.*)
    script: auto
    secure: always
  - url: .*
    script: auto
automatic_scaling:
  min_idle_instances: automatic
  max_idle_instances: automatic
  min_pending_latency: automatic
  max_pending_latency: automatic
  min_instances: 1
  max_instances: 1
network: {}

Thanks for your help and let me know if you need any other config file.

解决方案

With the current settings that you have, this is expected to happen after a certain period of time. If your app does not receive any request, it will scale down to 0 instances, therefore once a request arrives, it has to create an instance again to be able to serve the traffic and this "latency" is added to the request.

Warmup requests will help speeding up the process of creating the instance when there is an increase of load to your application. But as the documentation states, sometimes instead of a warmup request, a loading request is issued, specially when the application has 0 instances serving and has to create another one:

In some situations loading requests are sent instead: for example, if the instance is the first one being started up, or if there is a steep ramp-up in traffic

To overcome that, you can have a minimum of 1 instance running or even make use of min_idle_instances.

这篇关于我的Appengine标准(java11)上的首次请求响应时间长(+ 40秒)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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