우리 팀은 Slim PHP를 라우터로 사용하여이 RESTful API를 개발했으며 MySQL과 ORM을 Propel으로 개발하여이 앱과 함께 Google App Engine의 서비스로 배포했습니다 앱 엔진 로그인으로Google App Engine 오류 코드 204가있는 PHP55 무작위 서버 충돌 (500's)
500 Server Error Error: Server Error The server encountered an error and could not complete your request. Please try again in 30 seconds.
: .yaml 설정
service: api
runtime: php55
api_version: 1
threadsafe: yes
instance_class: F1
automatic_scaling:
min_idle_instances: automatic
max_idle_instances: automatic
min_pending_latency: automatic
max_pending_latency: automatic
skip_files:
- ^vendor/(.*/)+[Tt]ests/.*$
- ^\.(.*)
handlers:
- url: .*
script: app.php
가 Ember.js 웹 응용 프로그램에 의해 소비되는 모든 개발을 통해 우리는 이상한 patternless 서버가 더 정확하게 500S를, 충돌 받았어요 . 그렇지 않으면 시간의 99 잘 %를 작동 랜덤 엔드 포인트에서
, 우리는 물론, 이러한 임의 충돌과 생산에가는 기분이 안.A problem was encountered with the process that handled this request, causing it to exit. This is likely to cause a new process to be used for the next request to your application. (Error code 204)
우리가 시도하는 것 :
- 우리가 열고 연결마다 요청을 닫습니다 때문에 MySQL의 max_connections의 도달되고 있는지 여부를 확인.
- 우리가 메모리가 부족해질 가능성을 해결하기 위해 테스트를 위해 F1에서 우리의 인스턴스를 F4_1G로 업그레이드합니다.
- dev_appserver.py로 로컬 호스트의 스트레스 테스트 (여기서는 아무런 크래시가 발생하지 않습니다.)
- 슬림 앱 전체를 디버깅 용으로 잡으십시오. 실제로 예외를 잡아 내지 못합니다. Google App Engine과 관련있는 항목)
다음은 일반적인 요청 흐름의 일부 코드입니다.
app.php
/*
* Create SLIM application
*/
$app = new \Slim\App([
"settings" => [
"determineRouteBeforeAppMiddleware" => true,
]
]);
//Custom Authentication middleware
$app->add(new \OAuth2Server\SlimAuthenticationMiddleware());
//CORS and Headers Middleware
$app->add(function($request, $response, $next) {
$response = $next($request, $response);
$response = $response->withHeader("Access-Control-Allow-Origin", "*");
$response = $response->withHeader("Access-Control-Allow-Headers", "Content-Type, authorization");
$response = $response->withHeader("Access-Control-Allow-Methods", "POST, GET, PATCH, DELETE, OPTIONS");
$response = $response->withHeader("content-type", "application/json; charset=utf8");
return $response;
});
require_once("router.php");
$app->run();
router.php
$app->get($apiVersionPath.'/visits/{id}','\Controllers\Visits:get')
->add(new \OAuth2Server\ValidateRequestUser(array("doctor", "nurse","superuser","admin")));
방문 컨트롤러 GET/ID 관련 코드.
/**
* @param Request $request
* @param Response $response
* @param []$args
* @return Response
*/
public function get($request, $response, $args) {
$id = $request->getAttribute("route")->getArgument("id");
$serializer = new Serializer();
if(!is_numeric($id) || $id == 0){
throw new InvalidArgumentException("Invalid Argument");
}
$visit = \VisitQuery::create()
->useUserQuery()
->filterByClientId($request->getAttribute("user")->getClientId())
->endUse();
$visit = $visit->findPk($id);
if(!isset($visit) || !($visit instanceof \Visit)){
throw new EntityNotFoundException("Visit not found");
}
$resource = $visit->toResource(false);
$serializer->addResource($resource);
$body = $response->getBody();
$body->write($serializer->serialize());
return $response;
}
[이 문제] (https://issuetracker.google.com/issues/35900014)에 따르면 204는 일반적으로 메모리 문제를 의미합니다. 인스턴스 유형을 부딪히는 것이 도움이되지 않았고 패턴이 관찰되지 않았기 때문에 누군가가 용의자를 알게되거나 가능한 설명이있는 경우 앱 코드를 추가 할 것을 제안 할 수 있습니다. –
감사합니다 @ DanCornilescu, 방금 요청 흐름의 일부 코드를 추가했습니다 –