0

我的應用程序在GAE中運行。這個應用程序對我的CloudML進行REST調用。通過REST調用CloudML預測時遇到內部錯誤

以下是一個

 GoogleCredential credential = GoogleCredential.getApplicationDefault() 
       .createScoped(Collections.singleton(CLOUDML_SCOPE)); 
     HttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport(); 
     HttpRequestInitializer requestInitializer = request -> { 
      credential.initialize(request); 
      request.setReadTimeout(0); 
     }; 

     HttpRequestFactory requestFactory = httpTransport.createRequestFactory(
       requestInitializer); 

     GenericUrl url = new GenericUrl(predictRestUrl); 

     JacksonFactory jacksonFactory = new JacksonFactory(); 
     JsonHttpContent jsonHttpContent = new JsonHttpContent(jacksonFactory, getPayLoad()); 

     ByteArrayOutputStream baos = new ByteArrayOutputStream(); 

     jsonHttpContent.setWrapperKey("instances"); 
     jsonHttpContent.writeTo(baos); 
     LOG.info("Executing request... " + baos.toString()); 
     HttpRequest request = requestFactory.buildPostRequest(url, jsonHttpContent); 

     HttpResponse response = request.execute(); 

我已經設置了ReadTimeOut以0作爲我經常讀超時異常的代碼。

現在有了這個代碼,我經常收到來自CloudML

com.google.api.client.http.HttpResponseException: 500 Internal Server Error 
{ 
    "error": { 
    "code": 500, 
    "message": "Internal error encountered.", 
    "errors": [ 
     { 
     "message": "Internal error encountered.", 
     "domain": "global", 
     "reason": "backendError" 
     } 
    ], 
    "status": "INTERNAL" 
    } 
} 

下面的錯誤響應,其中我們可以得到REST調用CloudML日誌?如何進一步調試?

回答

0

我們與@sag一起工作,確定500錯誤是由於長時間「冷啓動」造成超時的結果。如果您在一段時間內沒有向您的模型發送流量,或者如果您發送的流量足夠多,我們需要旋轉更多的實例,則會出現一個「冷啓動」,其中一個或多個實例將啓動。目前,這可能是一個漫長的過程,有時會超過我們的目標,並可能導致500錯誤。

這些錯誤可以安全地重試;我們建議使用指數回退。

相關問題