In serverless computing, the amount and quality of CPU allocated to functions significantly impacts performance. AWS Lambda provides 1 vCPU with 1,769 MB of memory, while Google Cloud Functions requires 2,048 MB of memory to achieve 1 vCPU. This difference in CPU allocation efficiency explains why AWS Lambda demonstrated approximately 30% faster performance in benchmark tests for both simple hello world functions and image processing workloads, despite both platforms using similar memory-to-CPU proportions.
Cloud Functions vs AWS Lambda: 2023 Performance Benchmark Analysis
Added:In this video, we're going to run a benchmark test between AWS Lambda and Google Cloud Functions.
Recently Google Cloud introduced a new generation of Cloud Functions; they call it gen 2.
It's simply a wrapper around Cloud Run, which brings even more confusion.
For example, in the previous generation, to allow unauthenticated access to the function, you would need to grant a Cloud Functions Invoker role to all users.
Since gen 2 is a wrapper around Cloud Run, now, to achieve the same result, you would need to grant the Cloud Run Invoker role to Cloud Functions.
In the first benchmark test to establish a baseline, we will create a simple function that returns hello world and invoke that function using its URL 1000 times.
In the second test, we will download a large image from the S3 or GS bucket, depending on the Cloud, then resize it to 400 by 400 pixels and save the result back to the bucket.
Then based on the results, we will design a 3rd benchmark test.
In AWS, you can only give memory to your Lambda function.
It allocates CPU power in proportion to the amount of memory configured.
For example, if you need 1 vCPU, you would provide 1,769 MB of memory to your function.
There are a bunch of other parameters, but those are the most important ones.
Google Cloud Functions uses similar proportions.
We're going to allocate the same amount of memory for both functions, which is 1Gb, which results in a little more than half of the virtual CPU.
Also, how quickly Lambda and Cloud Functions can autoscale based on the load will play an important role in this test.
You can find the source code for the functions as well as terraform to reproduce this benchmark test in my GitHub repository.
If you run terraform apply, you'll get a few URLs that you can use to test your functions.
To run a benchmark, we're going to use a hey tool.
It's a tiny golang app that sends some load to a web application.
First of all, let's test the AWS Lambda hello world function.
There are a few arguments that we need to supply to hey.
First, we want to perform 1000 requests.
Then we want to spin up five workers to run some requests in parallel.
Also, specify the GET method and provide the URL for the function to invoke.
It does not have any output while it's running.
In the results, you can find the information about the slowest request, fastest and average, and a bunch of other staff.
And how many requests per second it served.
You also get a histogram with response distribution.
Here, for example, the average time of the requests is 119 ms. Also, it's important to take a look at latency distribution and especially how long it took to complete 95 and 99% of all requests.
For simplicity, I will just compare average time.
Next, let's run exactly the same hello world Google Cloud Function.
The results are slightly better.
The average time is only 110 ms, which is around 8% faster.
And we got 44 requests per second instead of 41 with Lambda.
I don't think you should rely on these particular benchmarks except that we proved that our serverless functions work.
We can also take a look at the concurrent execution; that's how many functions were created to serve the traffic.
In AWS, when you run short tests, metrics are not very accurate, but still, we can see that Lambda scaled from 1 instance to 3.
GCP also spun up 3 cloud functions for the hello world test.
Now let's take a look at another function to resize the image.
We have 3 golang functions, getImage to download an object from the bucket, uploadImage to save a new scaled-down image to the bucket, and scaleImage to resize the image.
In GCP, we use google cloud sdk, so the code will be slightly different but with the same logic.
To test AWS Lambda that resizes the image, grab the URL and use the same load test tool.
This test takes around 8 to 10 minutes to complete.
In the results, we have the average duration, which is 2.38 seconds, and 2 requests per second.
95% of the requests were completed in under 2.8 seconds.
Now run the same test with the Google Cloud Function to resize the image.
The results are significantly slower.
The average duration is above 3 seconds, and we only completed 1.5 requests per second, which is 36% slower than AWS.
During this benchmark, AWS created five instances of the Lambda function to resize the image.
On the other hand, Google doubles it to almost ten functions.
Let's run the final test, in which we are going to use AWS lambda, but instead of using S3, we are going to download an image from the Google Storage bucket, resize it and upload it back.
Basically, the same thing that the google cloud function does.
To grant permissions, you need to get the credentials file and put it into your lambda function and use the environment variable.
Results are a little bit surprising; AWS Lambda's average duration is 2.47 seconds which is still 31% faster than the native google cloud function.
To conclude, AWS lambda is significantly faster than Google Cloud Function.
The reason, in my opinion, would be the amount and quality of CPU that is allocated to the functions.
Based on the official data, in aws, you get one vCPU with 1,769 MB memory, and in GCP, you need 2048MB to get one vCPU.
There are other parameters that can affect the function performance, such as networking and auto-scaling.
Let me know in the comments why you think Cloud Functions are slower.
Thank you for watching; take a look at another benchmark between AWS lambda written in Golang vs. Rust; you will be surprised by the results.
Up Next

Reactive Intermediates in Chemistry: DelocChem Virtual Meeting
@delocchemvirtualchemistrym1718
325 views•2020-07-22

Triumph of Orthodoxy Icon: Byzantine Art & History Explained
@BenCallan
2.1K views•2024-08-06

Automating Docker Image Builds to AWS ECR with GitHub Actions
@AntonPutra
32.7K views•2021-10-17

Game of Thrones Opening Credits: A Cinematic Analysis
@gameofthrones
46.3M views•2011-04-18
Related Study Plans & Knowledge Roadmaps
Structured learning paths in General & Interdisciplinary Studies





















![AWS re:Invent 2019: [REPEAT 1] A serverless journey: AWS Lambda under the hood (SVS405-R1)](https://i.ytimg.com/vi/xmacMfbrG28/hqdefault.jpg)

















