Skip to content

Cores vs Slots in FlinkπŸ”—


1. CPU Cores = Physical HardwareπŸ”—

A machine (or container) running a Task Manager has a fixed number of physical CPU cores.

Example: A Task Manager with 4 cores means it can realistically run about 4 parallel threads at full speed.


2. Slots = Logical Parallelism UnitsπŸ”—

Flink divides each Task Manager into task slots.

  • A slot is a logical unit of parallel work.
  • Each slot gets an equal share of the Task Manager’s JVM (CPU, memory, network buffers).

Slots represent how many tasks you allow Flink to run concurrently on that Task Manager.


Key Point: Slots are NOT equal to coresπŸ”—

You can set more slots than CPU cores. Flink will allow more tasks, but they will time-slice on the CPUs.

Example: 4-core machine 8 slots

Tasks will share CPU time; throughput may drop but Flink allows it.


3. How slots relate to coresπŸ”—

Usually, slots ≀ cores is recommended for heavy workloads.

Typical configurations:πŸ”—

  • CPU-heavy streaming: 1 slot per core
  • Mixed/light workload: 2 slots per core
  • Very state-heavy jobs: fewer slots than cores

Slots determine parallel subtasks, but cores determine actual CPU power available.


4. What runs inside a slot?πŸ”—

A slot runs:

  • A chain of operators (map β†’ filter β†’ window) for one subtask
  • As a single thread or a few threads inside the TM
  • Using shared memory with other slots

Each slot holds one pipeline of tasks, not one operator.


5. Example to make it crystal clearπŸ”—

Suppose you have:πŸ”—

  • Machine with 8 CPU cores
  • Task Manager configured with 4 slots

Then Flink can run:

  • 4 parallel subtasks on that TM
  • Each subtask gets about 2 CPU cores worth of time (shared among all JVM threads)

If you instead configure 8 slots:πŸ”—

  • You can run 8 parallel subtasks
  • But each subtask gets about 1 core worth of CPU time (due to time sharing)

Performance depends on workload.


AnalogyπŸ”—

Think of the machine as a restaurant kitchen:

Cores = number of cooksπŸ”—

Each cook can actively prepare one dish at a time.

Slots = number of workstationsπŸ”—

Even if you have 8 workstations (slots), if you only have 4 cooks (cores), not all workstations can operate at full speed.


6. Main Differences SummaryπŸ”—

Concept Meaning Controlled By Relation
CPU Cores Real physical CPUs available Hardware / container Determines raw compute power
Slots Logical parallel subtask capacity Flink Task Manager config Determines concurrency level

Final Short SummaryπŸ”—

  • Cores = physical compute power
  • Slots = logical parallelism units
  • Slots can be equal, fewer, or greater than cores.
  • Slots determine how many tasks can run in parallel; cores determine how fast they run.