![]() ![]() There are three ways you could create a Lambda function on AWS: It could be something as simple as retrieving a blog post, creating a blog post, or even sending an email. An event triggers a Lambda function and dies after execution. AWS LAMBDA IMAGE RESIZE CODEIt allows you to run code without having to deal with servers in the cloud. AWS Lambda functionsĪs I said in the beginning, Lambda is a computing service offered by AWS. That’s because you’re going to learn something cool-no, something mind-blowing. With that established, now’s the time to hold onto your hat. That’s more than what’s held by any other provider. What’s Amazon Web Services?Īmazon Web Service, or AWS, is a leader in cloud computing platforms.Īccording to their website, AWS provides a “highly reliable, scalable, low-cost infrastructure platform and powers hundreds of thousands of businesses in 190 countries around the world.” According to Canalys’ 2018 report, AWS holds 32.6% of the market share. One of the entities responsible for taking care of these servers is Amazon Web Services. ![]() It only means the burden of managing these servers is taken away from you. Serverless doesn’t mean an absence of servers, because there actually are servers. Instead, the focus is on your business logic, broken down into smaller, single-purpose functions like so: There is no need for server provisioning, monitoring, logging, or managing the underlying infrastructure. Now, a shift in cloud computing known as serverless, or function-as-a service, has emerged in parallel. However, server provisioning, scaling, and monitoring was still a difficult task. In just minutes, you could spin up servers in multiple regions and deploy applications in seconds. You no longer needed to entertain the idea of building your own data centers anymore. Recently, a new era paved the way for running an application in the cloud. ![]() The process was tedious, difficult, and very demanding. Back then, companies built their own data centers. Then, using a Lambda function with NodeJS runtime, we’ll write code which will use the ( ) to resize the image into two sizes - one 200px wide, and another 800px wide, and finally, store it in another S3 bucket.First, let me take you back to the time when applications were hosted on physical machines in server rooms. We’ll create a simple image optimization pipeline which will get triggered whenever a new image is added to our S3 bucket. I’ve mostly focused on the Lambda code and the concept of the pipeline, so I’m assuming the reader is familiar with common workflows in the AWS ecosystem. So, this post describes a way to tackle this problem in an efficient way using AWS services. (If you want to read about how images are being uploaded directly to S3 from client, I’ve written about it here) So, doing the conversion on API side was not an option. I was using AWS S3 for storing the pictures, and the pictures were being uploaded to S3 from the client side itself, and the API would just receive the URL for uploaded image. Taking this one step ahead, let’s make two copies of the picture in different sizes - one relatively high res (for profile picture, yearbook picture, etc) and another a bit low res (for displaying on scraps where small size picture is needed) to improve performance. Ideally, what should happen is that once user uploads the picture, it should be resized, compressed and then used. It’s not just the performance, but the cost skyrockets as well, since that large image gets downloaded by so many other users multiple times. Also, if some user uploads a picture in wrong dimensions, it would ruin the UI for other users. If some user uploads a high quality 5 MB picture, the whole application would potentially slow down because of that. One mistake I made and realized a bit late after we got many users, is that I was directly storing the user uploaded profile pictures and then showing them as-is throughout the application. When a user registers on the platform, they upload an image as their profile picture, which is then used on their profile, as well as on others’ profile if they post a scrap for other users. So, we’re planning to work some more on GradGoggles and reach even more users this time. Since the pandemic hasn’t receded, even the batch of 2021 is going to graduate virtually. We recieved a very good response from users regarding GradGoggles. You can read the case study for the project here. Last year, I worked on an interesting project which was a virtual yearbook and scrapbook for the graduating batch of 2020 in my college. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |