Skip to main content

Prefect benchmarks

Benchmark conclusions
Conclusions for each benchmark run for all engines in all languages and settings

Summary

Prefect outperformed Airflow in most benchmarks, especially in long-running tasks, but still exhibited noticeable assignment delays and orchestration latency. It’s adequate for moderate workloads, but not optimized for high-frequency or highly parallel use cases.

Prefect setup

We set up Prefect version 2.14.4. We wrote our own simple docker compose since we couldn't find a recommended one in Prefect's documentation. We chose to use Postgresql as a database, as it is the recommended option for production usecases.

version: '3.8'

services:
postgres:
image: postgres:14
restart: unless-stopped
volumes:
- db_data:/var/lib/postgresql/data
expose:
- 5432
environment:
POSTGRES_PASSWORD: changeme
POSTGRES_DB: prefect
healthcheck:
test: ['CMD-SHELL', 'pg_isready -U postgres']
interval: 10s
timeout: 5s
retries: 5

prefect-server:
image: prefecthq/prefect:2-latest
command:
- prefect
- server
- start
ports:
- 4200:4200
depends_on:
postgres:
condition: service_started
volumes:
- ${PWD}/prefect:/root/.prefect
- ${PWD}/flows:/flows
environment:
PREFECT_API_DATABASE_CONNECTION_URL: postgresql+asyncpg://postgres:changeme@postgres:5432/prefect
PREFECT_LOGGING_SERVER_LEVEL: INFO
PREFECT_API_URL: http://localhost:4200/api
volumes:
db_data: null

The flow was defined using the following Python file.

from prefect import flow, task

ITER = 10 # respectively 40
FIBO_N = 33 # respectively 10

def fibo(n: int):
if n <= 1:
return n
else:
return fibo(n - 1) + fibo(n - 2)

@task
def fibo_task():
return fibo(FIBO_N)

@flow(name="bench_{}".format(ITER))
def benchmark_flow():
for i in range(ITER):
fibo_task()

if __name__ == "__main__":
benchmark_flow.serve(name="bench_{}".format(ITER))

Fibonacci 40 iterations, n=10

This benchmark measures the performance of Prefect when handling a large number of lightweight tasks. The tasks are Fibonacci calculations with 40 iterations and a base value of 10.

Python

