How many CPU cores does a Heroku Dyno have?

15,535

Solution 1

The number of CPUs is not published and is subject to change, but you can find out at runtime by running grep -c processor /proc/cpuinfo.

Solution 2

According to https://blog.heroku.com/archives/2014/2/3/heroku-xl

|       | 1X Dyno      | Performance Dyno  |
|-------|--------------|-------------------|
| RAM   | 512 MB       | 6 GB              |
|       | 1x - 4x      | 40x (8 CPU cores) |
| Price | $0.05 / hour | $0.80 / hour      |

The 2X dynos also have 4 cores:

$ heroku run --size=2X grep -c processor /proc/cpuinfo --app app-name
Running grep -c processor /proc/cpuinfo on app-name... up, run.3685
4

But the PX dynos have 8 cores:

$ heroku run --size=PX grep -c processor /proc/cpuinfo --app app-name
Running grep -c processor /proc/cpuinfo on app-name... up, run.4731
8

Solution 3

The heroku puma documentation suggests that you can find this out by running nproc on a dyno:

So, for example, to see how many are on performance-m, running:

$ heroku run bash --size=performance-l
$ nproc
8

But then dividing by 2, because:

The value returned by nproc includes “hyperthreads” in addition to physical cores, the combination of these two are refered to as the vCPU count. All physical cores used on Heroku have a hyperthread so to gain the “true” number of physical cores divide by two.

Which would mean performance-l has 4 CPUs.

When I do the same on performance-m, I get 2, meaning actually only 1 CPU.

Standard-1x and Standard-2x both have nproc tell me "8", meaning 4 CPUs, but the heroku puma documentation warns that these CPUs are shared with other users since standard dynos are multi-tenant.

The value for nproc from free, hobby, standard-1x, and standard-2x dynos are correct, but these cores are shared between multiple applications running in containers. While nproc for these dynos will all return 8, it is best to assume only one process can execute at a time.

Share:
15,535
jcatalan
Author by

jcatalan

Updated on June 22, 2022

Comments

  • jcatalan
    jcatalan almost 2 years

    I'm using Django with Celery 3.0.17 and now trying to figure out how many celery workers are run by default.

    From this link I understand that (not having modified this config) the number of workers must be currently equal to the number of CPU cores. And that's why I need the former. I wasn't able to find an official answer by googling or searching Heroku's dev center. I think it's 4 cores as I'm seeing 4 concurrent connections to my AMQP server, but I wanted to confirm that.