CodexBloom - Programming Q&A Platform

OCI Functions: Timing Out When Invoked from API Gateway with Large Payloads

πŸ‘€ Views: 247 πŸ’¬ Answers: 1 πŸ“… Created: 2025-06-15
oracle-cloud-infrastructure oci-functions api-gateway timeout Python

I've looked through the documentation and I'm still confused about I'm testing a new approach and I'm following best practices but I'm experiencing a timeout scenario when invoking my OCI Function from the API Gateway, specifically when the payload size exceeds 1MB....... The function is designed to process JSON data, but I receive a `504 Gateway Timeout` behavior when testing with larger payloads. The function runs perfectly with smaller payloads (around 500KB) but fails to respond within the 30-second timeout limit set by the API Gateway. I've tried increasing the timeout settings in the API Gateway configuration, but it appears that the function itself is still struggling with the processing time. My function is written in Python, and here’s the relevant code snippet: ```python import json def handler(ctx, data: str = None): payload = json.loads(data) # Simulate long processing time for large payloads result = process_large_payload(payload) return json.dumps(result) def process_large_payload(payload): # Simulating a processing delay import time time.sleep(35) # Simulating long processing return {'status': 'success'} ``` I've also checked the logs in OCI Functions and noticed that it doesn't log any errors, but it does show that it starts processing the request. I suspect that the way I'm handling large payloads might be leading to this timeout scenario. Is there a best practice for handling large payloads in OCI Functions when invoked via API Gateway? Any suggestions on how I can ensure my function processes larger payloads without timing out would be really helpful. Thanks! This issue appeared after updating to Python stable. Any pointers in the right direction? I'm open to any suggestions. The stack includes Python and several other technologies. I'm open to any suggestions. My team is using Python for this REST API.