Visualization
Statistics
PrefectWindmillWindmill Dedicated
Total duration (in seconds)4.8724.3832.092
Assignment2.174 (44.62%)1.836 (41.89%)1.795 (85.80%)
Execution1.546 (31.73%)2.215 (50.54%)0.122 (5.83%)
Transition1.152 (23.65%)0.332 (7.57%)0.175 (8.37%)
Timing details
View task timing details
TaskCreated atStarted atCompleted at
task_000.0001.2131.257
task_011.2941.3211.362
task_021.3941.4231.463
task_031.4961.5221.558
task_041.5871.6121.647
task_051.6761.7001.738
task_061.7671.7911.828
task_071.8581.8821.943
task_081.9741.9982.037
task_092.0682.0932.131
task_102.1622.1882.228
task_112.2602.2922.330
task_122.3592.3822.420
task_132.4492.4762.517
task_142.5482.5732.612
task_152.6402.6702.713
task_162.7422.7652.800
task_172.8282.8512.886
task_182.9162.9402.975
task_193.0043.0283.066
task_203.0953.1193.156
task_213.1873.2113.247
task_223.2763.2993.335
task_233.3643.3893.427
task_243.4623.4893.528
task_253.5573.5793.613
task_263.6413.6643.699
task_273.7263.7513.788
task_283.8173.8393.873
task_293.9003.9214.004
task_304.0334.0594.094
task_314.1234.1514.185
task_324.2114.2344.267
task_334.2934.3154.349
task_344.3774.4044.442
task_354.4704.4924.526
task_364.5554.5774.611
task_374.6384.6614.696
task_384.7264.7494.784
task_394.8144.8384.872
Windmill Comparison
TaskCreated atStarted atCompleted at
task_000.0000.0030.059
task_010.0670.1130.171
task_020.1800.2260.280
task_030.2900.3350.389
task_040.3980.4460.501
task_050.5100.5580.614
task_060.6220.6690.725
task_070.7320.7800.834
task_080.8420.8890.942
task_090.9500.9971.052
task_101.0611.1081.166
task_111.1751.2201.274
task_121.2831.3301.385
task_131.3941.4401.494
task_141.5031.5501.605
task_151.6121.6611.716
task_161.7231.7701.823
task_171.8311.8781.930
task_181.9391.9862.041
task_192.0492.0962.152
task_202.1612.2092.266
task_212.2742.3202.376
task_222.3842.4312.486
task_232.4952.5422.596
task_242.6042.6522.706
task_252.7152.7612.816
task_262.8252.8722.925
task_272.9332.9793.033
task_283.0423.0903.145
task_293.1543.2013.269
task_303.2783.3253.382
task_313.3913.4373.493
task_323.5013.5483.602
task_333.6113.6603.715
task_343.7233.7703.823
task_353.8333.8793.934
task_363.9423.9904.045
task_374.0534.1014.157
task_384.1654.2124.268
task_394.2774.3244.383
Windmill Dedicated Comparison
TaskCreated atStarted atCompleted at
task_000.0000.0190.022
task_010.0290.0730.077
task_020.0810.1250.128
task_030.1340.1790.182
task_040.1870.2310.234
task_050.2390.2840.287
task_060.2920.3380.341
task_070.3450.3910.394
task_080.3980.4440.447
task_090.4510.4970.500
task_100.5050.5490.552
task_110.5570.6030.606
task_120.6100.6550.659
task_130.6630.7090.712
task_140.7160.7610.764
task_150.7680.8140.817
task_160.8210.8670.870
task_170.8760.9210.924
task_180.9290.9730.976
task_190.9811.0271.030
task_201.0351.0801.083
task_211.0871.1321.135
task_221.1391.1861.189
task_231.1931.2381.241
task_241.2461.2921.295
task_251.2991.3451.348
task_261.3521.3981.401
task_271.4051.4511.454
task_281.4581.5041.507
task_291.5121.5571.560
task_301.5641.6111.614
task_311.6181.6641.667
task_321.6711.7171.720
task_331.7241.7701.773
task_341.7771.8231.826
task_351.8301.8761.879
task_361.8841.9301.933
task_371.9371.9831.986
task_381.9912.0362.039
task_392.0432.0892.092

Fibonacci 10 iterations, n=33

This benchmark measures the performance of Prefect when handling a small number of heavyweight tasks. The tasks are Fibonacci calculations with 10 iterations and a base value of 33.

Python

Visualization
Statistics
PrefectWindmillWindmill Dedicated
Total duration (in seconds)15.4898.3477.701
Assignment1.513 (9.77%)0.428 (5.13%)0.370 (4.80%)
Execution13.658 (88.18%)7.832 (93.83%)7.205 (93.56%)
Transition0.318 (2.05%)0.087 (1.04%)0.126 (1.64%)
Timing details
View task timing details
TaskCreated atStarted atCompleted at
task_000.0001.2702.629
task_012.6732.7034.059
task_024.0954.1215.475
task_035.5085.5346.916
task_046.9516.9798.337
task_058.3738.4019.816
task_069.8499.87411.253
task_0711.28711.31312.675
task_0812.71012.73714.070
task_0914.10214.12915.489
Windmill Comparison
TaskCreated atStarted atCompleted at
task_000.0000.0020.846
task_010.8580.9061.705
task_021.7151.7612.539
task_032.5482.5953.365
task_043.3753.4214.206
task_054.2154.2635.033
task_065.0425.0895.857
task_075.8665.9136.684
task_086.6936.7407.519
task_097.5297.5798.347
Windmill Dedicated Comparison
TaskCreated atStarted atCompleted at
task_000.0000.0230.745
task_010.7760.7971.518
task_021.5461.5712.292
task_032.2982.3403.057
task_043.0633.1143.845
task_053.8743.8894.608
task_064.6144.6615.380
task_075.3855.4336.151
task_086.1586.2086.925
task_096.9336.9817.701