<@ULVA73B9P> as a workaround for limited 20 deploy...
# ask-marvin
s
@Marvin as a workaround for limited 20 deployment in starter plan what if I create multiple schedule for single deployment with different parameters but if I need to change or add some features in code all schedules will break ?
m
thought for 446.8 seconds
Short answer: Yes—using one deployment with many schedules (each with different parameter values) is a valid way to stay under the 20-deployment cap on the Starter plan. Schedules don’t count as deployments, and you can attach multiple schedules to a single deployment. Will schedules “break” if you change code? Not by default. - Schedules are attached to the deployment and will persist across code updates/redeploys. They will keep triggering runs for that same deployment. - What can break is the run itself if you make a breaking change to your flow’s parameter signature or expected values. For example, renaming/removing a parameter that your schedules override will cause scheduled runs to fail validation or at runtime. Best practices to avoid trouble - Keep parameter names backward compatible. If you must change them, do a phased cutover: 1) Create a new deployment (e.g., “my-flow-v2”) with the updated code. 2) Copy schedules (and their parameter values) to the new deployment. 3) Pause/delete the old schedules when you’re confident everything works. - Remember that schedules only change timing/parameters. They do not change deployment-level settings like work pool, infra image, env vars, or tags. If you need those to differ per variant, you need separate deployments. - Use defaults in your flow parameters so legacy schedules can keep running after a code change. - If you manage schedules via the UI, redeploying code won’t modify them. If you manage schedules via config/CLI and explicitly “replace” schedules, that will overwrite them—use with care. Helpful commands and docs - List schedules on a deployment:
Copy code
prefect deployment schedule ls "<flow-name>/<deployment-name>"
- Create/pause/resume/delete schedules:
Copy code
prefect deployment schedule create "<flow-name>/<deployment-name>"
  prefect deployment schedule pause "<flow-name>/<deployment-name>" --id <schedule-id>
  prefect deployment schedule resume "<flow-name>/<deployment-name>" --id <schedule-id>
  prefect deployment schedule delete "<flow-name>/<deployment-name>" --id <schedule-id>
- Docs: Schedules concepts and Create schedules for deployments If you share how you’re managing schedules today (UI vs CLI vs code) and what kind of code changes you anticipate (parameter renames, new required params, etc.), I can suggest a concrete migration plan.
s
@Marvin If my current code is deployed and if I made changes to git code file which deployment uses. How to make the deployment to use the latest git code and does it affect current schedules of the deployment
m
thought for 173.8 seconds
Great question. In Prefect 3.x you have two common ways to make a deployment use new Git code, and neither will delete or pause your existing schedules. How to point a deployment at new code - Track a branch (always pull latest) - Configure your deployment’s source to a branch (e.g., main) instead of a commit. Each run will pull the latest commit from that branch at runtime. - Example (Python):
Copy code
from prefect import flow
    from prefect.storage import GitRepository

    @flow
    def my_flow(): ...

    my_flow.from_source(
        GitRepository(
            url="<https://github.com/org/repo>",
            branch="main",        # floating branch = latest
            # commit_sha=None     # leave unset
        ),
        entrypoint="flows/my_flow.py:my_flow",
    ).deploy(name="my-deployment", work_pool_name="my-pool")
- Example (prefect.yaml):
Copy code
deployments:
    - name: my-deployment
      entrypoint: flows/my_flow.py:my_flow
      source:
        git:
          url: <https://github.com/org/repo>
          branch: main
