Once you’ve finished using
modal run or
modal serve to iterate on your Modal
code, it’s time to deploy. A Modal deployment creates and then persists an
application and its objects, providing the following benefits:
- Repeated application function executions will be grouped under the deployment, aiding observability and usage tracking. Programmatically triggering lots of ephemeral app runs can clutter your web and CLI interfaces.
- Function calls are much faster because deployed functions are persistent and reused, not created on-demand by calls. Learn how to trigger deployed functions in Invoking deployed functions.
- Scheduled functions will continue scheduling separate from any local iteration you do, and will notify you on failure.
- Web endpoints keep running when you close your laptop, and their URL address matches the deployment name.
Deployments are created using the
modal deploy command.
% modal deploy whisper_pod_transcriber.main
✓ Initialized. View app page at https://modal.com/apps/ap-PYc2Tb7JrkskFUI8U5w0KG.
✓ Created objects.
├── 🔨 Created populate_podcast_metadata.
├── 🔨 Mounted /home/ubuntu/whisper_pod_transcriber at /root/whisper_pod_transcriber
├── 🔨 Created fastapi_app => https://modal-labs-whisper-pod-transcriber-fastapi-app.modal.run
├── 🔨 Mounted /home/ubuntu/whisper_pod_transcriber/whisper_frontend/dist at /assets
├── 🔨 Created search_podcast.
├── 🔨 Created refresh_index.
├── 🔨 Created transcribe_segment.
├── 🔨 Created transcribe_episode..
└── 🔨 Created fetch_episodes.
✓ App deployed! 🎉
View Deployment: https://modal.com/apps/modal-labs/whisper-pod-transcriber
Running this command on an existing deployment will redeploy the app, incrementing its version. For detail on how live deployed apps transition between versions, see the Updating deployments section.
Deployments can also be created using Modal’s client library.
A deployment can deploy new apps or redeploy new versions of an existing deployed app. It’s useful to understand how Modal handles the transition between versions of running deployment. Modal deployments only take a few seconds, but we still ensure things run smoothly in this short deployment period.
A running deployed app will continue running and accepting requests while a deployment is happening. Existing function executions will also keep running. They will not be terminated by the deployment because they’re outdated.
However, any existing container running the old version of the app will be marked by Modal as outdated and will become ineligible to serve new requests. These outdated containers will become idle and gracefully terminate.
Any warm pool containers will also be cycled during a deployment, as the previous version’s warm pool are now outdated.
Deployed apps can be stopped in the web UI by clicking the red delete button on
the deployment’s app page, or alternatively by using the
modal app stop command.
Stopped deployments are eventually garbage collected.