Google App Engine 표준 환경 502 POST 서버 오류

Google App Engine 표준 환경 502 POST 서버 오류

며칠 동안 App Engine을 사용하여 Unity에서 PubSub로 데이터를 스트리밍한 후 엄청난 양의 502 오류가 발생하여 생성된 인스턴스 수가 늘어나고 이로 인해 일일 지출 한도를 초과했습니다.

인스턴스 증가

인스턴스 증가

내가 사용하고 있는 Python 스크립트: https://github.com/GoogleCloudPlatform/python-docs-samples/tree/master/appengine/standard_python37/pubsub

모든 오류는 HTTP POST 요청이며 대기 시간이 30초보다 크고 로그 메시지는 다음과 같습니다.

이 요청으로 인해 애플리케이션에 대한 새 프로세스가 시작되어 애플리케이션 코드가 처음으로 로드되었습니다. 따라서 이 요청은 애플리케이션에 대한 일반적인 요청보다 시간이 더 오래 걸리고 더 많은 CPU를 사용할 수 있습니다.

저는 Flex 환경에서만 사용할 수 있고 Standard에서는 사용할 수 없는 준비 상태 확인 및 활성 상태 확인을 살펴보도록 권장받았습니다. 이 오류의 원인은 무엇이며 이를 방지하는 방법은 무엇입니까?

로그 예:

    {
 httpRequest: {
  status: 502   
 }
 insertId: "5e2bf548000bc56fe5d27eec"  
 labels: {
  clone_id: "00c61b117c17d8ad1566cc1788d5763552dbe5ace0c77a3523e4047bdc431b306a3840a5168f"   
 }
 logName: "projects/x/logs/appengine.googleapis.com%2Frequest_log"  
 operation: {
  first: true   
  id: "5e2bf52700ff069deff4c6f3400001737e626f6f74796661726d6c697665000133000100"   
  last: true   
  producer: "appengine.googleapis.com/request_id"   
 }
 protoPayload: {
  @type: "type.googleapis.com/google.appengine.logging.v1.RequestLog"   
  appEngineRelease: "1.9.71"   
  appId: "s~x"   
  cost: 3.2186e-8   
  endTime: "2020-01-25T07:59:04.771274Z"   
  finished: true   
  first: true   
  host: "x.appspot.com"   
  httpVersion: "HTTP/1.1"   
  instanceId: "00c61b117c17d8ad1566cc1788d5763552dbe5ace0c77a3523e4047bdc431b306a3840a5168f"   
  instanceIndex: -1   
  ip: "x"   
  latency: "33.337627s"   
  line: [
   0: {
    logMessage: "This request caused a new process to be started for your application, and thus caused your application code to be loaded for the first time. This request may thus take longer and use more CPU than a typical request for your application."     
    severity: "INFO"     
    time: "2020-01-25T07:59:04.770902Z"     
   }
  ]
  megaCycles: "4387"   
  method: "POST"   
  pendingTime: "0.005315345s"   
  requestId: "5e2bf52700ff069deff4c6f3400001737e626f6f74796661726d6c697665000133000100"   
  resource: "/"   
  responseSize: "288"   
  startTime: "2020-01-25T07:58:31.433647Z"   
  status: 502   
  traceId: "2ee7b458fad62565bd5ed150e67647fc"   
  traceSampled: true   
  urlMapEntry: "auto"   
  userAgent: "Dalvik/2.1.0 (Linux; U; Android 5.1.1; SM-T360 Build/LMY47X) x SDK"   
  versionId: "3"   
  wasLoadingRequest: true   
 }
 receiveTimestamp: "2020-01-25T07:59:04.772448343Z"  
 resource: {
  labels: {
   module_id: "default"    
   project_id: "x"    
   version_id: "3"    
   zone: "us12"    
  }
  type: "gae_app"   
 }
 severity: "INFO"  
 timestamp: "2020-01-25T07:58:31.433647Z"  
 trace: "projects/x/traces/2ee7b458fad62565bd5ed150e67647fc"  
 traceSampled: true  
}

앱.yaml:

runtime: python37
entrypoint: gunicorn -b :$PORT main:app

    #[START env]

        env_variables:
            PUBSUB_TOPIC: xx
            # This token is used to verify that requests originate from your
            # application. It can be any sufficiently random string.
            PUBSUB_VERIFICATION_TOKEN: xx
        #[END env]

요구사항.txt:

Flask==1.0.2
google-api-python-client==1.7.8
google-auth==1.6.3
google-cloud-pubsub==0.40.0
gunicorn==19.7.1

*참고: 로그에는 오류가 계속 표시되지만 며칠 후에는 증가된 인스턴스 수가 AppEngine 대시보드에 표시되지 않습니다.

관련 정보