java开发的软件响应时间要求,我的Appengine标准(java11)上的首次请求响应时间长(+ 40秒)...

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?

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值