# ClientError：调用 Invoke 操作时出错（RequestEntityTooLargeException）：对于 Invoke 操作，请求必须小于 6291556 字节

- **ID:** `aws/lambda-invoke-payload-too-large`
- **领域:** aws
- **类别:** runtime_error
- **错误码:** `RequestEntityTooLargeException`
- **验证级别:** ai_generated
- **修复率:** 85%

## 根因

通过同步 Invoke 发送到 AWS Lambda 的负载超过了最大请求大小 6 MB（6,291,556 字节），导致 API 拒绝调用。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| lambda-2015-03-31 | active | — | — |
| boto3-1.34.0 | active | — | — |

## 解决方案

1. ```
   使用异步调用（Event 调用）支持最多 256 KB 负载，或使用 S3 传递大负载：上传到 S3 并将对象键传递给 Lambda。
   ```
2. ```
   将负载分成较小的块并多次调用 Lambda，在客户端聚合结果。
   ```
3. ```
   使用带有函数 URL 或 API Gateway 的 Lambda，可以处理更大的负载（最多 10 MB）并流式传输数据。
   ```

## 无效尝试

- **Increase Lambda function timeout or memory** — Timeout and memory limits affect execution, not the payload size limit; the API rejects before the function runs. (95% 失败率)
- **Compress the payload with gzip but keep the same structure** — Lambda Invoke API doesn't automatically decompress; the function receives compressed bytes, which may break parsing unless handled explicitly. (60% 失败率)
