<@ULVA73B9P> - I have a question regarding my curr...
# ask-community
h
@Marvin - I have a question regarding my current setup and would appreciate your guidance. We have a process running on a Windows (A) server in an on-premises environment. Additionally, there is an Ubuntu (B) server where we have greater control and plan to run transformation and downstream processing tasks. I would like to understand whether Prefect can be used to orchestrate and coordinate workflows across these two servers, with the primary configuration and control plane hosted on the Ubuntu server. Specifically, I am interested in: • Whether Prefect supports orchestration across multiple machines in this setup • How tasks can be triggered or executed on the Windows server from the Ubuntu-based Prefect environment • Any recommended architecture or best practices for implementing this
m
thought for 425.9 seconds
Short answer: yes. In Prefect 3.x you can orchestrate across multiple machines by running a shared control plane (Prefect Cloud or self‑hosted API) and starting a worker on each machine that polls a targeted work pool. Deployments are bound to a work pool so a given flow runs on the machine(s) whose worker(s) poll that pool. Here’s a concise, battle‑tested way to set up your Ubuntu↔️Windows topology. Architecture (recommended) - Control plane on Ubuntu (either Prefect Cloud or a self‑hosted Prefect API on Ubuntu B) - One work pool per execution environment: - ubuntu-docker or ubuntu-process (on Ubuntu B) - windows-process (on Windows A) - One worker running on each machine, pointed at its work pool - Deployments target the appropriate pool; Ubuntu flows run on Ubuntu, Windows flows run on Windows - Cross‑machine coordination via run_deployment() or Automations (event triggers) - Persist results to shared storage (S3/Azure/NFS/SMB) for handoffs Docs for key concepts - Workers: Workers overview - Work pools: Work pools - Deploy via Python: Deploy via Python - Run deployments: Run deployments - Chain deployments with events: Chaining deployments - Results: Result persistence Step‑by‑step setup 1) Point both machines at the same Prefect API - Prefect Cloud (recommended for simplicity) - On both machines set:
Copy code
# Linux (bash)
  export PREFECT_API_URL="<https://api.prefect.cloud/api/accounts/<acct-id>/workspaces/<ws-id>>"
  export PREFECT_API_KEY="<your_api_key>"
Copy code
# Windows (PowerShell)
  $env:PREFECT_API_URL = "<https://api.prefect.cloud/api/accounts/<acct-id>/workspaces/<ws-id>>"
  $env:PREFECT_API_KEY = "<your_api_key>"
- Or self‑hosted on Ubuntu B (make sure Windows A can reach it)
Copy code
# Example local server URL
  export PREFECT_API_URL="http://<ubuntu-b-ip>:4200/api"
2) Create work pools (one per environment)
Copy code
prefect work-pool create windows-process-pool --type process
prefect work-pool create ubuntu-docker-pool --type docker
# If you won’t use Docker on Ubuntu, create a process work pool instead:
# prefect work-pool create ubuntu-process-pool --type process
Tip: If you plan to use Docker/Kubernetes, install extras on the Ubuntu host:
Copy code
pip install "prefect[docker]"
# or
pip install "prefect[kubernetes]"
3) Start a worker on each machine - Ubuntu B:
Copy code
# Docker-based worker
prefect worker start --pool ubuntu-docker-pool --type docker
# or, process-based
# prefect worker start --pool ubuntu-process-pool --type process
- Windows A (PowerShell):
Copy code
prefect worker start --pool windows-process-pool --type process
Run these as services for reliability (systemd on Ubuntu, Task Scheduler/NSSM on Windows). 4) Create deployments that target each machine - Example: a flow you want to run on Ubuntu
Copy code
from prefect import flow

@flow(log_prints=True)
def transform_on_ubuntu(x: int = 1):
    print(f"Ubuntu transform: x={x}")
    return x * 2

if __name__ == "__main__":
    transform_on_ubuntu.deploy(
        name="ubuntu-transform",
        work_pool_name="ubuntu-docker-pool",  # or ubuntu-process-pool
        interval=3600,                        # run hourly, or omit for on-demand
        parameters={"x": 10},
    )
- Example: a flow you want to run on Windows ``` from prefect import flow @flow(log_prints=True) def process_on_windows(path: str): # Windows-native operations (e.g., PowerShell, COM, vendor tools) import subprocess r = subprocess.run(["powershell", "-Command", f"Get-Item '{path}'"], capture_output=True, text=True) print(r.stdout or r.stderr)
return {"path": path, "ok": r.returncode == 0} if name == "__main__": process_on_windows.deploy( name="windows-process", work_pool_name="windows-process-pool", )
Copy code
5) Trigger Windows work from Ubuntu
- Programmatically from a flow running on Ubuntu:
from prefect import flow from prefect.deployments import run_deployment @flow def orchestrate(date: str): # Kick off a Windows deployment run_deployment( name="process_on_windows/windows-process", # "<flow_name>/<deployment_name>" parameters={"path": f"C:\\data\\input\\{date}.csv"} ) if name == "__main__": orchestrate.deploy( name="ubuntu-orchestrator", work_pool_name="ubuntu-docker-pool" )
Copy code
- Or use Automations to chain deployments when one completes:
  <https://docs.prefect.io/v3/how-to-guides/automations/chaining-deployments-with-events/|Chaining deployments with events>

6) Share results/data between machines
- Turn on persisted results and use shared storage (S3/Azure/NFS/SMB):
# Global default (optional) prefect config set PREFECT_RESULTS_PERSIST_BY_DEFAULT=true
Copy code
- Example with S3 (install collection: pip install prefect-aws):
from prefect import flow from prefect_aws.s3 import S3Bucket # One-time setup (can be done in code or UI) S3Bucket(bucket_name="my-prefect-results").save("results-bucket", overwrite=True) @flow(persist_result=True, result_storage="s3-bucket/results-bucket") def cross_machine_step(): return {"status": "ok"} ``` Windows and Ubuntu workers can both read/write this storage, enabling handoffs. Operational best practices - Keep workers always-on (systemd on Ubuntu; Task Scheduler/NSSM on Windows) - Use service accounts/API keys for workers; store secrets in env vars or Prefect blocks - Use work pools per environment to isolate packages, OS specifics, and concurrency limits - Prefer Docker on Ubuntu when you need reproducible environments - For Windows‑native tooling, use the process worker and vendor CLIs/PowerShell - Ensure both machines can reach the Prefect API (firewall/DNS) and any result storage - Monitor from the Prefect UI; add retries/timeouts where appropriate Answers to your specific bullets - Orchestration across multiple machines: Yes—via work pools + workers connected to a shared API. See Workers and Work pools. - Trigger/execute tasks on Windows from Ubuntu: Create a deployment targeting the Windows work pool and trigger it from Ubuntu using
prefect deployment run ...
or
run_deployment()
from a flow. See Run deployments. - Recommended architecture: Control plane (Cloud or self‑hosted on Ubuntu) + one worker per machine polling its pool; use result persistence and, if needed, event‑driven Automations to chain cross‑machine steps. See Deploy via Python and Chaining. A few clarifying questions to tailor this to you - Will you use Prefect Cloud or self‑hosted on Ubuntu B? - Is Docker acceptable on Ubuntu B, or should we stick to the process worker there? - What needs to run specifically on Windows A (native binaries/PowerShell/vendor tools)? - Do you already have shared storage (e.g., S3/Azure/SMB/NFS) for handoffs, or should we propose one? If you share those details, I can provide a minimal, copy‑pasteable blueprint (flows, deployments, and worker service configs) for your exact environment.