应用程序引擎标准环境中的并发请求

2024-04-29 19:15:37 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在appengine标准环境python27运行时上使用django1.10.5。你知道吗

我的app.yaml看起来像:

runtime: python27
api_version: 1
threadsafe: true

instance_class: F4_1G
automatic_scaling:
  min_idle_instances: 1
  max_idle_instances: automatic # default value
  max_concurrent_requests: 8 # default value
  max_pending_latency: 30ms # default value

- url: /.*
  script: myapp.wsgi.application
  secure: always

所以我使用wsgi,它支持线程,而threadsafe是正确的。你知道吗

我在simple hello world页面上使用https://github.com/rakyll/hey进行简单的压力测试,得到以下结果:

2个并发请求

hey -more -c 2 -n 100 -m GET https://<test-app-url>.appspot.com

Response time histogram:
  0.074 [1] |∎
  0.214 [62]|∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎
  0.354 [20]|∎∎∎∎∎∎∎∎∎∎∎∎∎
  0.495 [6] |∎∎∎∎
  0.635 [6] |∎∎∎∎
  0.775 [4] |∎∎∎
  0.916 [0] |
  1.056 [0] |
  1.197 [0] |
  1.337 [0] |
  1.477 [1] |∎

8个并发请求

hey -more -c 8 -n 100 -m GET https://<test-app.appspot>.appspot.com

Response time histogram:
  0.083 [1] |∎
  0.590 [74]|∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎
  1.098 [11]|∎∎∎∎∎∎
  1.605 [6] |∎∎∎
  2.112 [0] |
  2.619 [2] |∎
  3.127 [1] |∎
  3.634 [0] |
  4.141 [0] |
  4.649 [0] |
  5.156 [1] |∎

如何控制/监视/调试线程行为? 我知道的唯一设置是max_concurrent_requests: 8(仅在使用自动缩放时可用),这是否意味着每个实例最多8个线程? 如何在基本/手动缩放中控制每个实例的线程数?如何解释延迟随着并发请求的增加而增加?你知道吗


Tags: instanceshttpscomappdefaultvalue线程concurrent