FastAPI Serve - FastAPI to the Cloud, Batteries Included!
Project description
FastAPI-Serve: FastAPI to the Cloud, Batteries Included! ☁️🔋🚀
Welcome to fastapi-serve, a framework designed to take the pain out of deploying your local FastAPI applications to the cloud. Built using our open-source framework Jina, fastapi-serve
offers out-of-the-box support for automated deployments on cloud.jina.ai
, our scalable and robust cloud platform. 🌩️
Features 😍
- 🌐 DNS: Automatic URL generation for your app.
- 🔗 Protocols: Full compatibility with HTTP, WebSocket, and GraphQL.
- ↕️ Scaling: Scale your app manuallly or let it auto-scale based on RPS, CPU, and Memory.
- 🗝️ Secrets: Secure handling of secrets and environment variables.
- 🎛️ Hardware: Tailor your deployment to suit specific needs.
- 💾 Storage: Persistent and secure network storage.
- 🔎 Observability: Integrated access to logs, metrics, and traces.
- 📦 Containerization: Effortless containerization of your Python codebase with our integrated registry.
Getting Started 💡
First, install the fastapi-serve
package using pip:
pip install fastapi-serve
Then, simply use the fastapi-serve
command to deploy your FastAPI application:
fastapi-serve deploy jcloud app:app
You can also specify the name of your app:
fastapi-serve deploy jcloud app:app --name my-app
You'll get a URL to access your newly deployed application along with the Swagger UI.
Examples 📚
- Follow our Quickstart Guide to deploy a simple FastAPI application.
fastapi-serve CLI 🖥️
fastapi-serve
comes with a simple CLI that allows you to deploy your FastAPI applications to the cloud with ease.
Description | Command |
---|---|
Deploy your app locally | fastapi-serve deploy local app:app |
Deploy your app on JCloud | fastapi-serve deploy jcloud app:app |
Update existing app on JCloud | fastapi-serve deploy jcloud app:app --app-id <app-id> |
Get app status on JCloud | fastapi-serve status <app-id> |
List all apps on JCloud | fastapi-serve list |
Remove app on JCloud | fastapi-serve remove <app-id> |
💡 JCloud Deployment
⚙️ Configurations
For JCloud deployment, you can configure your application infrastructure by providing a YAML configuration file using the --config
option. The supported configurations are:
- Instance type (
instance
), as defined by Jina AI Cloud. - Minimum number of replicas for your application (
autoscale_min
). Setting it 0 enables serverless. - Disk size (
disk_size
), in GB. The default value is 1 GB.
For example:
instance: C4
autoscale_min: 0
disk_size: 1.5G
You can alternatively include a jcloud.yaml
file in your application directory with the desired configurations. However, please note that if the --config
option is explicitly used in the command line interface, the local jcloud.yaml file will be disregarded. The command line provided configuration file will take precedence.
If you don't provide a configuration file or a specific configuration isn't specified, the following default settings will be applied:
instance: C3
autoscale_min: 1
disk_size: 1G
💰 Pricing
Applications hosted on JCloud are priced in two categories:
Base credits
- Base credits are charged to ensure high availability for your application by maintaining at least one instance running continuously, ready to handle incoming requests. If you wish to stop the serving application, you can either remove the app completely or put it on pause, the latter allows you to resume the app serving based on persisted configurations (refer to
lc-serve
CLI section for more information). Both options will halt the consumption of credits. - Actual credits charged for base credits are calculated based on the instance type as defined by Jina AI Cloud.
- By default, instance type
C3
is used with a minimum of 1 instance and Amazon EFS disk of size 1G, which means that if your application is served on JCloud, you will be charged ~10 credits per hour. - You can change the instance type and the minimum number of instances by providing a YAML configuration file using the
--config
option. For example, if you want to use instance typeC4
with a minimum of 0 replicas, and 2G EFS disk, you can provide the following configuration file:instance: C4 autoscale_min: 0 disk_size: 2G
Serving credits
- Serving credits are charged when your application is actively serving incoming requests.
- Actual credits charged for serving credits are calculated based on the credits for the instance type multiplied by the duration for which your application serves requests.
- You are charged for each second your application is serving requests.
Total credits charged = Base credits + Serving credits. (Jina AI Cloud defines each credit as €0.005)
Examples
Example 1
Consider an HTTP application that has served requests for 10
minutes in the last hour and uses a custom config:
instance: C4
autoscale_min: 0
disk_size: 2G
Total credits per hour charged would be 3.33
. The calculation is as follows:
C4 instance has an hourly credit rate of 20.
EFS has hourly credit rate of 0.104 per GB.
Base credits = 0 + 2 * 0.104 = 0.208 (since `autoscale_min` is 0)
Serving credits = 20 * 10/60 = 3.33
Total credits per hour = 0.208 + 3.33 = 3.538
Example 2
Consider a WebSocket application that had active connections for 20 minutes in the last hour and uses the default configuration.
instance: C3
autoscale_min: 1
disk_size: 1G
Total credits per hour charged would be 13.33
. The calculation is as follows:
C3 instance has an hourly credit rate of 10.
EFS has hourly credit rate of 0.104 per GB.
Base credits = 10 + 1 * 0.104 = 10.104 (since `autoscale_min` is 1)
Serving credits = 10 * 20/60 = 3.33
Total credits per hour = 10.104 + 3.33 = 13.434
Support 💪
If you encounter any problems or have questions, feel free to open an issue on the GitHub repository or reach out to us directly at support@jina.ai.
Our Cloud Platform 🌐
cloud.jina.ai
is our robust and scalable cloud platform designed to run your FastAPI applications with minimum hassle and maximum efficiency. With features like auto-scaling, integrated observability, and automated containerization, it provides a seamless and worry-free deployment experience.
fastapi-serve
is more than just a deployment tool, it's a bridge that connects your local development environment with our powerful cloud infrastructure. Start using fastapi-serve
today, and experience the joy of effortless deployments! 🎊
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Hashes for fastapi-serve-0.0.2.dev12.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | b332516fd30079970e333df9a1b9f29eb92dd8be612058667871dfbac2b7051b |
|
MD5 | bcda6e0e25b4757243e86138a2004e51 |
|
BLAKE2b-256 | 2dd58be2b6063e4500317e1bafd3386c5096d7f147b9468d68a4fed0c48f5039 |