Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the maximum number of virtual processor cores available in AWS Lambda?

I'm trying to find the maximum number of virtual processor cores available in AWS Lambda. The official documentation implies that it scales with the amount of configured memory:

In the AWS Lambda resource model, you choose the amount of memory you want for your function, and are allocated proportional CPU power and other resources. For example, choosing 256MB of memory allocates approximately twice as much CPU power to your Lambda function as requesting 128MB of memory and half as much CPU power as choosing 512MB of memory.

However, running the following snippet gets me Number of cores = 2 even if I configure the highest amount of memory requestable: 1536 MB.

package example;

import java.io.{ InputStream, OutputStream }

class Main {
  def main(input: InputStream, output: OutputStream): Unit = {   
    val result = "Number of cores = " + Runtime.getRuntime().availableProcessors()
    output.write(result.getBytes("UTF-8"))
  }
}

So what's going on here? Am I using availableProcessors() wrong or misinterpreting its result incorrectly? Or are there some other configurations that's need to get more cores?

like image 723
My other car is a cadr Avatar asked Dec 07 '15 13:12

My other car is a cadr


People also ask

Does AWS Lambda have a limit?

There is a hard limit of 6mb when it comes to AWS Lambda payload size. This means we cannot send more than 6mb of data to AWS Lambda in a single request.

Is AWS Lambda single core?

One Lambda function has only one or two cores available, however, the power in Lambda is that you can run hundreds of them at the same time. The default limit of the amount of active Lambda functions is 100, but this is just a limit to safeguard the infrastructure (and your wallet). You can ask for more.

What processor does AWS Lambda use?

AWS Lambda Functions Powered by AWS Graviton2 Processor – Run Your Functions on Arm and Get Up to 34% Better Price Performance. Many of our customers (such as Formula One, Honeycomb, Intuit, SmugMug, and Snap Inc.) use the Arm-based AWS Graviton2 processor for their workloads and enjoy better price performance.

Is there a limit to the number of AWS Lambda functions executed at once?

The default concurrency limit per AWS Region is 1,000 invocations at any given time. The default burst concurrency quota per Region is between 500 and 3,000, which varies per Region. There is no maximum concurrency limit for Lambda functions.


4 Answers

As per AWS Lambda documentation and forum, AWS doesn't state which instance types that AWS uses for this service. In the end of 2014, AWS used compute-optimize-like instances. And now, AWS uses general-purposes-like instances.

The CPU share dedicated to a function is based off of the fraction of its allocated memory, per each of the two cores. For example, an instance with ~ 3 GB memory available for lambda functions where each function can have up to 1 GB memory means at most you can utilize ~ 1/3 * 2 cores = 2/3 of the CPU. The details may be revisited in the future, but that is the fractional nature of our usage model.

You can only utilize the CPU power proportional to the memory. Although, the lower and higher memory are in a same instance, they will share proportional CPU power, which is the higher memory will get more CPU power. If you read your total CPU cores is 2, it doesn't mean that you can fully utilize all of the CPU.

Currently, there is no way to configure CPU. Only total memory that you can adjust.

like image 163
Edward Samuel Avatar answered Oct 05 '22 16:10

Edward Samuel


While AWS till today didn't disclose any details regarding processing power of AWS Lambda functions, they now did after announcing an increase of the maximum memory from 1536 MB to 3008 MB. Their documentation now states:

Functions larger than 1536MB are allocated multiple CPU threads, and multi-threaded or multi-process code is needed to take advantage of the additional performance.

Based on that, we can conclude that all AWS Lambda functions up to 1536 MB of memory have a single virtual processor core available, while functions with more memory have two cores available.

Update:

While that part of the documentation isn't available anymore, Chris Munns from AWS recently at the AWS Serverless Startup Day on 2018-07-10 disclosed that all AWS Lambda functions with more than 1.8GB of memory are running on multiple cores. So apparently the boundary between single-core and multi-core for AWS Lambda functions moved from 1.5GB to 1.8GB.

like image 27
Dunedan Avatar answered Oct 05 '22 18:10

Dunedan


Edit 16 Sep 2021

This answer is almost 6 years old and not really relevant anymore. See comments, you can now select up to 6 cores based on the amount of RAM you select.

Original answer

You're asking the wrong question I think (or want to use Lambda for something where it's not built for). One Lambda function has only one or two cores available, however, the power in Lambda is that you can run hundreds of them at the same time. The default limit of the amount of active Lambda functions is 100, but this is just a limit to safeguard the infrastructure (and your wallet). You can ask for more.

So your account can have 100 Lambda functions running at the same time, which you could see as 100 cores (however it's not). If you request a limit increase, this could also be 1000 or 10,000 or 100,000.

Analogy: instead of having 1 100-core computer, you have 100 1-core computers.

like image 32
Luc Hendriks Avatar answered Oct 05 '22 17:10

Luc Hendriks


According to the latest announcement from AWS, the maximum number of vCPUs is six.

like image 38
Jacek Avatar answered Oct 05 '22 17:10

Jacek