通过REST调用CloudML Predict时遇到内部错误
我的应用程序正在GAE中运行。此应用程序对我的CloudML进行REST调用 这是代码通过REST调用CloudML Predict时遇到内部错误,rest,google-app-engine,google-cloud-ml,google-cloud-ml-engine,Rest,Google App Engine,Google Cloud Ml,Google Cloud Ml Engine,我的应用程序正在GAE中运行。此应用程序对我的CloudML进行REST调用 这是代码 GoogleCredential credential = GoogleCredential.getApplicationDefault() .createScoped(Collections.singleton(CLOUDML_SCOPE)); HttpTransport httpTransport = GoogleNetHttpTranspo
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的日志?如何进一步调试?我们与@sag合作,确定500错误是由于长时间“冷启动”导致的超时。如果您有一段时间没有向您的模型发送流量,或者如果您发送的流量足够多,我们需要启动更多实例,那么您将遇到“冷启动”,其中一个或多个实例启动。目前,这可能是一个漫长的过程,有时我们会超时,并可能导致500个错误 可以安全地重试这些错误;我们建议使用指数退避