I compared Node.js and Python in creating thumbnails using AWS Lambda

I investigated which framework, Node.js or Python, is better for the thumbnail creation process using AWS Lambda.

TL;DR

--If you want to create thumbnails, Python seems to have much better performance than Node.js. --Sample code is here

Experimental scenario

  1. Download photos from S3
  2. Rotation correction by looking at the Orientation value of Exif
  3. Get the width and height values after rotation correction
  4. Resize to 50% and upload to S3

Input image

Output image

Lambda function specs

--Memory 256M

Experimental result

Results of running 5 times each on the AWS console

Node.js Python
processing time(ms) 10500 - 12375 3214 - 3727

The result is that Python has an overwhelmingly shorter processing time. The maximum memory size used was also smaller in Python.

So, if you want to generate thumbnails with AWS Lambda, it seems better to use Python than to use Node.js.

Creating thumbnails in Python

ImageMagick (GraphicMagicks) is available in Node.js from the beginning, and there are many sample programs and articles, but Python does not have much information. When I built the image processing library Pillow in Python on EC2 with reference to the following, surprisingly smooth thumbnail creation worked using Lambda.

-Try using the image processing library "Pillow" with AWS Lambda

The code used in this experiment is located here. The pre-built Pillow is also included in the repository, which can be useful if you want to quickly create thumbnails with AWS Lambda x Python.

Recommended Posts

I compared Node.js and Python in creating thumbnails using AWS Lambda
[Python] I wrote a REST API using AWS API Gateway and Lambda.
[Python] Scraping in AWS Lambda
I compared Java and Python!
Summary if using AWS Lambda (Python)
Write AWS Lambda function in Python
Install pip in Serverless Framework and AWS Lambda with Python environment
[AWS] Using ini files with Lambda [Python]
Notes using cChardet and python3-chardet in Python 3.3.1.
I compared python3 standard argparse and python-fire
Easy server monitoring with AWS Lambda (Python) and result notification in Slack
I compared using Dash and Streamlit in Docker environment using B league data
I tried web scraping using python and selenium
Differences between queryStringParameters and multiValueQueryStringParameters in AWS Lambda
I tried object detection using Python and OpenCV
Creating numbering process using python in DynamoDB Local Numbering process
I was able to recurse in Python: lambda
I wrote a class in Python3 and Java
I compared "python dictionary type" and "excel function"
Amazon API Gateway and AWS Lambda Python version
Try using ChatWork API and Qiita API in Python
I checked the reference speed when using python list, dictionary, and set type in.
Develop, run, and deploy AWS Lambda remotely using lambda-uploader
Dynamic HTML pages made with AWS Lambda and Python
Basics of I / O screen using tkinter in python3
I tried using google test and CMake in C
Try creating a compressed file using Python and zlib
[AWS IoT] Register things in AWS IoT using the AWS IoT Python SDK
I tried using TradeWave (BitCoin system trading in Python)
I put Selenium and headless chrome in AWS lambda. (Notes under Win10 environment, etc.)
Check types_map when using mimetypes on AWS Lambda (Python)
I compared the speed of the reference of the python in list and the reference of the dictionary comprehension made from the in list.
I tried to get an AMI using AWS Lambda
I want to AWS Lambda with Python on Mac!
Read and write NFC tags in python using PaSoRi
[Python] Retry process (Exponential Backoff) memo in AWS Lambda
AWS Lambda now supports Python so I tried it
Make ordinary tweets fleet-like with AWS Lambda and Python
I was able to repeat it in Python: lambda
I compared Python more-itertools 2.5 → 2.6
I clustered the dollar yen using the k-medoids method in python and calculated the correct answer rate.
I tried [scraping] fashion images and text sentences in Python.
Try to make it using GUI and PyQt in Python
I got an error in vim and zsh in Python 3.7 series
I made a quick feed reader using feedparser in Python
What I learned about AI and machine learning using Python (4)
A memo when creating a directed graph using Graphviz in Python
Collect tweets using tweepy in Python and save them in MongoDB
I tried programming the chi-square test in Python and Java.
I created a class in Python and tried duck typing
Predict gender from name using Gender API and Pykakasi in Python
Graph time series data in Python using pandas and matplotlib
I tried to make a stopwatch using tkinter in python
Create API with Python, lambda, API Gateway quickly using AWS SAM
[AWS Lambda] Use any container Image in Python very simply
I made a Chatbot using LINE Messaging API and Python
Site monitoring and alert notification with AWS Lambda + Python + Slack
I wrote python in Japanese
Generate rounded thumbnails in Python
[Python] I tried using OpenPose
Web scraping using AWS lambda