Best Practice
- RPS(requests per second) 기준 스로틀링 제한이 있습니다.
- Hard Limit: Burst 5,000
- Region: 10,000 은 RPS는 계정의 Region 당 10,000개이며 테스트 결과에 따라 증가 가능가능합니다.
- 내부적으로 토큰 버킷 알고리즘에 의거 요청에 대한 처리는 최대 5,000개까지 가능합니다.
- Integration Timeout REST API time out 설정은 50ms ~ 29s 로 설정이 가능
- Time out이 Timeout이 길어지면 RPS 제한을 증가해도 요청 처리에 문제가 발생 가능
- Lambda 를 연결했을 경우 Lambda 의 타임아웃을 짧게 구성했다고 하더라도 API GW 레벨에서도 타임아웃을 적절히 짧게 설정해줘야 합니다.
- API GW 에 연결된 백엔드 문제가 API GW 까지 영향을 미치지 않게 하기 위함 입니다.
- API caching 설정해주는게 성능면에서 유리합니다.
- TTL 은 0~3600s 로 설정 가능하며, Default는 300s 입니다.
- CW 지표에는 4XX, 5XX 에러 카운트 정도만 표시되기 때문에 별도 설정을 통해 CW Logs 에 API 로깅을 해주는게 개발할 때 더 편리합니다.
Data Transformation 요건이 없다면 integration type 을 proxy integration 로 연동하면 API Gateway에서 Backend 로 부터 받은 내용을 그대로 리턴합니다.
- Data Transformation 요건이 있다면 , Mapping Template 을 사용
Mapping Template의 Content-Type을 application/json 과 text/html 로 두개를 만들어 놓고 분기 처리 합니다.
(Request Mapping Template에 2개, Response Mapping Template에 2개)- response 시 에는 accept header 값을 보고 어떤 VTL 을 적용할지 선택 가능
Reference
- https://aws.amazon.com/ko/api-gateway/faqs/
- https://docs.aws.amazon.com/apigateway/latest/developerguide/limits.html
- https://github.com/hatsari/article/tree/master/aws/aws_api_gw_httpapi
- https://www.cloudconformity.com/knowledge-base/aws/APIGateway/
Blog
- Visualizing Amazon API Gateway usage plans using Amazon QuickSight
- Using multiple segments in Amazon API Gateway base path mapping
- Performing canary deployments for service integrations with Amazon API Gateway
- Integrating Amazon API Gateway private endpoints with on-premises networks
- Building private cross-account APIs using Amazon API Gateway and AWS PrivateLink
- Building a serverless multi-player game that scales
- Introducing Amazon API Gateway service integration for AWS Step Functions
- The serverless LAMP stack part 6: From MVC to serverless microservices
- Building a serverless document scanner using Amazon Textract and AWS Amplify