# ClientError: An error occurred (RequestEntityTooLargeException) when calling the Invoke operation: Request must be smaller than 6291456 bytes for the Invoke operation

- **ID:** `aws/lambda-invoke-request-too-large`
- **Domain:** aws
- **Category:** protocol_error
- **Error Code:** `RequestEntityTooLargeException`
- **Verification:** ai_generated
- **Fix Rate:** 90%

## Root Cause

Lambda synchronous invocation payload exceeds the 6 MB limit, including both request and response sizes.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| lambda-2024 | active | — | — |
| aws-sdk-python-1.34.0 | active | — | — |
| aws-cli-2.17.0 | active | — | — |

## Workarounds

1. **Use asynchronous invocation (Event invoke) which has a 256 KB payload limit, but for larger payloads, upload data to S3 first and pass the S3 key to Lambda. Example: s3_client.upload_fileobj(data_stream, bucket, key); lambda_client.invoke(FunctionName='myFunc', Payload=json.dumps({'s3_key': key}))** (95% success)
   ```
   Use asynchronous invocation (Event invoke) which has a 256 KB payload limit, but for larger payloads, upload data to S3 first and pass the S3 key to Lambda. Example: s3_client.upload_fileobj(data_stream, bucket, key); lambda_client.invoke(FunctionName='myFunc', Payload=json.dumps({'s3_key': key}))
   ```
2. **Reduce payload size by filtering unnecessary fields or using pagination. If using API Gateway, enable payload compression.** (80% success)
   ```
   Reduce payload size by filtering unnecessary fields or using pagination. If using API Gateway, enable payload compression.
   ```

## Dead Ends

- **** — Lambda服务在检查大小前不会解压，压缩后的数据仍会被视为原始大小。 (90% fail)
- **** — 分割负载会增加复杂性和延迟，且可能导致数据一致性问题。 (60% fail)
