如何配置 GCP App Engine 以在一段时间不活动后正确关闭

问题描述 投票:0回答:1

最近,我在具有弹性环境和自动缩放设置的 GCP App Engine 中部署了一个应用程序。据我所知,经过一段时间的不活动(即没有请求)后,与 App Engine 关联的实例将关闭,直到收到新的请求。然而,就我而言,实例始终“可用”,并且在查看 GCP 文档后,我无法弄清楚我做错了什么。健康检查或就绪检查是否有可能阻止实例关闭?

这是我的app.yaml

runtime: python
env: flex
entrypoint: gunicorn -k uvicorn.workers.UvicornWorker -b :$PORT app:app

runtime_config:
    operating_system: "ubuntu22"
    runtime_version: "3.10"

env_variables:
  GCP_ENV: True
  CLASSIFIER_MODEL: "/mnt/ramdisk1/Model/classifier_model"
  LOGGER_CONFIG: "logging.conf"
  SENTENCE_MODEL: "/mnt/ramdisk1/Model/sentence_model"
  SPANISH_DIC: "spanish.txt"

resources:
  cpu: 1
  memory_gb: 6
  disk_size_gb: 20
  volumes:
    - name: ramdisk1
      volume_type: tmpfs
      size_gb: 2

automatic_scaling:
  cpu_utilization:
    target_utilization: 0.95
  max_num_instances: 1

这是应用于部署的配置(显示在 GCP App Engine 仪表板的服务部分中):

runtime: python
api_version: '1'
env: flexible
threadsafe: true
env_variables:
  CLASSIFIER_MODEL: /mnt/ramdisk1/Model/classifier_model
  GCP_ENV: 'True'
  LOGGER_CONFIG: logging.conf
  SENTENCE_MODEL: /mnt/ramdisk1/Model/sentence_model
  SPANISH_DIC: spanish.txt
automatic_scaling:
  cool_down_period: 120s
  min_num_instances: 1
  max_num_instances: 1
  cpu_utilization:
    target_utilization: 0.95
resources:
  cpu: 1
  memory_gb: 6
  disk_size_gb: 20
  volumes:
    - volume_type: tmpfs
      size_gb: 2
      name: ramdisk1
liveness_check:
  initial_delay_sec: '300'
  check_interval_sec: '30'
  timeout_sec: '4'
  failure_threshold: 4
  success_threshold: 2
readiness_check:
  check_interval_sec: '5'
  timeout_sec: '4'
  failure_threshold: 2
  success_threshold: 2
  app_start_timeout_sec: '300'
service_account: service-account
flexible_runtime_settings:
  operating_system: ubuntu22
  runtime_version: '3.10'

有人看到了我看不到的东西?

预先感谢您提供任何线索。

google-cloud-platform google-app-engine app-engine-flexible
1个回答
0
投票

灵活的环境不提供零缩放,请参见示例此比较表

因此,您始终至少有 1 个实例在运行。

© www.soinside.com 2019 - 2024. All rights reserved.