dyerc / craft-flux

Craft CMS plugin which integrates with AWS Lambda and CloudFront to process, cache and serve images
https://cdyer.co.uk/plugins/flux
Other
4 stars 2 forks source link

CloudFront invalidations are limited to 3000 concurrent invalidation paths #11

Closed markdrzy closed 1 year ago

markdrzy commented 1 year ago

Per the CloudFront API documentation,

you can have invalidation requests for up to 3,000 files per distribution in progress at one time.

If this number is exceeded, the invalidation requests will fail. The invalidateCache method accepts an array of paths, but does not presently batch the invalidation requests if greater than 3000 paths are provided. To work around this limitation, invalidation requests should be sent in 3000-chunk batches.

It should also be noted that invalidation requests may be in progress for a non-trivial duration; if multiple 3000-chunk invalidation requests are sent simultaneously, only the first batch will succeed — the others will fail. I believe the only way to avoid this situation is to send these invalidation requests synchronously.

dyerc commented 1 year ago

Thanks @markdrzy for pointing out both of these CloudFront request limits. I'll change the function to batch up the requests.