如何解决 Google App Engine 的延迟?

huangapple go评论89阅读模式
英文:

How to resolve google app engine latency?

问题

以下是您提供的内容的翻译:

我们的项目运行在Google App Engine标准环境中,自动扩展配置如下所述。应用中启用了预热请求,并且我们正在使用Google终端点服务。然而,在不同的场景中,我遇到了延迟问题。
环境:Java 8,实例类型:F4_1G
自动扩展配置:
最小实例数:2
最大并发请求数:80
最小挂起延迟:6秒
最大挂起延迟:10秒

我使用JMeter进行了测试,配置了85个异步请求,斜坡上升时间为10秒
从应用程序日志中我可以注意到,AppEngine花费了很长时间来处理请求。以下是我提出的问题:

  1. 大多数请求因超时而失败。在图像1中,我们可以看到请求花费了88.2秒的时间。我知道AppEngine自动扩展有60秒的请求超时限制。但是,我们已经配置了最少2个实例的自动扩展,并且没有最大实例的限制。AppEngine实例应该处理该请求,否则AppEngine应该扩展以处理该请求。为什么没有发生?
    图像1

  2. 在扩展过程中,请求花费了43.6秒的时间。在图像2中,我们能够看到请求在印度标准时间(IST)的20:27:01:663到达,并且API执行的第一行从IST的20:27:40:407开始。在这段时间内发生了什么?我能得到这段时间的日志吗?
    图像2

  3. 扩展后,后续请求的处理时间也非常长。例如,API请求通常在2秒内完成。在图像3中,我们可以注意到API在没有加载请求过程的情况下需要42.4秒,然后请求在IST的20:27:01:728到达。API执行的第一行从IST的20:27:40:708开始。在这段时间内发生了什么?
    图像3

英文:

Our project is running on the Google App Engine standard environment with auto-scaling configured as mentioned below. Warm up requests are enabled in the app and we are using Google Endpoints service. However, I am facing a latency issue in the different scenarios.
Environment: Java 8, Instance type: F4_1G
Configuration for autoscaling:
min-instances: 2
max-concurrent-requests: 80
min-pending-latency: 6s
max-pending-latency: 10s

I tested with JMeter with configuration of sending 85 asynchronous requests with a ramp up period of 10 seconds.
From the application logs I can notice that appengine takes a long time to serve the request.Below are the questions I have

1.Most of the requests are failing because of time exceed. In image 1, we can spot that the request takes 88.2 seconds. I know that AppEngine auto scaling has a 60 seconds request timeout limit. But we have configured autoscaling with a minimum 2 instances and there is no restriction for max-instance. The AppEngine Instance should handle the request otherwise AppEngine should scale up to handle the request. Why is it not happening?
Image_1

  1. While scaling up, the request takes 43.6 seconds. In image 2, we are able to see that the request came at 20:27:01:663 IST and the first line of API execution starts at 20:27:40:407 IST. What is happening in between time? Can I get a log for this period?
    Image_2
  2. After the scaleup, subsequent requests also take a very long time to serve. For instance an API request usually gets completed within 2 seconds. In image 3, we can note that API takes 42.4s without loading-request process and then request comes at 20:27:01:728 IST. The first line of API execution starts at 20:27:40:708 IST. What is happening in between time?
    Image_3

答案1

得分: 1

我认为这与Java 8运行时有关,部署新实例需要很长时间,因为Java是一个重量级运行时。

部署时间超过60秒,您的无人值守请求将因超时而结束。

我认为您可以改进升级策略,例如尝试使用更多的实例启动您的服务,并添加此选项“target_throughput_utilization”,以便在达到80个并发请求之前开始启动新实例。

文档说明如下:
'当并发请求的数量达到max-concurrent-requests乘以target-throughput-utilization的值时,调度程序将启动一个新实例。'

min-instances: 4 
max-concurrent-requests: 80
target_throughput_utilization: 0.75
min-pending-latency: 6s 
max-pending-latency: 10s

在我的示例中,新实例将在实际实例有(80 X 0.75)60个并发请求时启动。

英文:

I think that is related with Java 8 runtime that takes long time to deploy a new instance, because java is a heavy runtime.

The deploy time exceed 60s and your unattended requests will be ended by timeout.

I think that you can improve your you escalation strategy, for example try to start your service with more instances and add this option "target_throughput_utilization" in order to start to raise a new instance before hit your 80 concurrent requests

the documentation state that:
'When the number of concurrent requests reaches a value equal to max-concurrent-requests times target-throughput-utilization, the scheduler starts a new instance.'

min-instances: 4 
max-concurrent-requests: 80
target_throughput_utilization:0.75
min-pending-latency: 6s 
max-pending-latency: 10s

In my example the new instance will start when the actual instance has (80 X 0.75) 60 concurrent requests

huangapple
  • 本文由 发表于 2020年4月6日 21:30:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/61060999.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定