- Notifications
You must be signed in to change notification settings - Fork1.2k
Description
from slack, about django zappa but the fixes suggested seem to belong upstream in zappa proper.
tlpriest [12:54 AM]
Has anyone run a significant django project on api gateway + lambda? I'm seeing some odd behavior just trying to complete a migration. 1 - It takes a very long time (4 minutes) with a t2.medium RDS server. Using docker postgres container localhost it takes about 1m20s. 2 - It appears to me that something is automatically resubmitting the request if it's not completed in a certain timeout (I'm trying to divine the timeout value from the logs now, but I'm seeing the original migrate and 3 restarts if the log streams are correct).
I have found the source of the resubmission issue I believe. python boto3 has a default read timeout of 60 seconds. I set the execution time on the lambda function to 5 minutes so migration could complete. So, when you invoke "./manage.py invoke ${env} migrate" and that does not complete in 60 seconds, it looks like there's a resubmission by the boto3 client to lamba, which starts a second, etc. migration in the middle of the first. (edited)
tlpriest [10:35 AM]
The fix for "manage.py invoke ${env} migrate" or any other long running process is:
config_dict = {'region_name': 'us-west-2', 'connect_timeout': 5, 'read_timeout': 300}
config = Config(**config_dict)
client = session.client('lambda', config=config)
[10:36]
You could get fancy and set the read_timeout to the duration configured for the target lambda function...