- With this setup, you do not need to redeploy after every commit; future runs will pick up the latest on that branch. - Pin to a commit (immutable, reproducible) - If your deployment is pinned to a specific
commit_sha
, you’ll need to update it after you push new code: - Update the commit in code (Python or prefect.yaml as above) and run
prefect deploy
again, or - Edit the deployment in the UI to point to the new commit SHA and save. - This gives deterministic rollbacks and reproducibility. Does this affect existing schedules? - No. Updating the deployment’s source/commit does not remove or pause schedules. They continue to trigger runs for that deployment. - Caveat: if your code change breaks the flow’s parameter schema or entrypoint path, scheduled runs may fail at runtime. Keep parameter names backward compatible or phase changes carefully. Related docs - Schedules: Schedules concepts - Creating schedules: Create schedules for deployments - prefect.yaml and source config: prefect.yaml guide If you share how your current deployment is configured (prefect.yaml vs Python
from_source
, branch vs commit), I can give exact steps to switch to “latest” or update the commit safely.
s
@Marvin which are your competitors or alternatives
m
thought for 31.8 seconds
There are a few common categories of “alternatives” to Prefect, depending on how you like to build and run workflows: - Python-first workflow orchestrators - Apache Airflow – mature, DAG-based, heavy on configuration; huge ecosystem and community - Dagster – modern Python orchestrator with strong typing, software-defined assets - Luigi – older Python orchestrator; simple but less feature-rich - Kubernetes-native orchestrators - Argo Workflows – k8s CRD/workflow engine; container-per-step; YAML-first - Flyte – k8s-native, strongly typed tasks, caching, ML friendly - Tekton – CI/CD pipelines on k8s; can be used for workflows - Kubeflow Pipelines – ML-focused pipelines on k8s - Durable workflow engines - Temporal – code-as-workflows with durable execution (Java/Go/TypeScript/Python) - Netflix Conductor – microservice orchestration, JSON/YAML + code - Cadence – Temporal’s predecessor from Uber - Cloud-managed orchestrators/integration - AWS Step Functions – serverless state machines; deep AWS integrations - AWS MWAA / GCP Cloud Composer – managed Airflow - Azure Data Factory – low-code pipelines, strong data connectors - Google Workflows – serverless orchestration for GCP services - Data integration/ELT tools with schedulers - Airbyte, Fivetran, Stitch – managed connectors and syncs (less general-purpose orchestration) - Stream/batch dataflow tools with orchestration features - Apache NiFi – flow-based, drag-and-drop for data movement/streaming - Enterprise job schedulers - Control-M, Redwood RunMyJobs, Rundeck – cross-platform enterprise scheduling/orchestration If you share a bit about your stack (cloud vs on-prem/k8s, Python vs polyglot, batch vs streaming, managed vs self-hosted, compliance constraints), I can narrow this to a short, opinionated shortlist tailored to your needs.
s
@Marvin my use case i have to deploy python jobs from nextjs app on different hosts, monitor and control jobs from ui.
m
thought for 225.7 seconds
Got it. Prefect 3.x fits this well. Here’s a practical pattern to deploy Python jobs from a Next.js app, run them on specific hosts, and monitor/control them from your UI. Recommended architecture - One or more work pools in Prefect Cloud/Server - A worker process running on each host where jobs should execute - Your Python flows packaged in a Git repo (or container); create deployments that point to that source - Your Next.js app (server-side) uses a Prefect service account API key to call the Prefect REST API to: - trigger runs of deployments - list runs for monitoring - cancel runs Run jobs on different hosts - Host-agnostic (simplest): Put workers from all hosts in a single work pool. Any host can pick up the run. - Host-specific (pick a host per job): - Easiest/clean: Create one work pool per host and one deployment per host (e.g., my-flow@host-a, my-flow@host-b), each targeting the corresponding pool. Your Next.js app chooses which deployment to run. - Why: In Prefect 3.x, the target work pool is set on the deployment; it is not overridden per-run. Work queues can filter runs, but selection is still defined by the deployment, not at run time. Notes on the 20-deployment Starter cap: if host-specific selection is required and you have many hosts, this cap may be a constraint. If you can run host-agnostic, keep a single deployment per flow and one shared pool. Set up the hosts - Create a work pool per host (or one shared pool):
Copy code
prefect work-pool create "host-a-pool" --type process
  prefect work-pool create "host-b-pool" --type process
- Start a worker on each host:
Copy code
prefect worker start --pool host-a-pool
  prefect worker start --pool host-b-pool
- Docs/background: Work pools and workers and Upgrade to workers Create deployments from Git - Track a branch (always latest) or pin to a commit for reproducibility. Example (Python):
Copy code
from prefect import flow
  from prefect.storage import GitRepository

  @flow
  def my_flow(param: str = "hello"):
      ...

  my_flow.from_source(
      GitRepository(
          url="<https://github.com/org/repo>",
          branch="main",
      ),
      entrypoint="flows/my_flow.py:my_flow",
  ).deploy(name="my-flow@host-a", work_pool_name="host-a-pool")

  my_flow.from_source(
      GitRepository(
          url="<https://github.com/org/repo>",
          branch="main",
      ),
      entrypoint="flows/my_flow.py:my_flow",
  ).deploy(name="my-flow@host-b", work_pool_name="host-b-pool")
- Or with prefect.yaml, set
source.git.url
and
branch
and run
prefect deploy
. Trigger runs from Next.js (server-side) - Store a Prefect service account API key in Next.js server env (never expose to the browser). Service accounts: Service accounts - Create flow runs by calling the REST endpoint: - POST
/deployments/{deployment_id}/create_flow_run
- Docs: Create flow run from deployment Example Next.js API route to trigger a run ``` export default async function handler(req, res) { try { const { deploymentId, parameters } = JSON.parse(req.body); const resp = await fetch(
${process.env.PREFECT_API_URL}/deployments/${deploymentId}/create_flow_run
, { method: "POST", headers: { "Authorization":
Bearer ${process.env.PREFECT_API_KEY}
, "Content-Type": "application/json", }, body: JSON.stringify({ parameters: parameters ?? {}, // optional: name, tags, and scheduled start time // name: "run-from-nextjs", // tags: ["from-nextjs"], // state: { type: "SCHEDULED", state_details: { scheduled_time: new Date().toISOString() } } }), });
if (!resp.ok) { const errorText = await resp.text(); return res.status(resp.status).json({ error: errorText }); } const data = await resp.json(); // includes flow_run_id return res.status(200).json(data); } catch (e) { return res.status(500).json({ error: String(e) }); } }
Copy code
Monitor runs in your UI
- List runs (filter by deployment, state, time) via REST:
  - GET `/flow-runs` with filters
  - Docs: <https://docs-3.prefect.io/v3/advanced/api-client|API client overview> (REST endpoints are linked from here)
- Deep link to Prefect UI for a specific run for rich logs/debugging.
- Optionally poll run status or build a small background job to sync statuses into your own DB for dashboards.

Control runs (cancel)
- Cancel a run from your Next.js backend by setting the run state to Cancelled (REST endpoint documented under flow runs state management).
- You can also expose buttons in your UI that call your Next.js API route to cancel a run.
- CLI for local testing:
prefect deployment run "<flow>/<deployment>" --param key=value ``` Help:
prefect deployment run --help
Putting it together - If you need strict host selection: - One deployment per host (my-flow@host-a, my-flow@host-b), each targeting a different pool. - Your Next.js backend chooses which deployment ID to run. - If host agnostic is OK: - One deployment and one shared pool with workers on each host. Runs will land wherever capacity exists. Open questions to tailor this for you - Do you need to target a specific host per job, or can runs execute on any available host? - Roughly how many hosts and distinct flows will you manage? If many hosts, we can discuss patterns to stay within the 20-deployment limit. - Are you comfortable tracking the latest Git branch for rapid iteration, or do you need pinned commits/releases for reproducibility? References - Create flow run from deployment (REST): API reference - Service accounts: Service accounts - Work pools and workers: Background article - Prefect API client overview: API client
s
@Marvin can I use onpremise prefect in production
m
thought for 43.5 seconds
Yes. Prefect 3.x Server (self‑hosted) is production‑ready and widely used on-prem. You run and operate the Prefect API, UI, and Postgres yourself; workers run wherever you need them (VMs, k8s, etc.). The tradeoff vs Prefect Cloud is you manage upgrades, scaling, backups, and auth/SSO yourself. What a typical production on‑prem setup looks like - Core services: Prefect API + UI, backed by PostgreSQL - Execution: One or more work pools; workers on your compute (k8s, VMs, on-prem containers) - Networking: Ingress/load balancer in front of API/UI, TLS termination - Observability: Centralized logs/metrics; optionally forward worker logs to your system - Backups/DR: Regular backups of the Postgres database and any external result storage you use Recommended deployment options - Docker Compose (quick start, single node) – good for small/medium teams - Kubernetes (Helm) – better for HA/scale: multiple API/UI replicas, managed Postgres, autoscaling workers High availability and scaling - API/UI: run multiple replicas behind a load balancer; use a managed or HA Postgres - Workers: horizontally scale by adding workers per work pool; enforce concurrency limits per pool/queue - Storage: store code in Git or container images; store results/artifacts in your object store or NFS Key operational considerations - Database: use Postgres with required extensions (e.g., pg_trgm); set up backups and monitoring - Upgrades: plan rolling upgrades of Server and workers; pin client versions in flows if needed - Auth/Access: manage your own SSO/reverse proxy; rotate service account tokens - Networking: egress from workers to reach your Git/image registry and the Prefect API - Security: follow least-privilege for service accounts; lock down the API/UI behind your perimeter Docs to get started - Server concepts: Self-hosted Server overview - Self-hosted guides: Self-hosted deployment guides - Work pools/workers: Work pools and workers background If you share your environment (k8s vs VMs, preferred database, expected scale, SSO needs), I can outline an opinionated, production-ready reference architecture and sizing assumptions.
s
@Marvin how you are currently architectured. Are you referring RAG as a tool or any other way you are able to answer prefect specific questions
m
thought for 34.4 seconds
Great question! Short answer: I’m a tool-augmented LLM, and yes—my workflow is RAG-like. I combine a language model with targeted tools that retrieve and verify Prefect-specific information from official sources before I answer. Here’s how I’m architected to help with Prefect: - Core model + retrieval - I start with built-in knowledge, but I use retrieval to confirm details and pull up-to-date info from official sources. - Primary sources I consult and link back to: - Prefect docs - Prefect GitHub repo (issues, PRs, code) - GitHub Discussions - Release notes - Tools I use (RAG + verification) - Research agent: Deep-dives a topic across docs and GitHub and synthesizes findings. I use this when questions are nuanced or version-specific. - GitHub search: Finds relevant issues/discussions so I can reference prior art and known bugs. - API verification: Introspects Prefect’s public API to confirm class and function signatures before suggesting code. - CLI verification: I run
prefect ... --help
(with optional extras via
uv run --with 'prefect[<extra>]'
) to ensure commands and flags I suggest actually exist. - Release notes: I can fetch the latest changes when behavior differs across versions. - Lightweight memory: I can store/delete helpful facts about your environment on request to tailor guidance. - Defaults and guardrails - I assume Prefect 3.x unless you tell me otherwise, and I avoid deprecated 2.x patterns (for example, I won’t suggest
Deployment.build_from_flow()
or
prefect deployment build
in 3.x). - I include links to sources I used so you can verify or go deeper. - If I can’t find a definitive answer, I’ll say so and ask for more info rather than guess. What this means in practice: - For CLI questions, I validate with
--help
before recommending syntax. - For code, I check available APIs and signatures before sharing examples. - For behavior or bugs, I search open/closed issues and discussions and link the most relevant threads. If it helps, I can demo this on a concrete ask (e.g., “What’s the correct way to deploy a flow from GitHub in Prefect 3?”) and show the verification steps and sources I’d use. Would you like me to walk through an example?