Jina AI Cloud Hosting#
After building a Jina project, the next step is to deploy and host it on the cloud. Jina AI Cloud is Jina’s reliable, scalable and production-ready cloud-hosting solution that manages your project lifecycle without surprises or hidden development costs.
At present, Jina AI Cloud hosts all your Jina projects and offers computational/storage resources for free!
Jina AI Cloud provides a CLI that you can use via
jina cloud from the terminal (or
jcloud or simply
jc for minimalists.)
You can also install just the JCloud CLI without installing the Jina package.
pip install jcloud jc -h
If you installed the JCloud CLI individually, all of its commands fall under the
In case the command
jc is already occupied by another tool, use
jcloud instead. If your pip install doesn’t register bash commands for you, you can run
python -m jcloud -h.
For the rest of this section, we use
jcloud. But again they are interchangable with
In Jina’s idiom, a project is a Flow, which represents an end-to-end task such as indexing, searching or recommending. In this document, we use “project” and “Flow” interchangeably.
Flows have a maximum lifetime after which they are automatically deleted.
A Flow can have two types of file structure: a single YAML file or a project folder.
Single YAML file#
usesmust follow the format
jinaai+docker://<username>/MyExecutor(from Executor Hub) to avoid any local file dependencies:
# flow.yml jtype: Flow executors: - name: sentencizer uses: jinaai+docker://jina-ai/Sentencizer
jc deploy flow.yml
We recommend testing locally before deployment:
jina flow --uses flow.yml
The best practice of creating a JCloud project is to use:
This ensures the correct project structure accepted by JCloud.
Just like a regular Python project, you can have sub-folders of Executor implementations and a
flow.yml on the top-level to connect all Executors together.
You can create an example local project using
jc new hello. The default structure looks like:
hello/ ├── .env ├── executor1 │ ├── config.yml │ ├── executor.py │ └── requirements.txt └── flow.yml
hello/is your top-level project folder.
executor1directory has all Executor related code/configuration. You can read the best practices for file structures. Multiple Executor directories can be created.
flow.ymlYour Flow YAML.
.envAll environment variables used during deployment.
jc deploy hello
The Flow is successfully deployed when you see:
You will get a Flow ID, say
merry-magpie-82b9c0897f. This ID is required to manage, view logs and remove the Flow.
As this Flow is deployed with the default gRPC gateway (feel free to change it to
websocket), you can use
jina.Client to access it:
from jina import Client, Document print( Client(host='grpcs://merry-magpie-82b9c0897f.wolf.jina.ai').post( on='/', inputs=Document(text='hello') ) )
To get the status of a Flow:
jc status merry-magpie-82b9c0897f
Basic monitoring is provided to Flows deployed on Jina AI Cloud.
To access the Grafana-powered dashboard, first get the status of the Flow. The
Grafana Dashboard link is displayed at the bottom of the pane. Visit the URL to find basic metrics like ‘Number of Request Gateway Received’ and ‘Time elapsed between receiving a request and sending back the response’:
To list all of your “Serving” Flows:
You can also filter your Flows by passing a phase:
jc list --phase Deleted
Or see all Flows:
jc list --phase all
You can remove a single Flow, multiple Flows or even all Flows by passing different identifiers.
To remove a single Flow:
jc remove merry-magpie-82b9c0897f
To remove multiple Flows:
jc remove merry-magpie-82b9c0897f wondrous-kiwi-b02db6a066
To remove all Flows:
jc remove all
By default, removing multiple or all Flows is an interactive process where you must give confirmation before each Flow is deleted. To make it non-interactive, set the below environment variable before running the command:
You can update a Flow by providing an updated YAML.
To update a Flow:
jc update super-mustang-c6cf06bc5b flow.yml
Pause / Resume Flow#
You have the option to pause a Flow that is not currently in use but may be needed later. This will allow the Flow to be resumed later when it is needed again by using
To pause a Flow:
jc pause super-mustang-c6cf06bc5b
To resume a Flow:
jc resume super-mustang-c6cf06bc5b
Restart Flow, Executor or Gateway#
If you need to restart a Flow, there are two options: restart all Executors and the Gateway associated with the Flow, or selectively restart only a specific Executor or the Gateway.
To restart a Flow:
jc restart super-mustang-c6cf06bc5b
To restart the Gateway:
jc restart super-mustang-c6cf06bc5b --gateway
To restart an Executor:
jc restart super-mustang-c6cf06bc5b --executor executor0
Scale an Executor#
You can also manually scale any Executor.
jc scale good-martin-ca6bfdef84 --executor executor0 --replicas 2
JCloud scales according to your needs. You can demand different resources (GPU/RAM/CPU/storage/instance-capacity) based on the needs of your Flows and Executors. If you have specific resource requirements, please contact us on Slack or raise a GitHub issue.
Deployments are only supported in the
Each Executor is allocated a maximum of 4GB RAM, 2 CPU cores & 10GB of block storage.
Three Flows can be deployed at a time, out of which one Flow can use a GPU.
A maximum of two GPUs are allocated per Flow.
Flows with Executors using GPU are removed after 12 hours, whereas other Flows are removed after 72 hours.