![]() ![]() It won't work, it will throw an "Invalid ELF Header" error. You can't just npm install sharp locally, zip it with code and upload to Lambda (as you normally would do with other packages). Since it uses native APIs, it needs to be compiled on the same architecture that the Lambda runs on. It uses VIPS, that only holds a part of the image in memory at one time, so it's very fast and efficient.īut an issue with using Sharp in AWS Lambda environment is exactly the VIPS library. Sharp is a NodeJS image transformation library that way exceeds other libraries like ImageMagic in terms of speed. Here is the list of all available event sources for Lambda. How do you run a Lambda function? There are several ways of invoking it - via an HTTPS request to a specific url or your Lambda (Amazon API Gateway), or when an specific event happens on one of the AWS services like SNS or S3. ![]() ![]() You only write the code, and AWS takes care of starting instances of your Lambda function, scaling it up or down and balancing hardware requirements. Your Lambda function can do anything, and in our case it was resizing images. You write code for your Lambda function, in Java, NodeJS or Python, and you upload it to AWS Console. AWS Lambda was a perfect match for those requirements.ĪWS Lambda is Amazon's compute service. We wanted this processing to be scalable, and to allow it to run in parallel without much programming overhead. But we also had to wait for all the images to upload before starting to resize them - there were business rules preventing us from resizing images as they come. So the images needed to be available (nearly) as soon as the new Order came in, in different sizes. When I say resizing, I actually mean getting all those images from S3, doing the resizing, and storing them back to S3.Ī lot of hi-res images would be uploaded with the Order (1000 or more), and as soon as they all got uploaded, the Admin would see the new Order and should be able to browse through the images - two sizes of thumbs alongside the original image. The result - resizing 1000 images (around 1.2 GB) to 2 thumbnail sizes in a little less than 3s. Recently I worked on a project that required fast image resizing. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |