Worker types
Below is a list of available worker types. Most worker types require installation of an additional package.
If you don’t see a worker type that meets your needs, consider
developing a new worker type.
Worker options
Workers poll for work from one or more queues within a work pool. If the worker references a work queue that doesn’t exist, it is created automatically. The worker CLI infers the worker type from the work pool. Alternatively, you can specify the worker type explicitly. If you supply the worker type to the worker CLI, a work pool is created automatically if it doesn’t exist (using default job settings). Configuration parameters you can specify when starting a worker include:
You must start a worker within an environment to access or create the required infrastructure to execute flow runs.
The worker will deploy flow runs to the infrastructure corresponding to the worker type. For example, if you start a worker with
type
kubernetes, the worker deploys flow runs to a Kubernetes cluster.
Prefect must be installed in any environment (for example, virtual environment, Docker container) where you intend to run the worker or
execute a flow run.
Worker status
Workers have two statuses:ONLINE and OFFLINE. A worker is online if it sends regular heartbeat messages to the Prefect API.
If a worker misses three heartbeats, it is considered offline. By default, a worker is considered offline a maximum of 90 seconds
after it stopped sending heartbeats, but you can configure the threshold with the PREFECT_WORKER_HEARTBEAT_SECONDS setting.
Worker logs
Workers send logs to the Prefect Cloud API if you’re connected to Prefect Cloud.- All worker logs are automatically sent to the Prefect Cloud API
- Logs are accessible through both the Prefect Cloud UI and API
- Each flow run will include a link to its associated worker’s logs
Worker details
The Worker Details page shows you three key areas of information:- Worker status
- Installed Prefect version
- Installed Prefect integrations (e.g.,
prefect-aws,prefect-gcp) - Live worker logs (if worker logging is enabled)
Start a worker
Use theprefect worker start CLI command to start a worker. You must pass at least the work pool name.
If the work pool does not exist, it will be created if the --type flag is used.
--type flag:
--limit flag.
For example, to limit a worker to five concurrent flow runs:
Configure prefetch
By default, the worker submits flow runs 10 seconds before they are scheduled to run. This allows time for the infrastructure to be created so the flow run can start on time. In some cases, infrastructure takes longer than 10 seconds to start the flow run. You can increase the prefetch time with the--prefetch-seconds option or the PREFECT_WORKER_PREFETCH_SECONDS setting.
If this value is more than the amount of time it takes for the infrastructure to start, the flow run will wait until its
scheduled start time.
Polling for work
Workers poll for work every 15 seconds by default. You can configure this interval in your profile settings with thePREFECT_WORKER_QUERY_SECONDS setting.
Install policy
The Prefect CLI can install the required package for Prefect-maintained worker types automatically. Configure this behavior with the--install-policy option. The following are valid install policies:
Further reading
- See how to daemonize a Prefect worker.
- See more information on overriding a work pool’s job variables.