Preliminaries#

This chapter introduces the basic terminology and concepts you will encounter in the docs. But first, look at the code below:

from jina import DocumentArray, Executor, Flow, requests


class FooExec(Executor):
    @requests
    async def add_text(self, docs: DocumentArray, **kwargs):
        for d in docs:
            d.text += 'hello, world!'


class BarExec(Executor):
    @requests
    async def add_text(self, docs: DocumentArray, **kwargs):
        for d in docs:
            d.text += 'goodbye!'


f = Flow(port=12345).add(uses=FooExec, replicas=3).add(uses=BarExec, replicas=2)

with f:
    f.block()
from jina import Client, DocumentArray

c = Client(port=12345)
r = c.post('/', DocumentArray.empty(2))
print(r.texts)

Running it gives you:

['hello, world!goodbye!', 'hello, world!goodbye!']

Architecture#

This animation shows what’s happening behind the scenes when running the previous example:

../../_images/arch-overview.svg

Hint

GRPC, WebSocket, HTTP are network protocols for transmitting data. gRPC is always used for communication between Gateway and Executor.

Hint

TLS is a security protocol to facilitate privacy and data security for communications over the Internet. The communication between Client and Gateway is protected by TLS.

Jina as an MLOPs framework is structured in two main layers that together with DocArray data structure and Jina Python Client complete the framework, all of them are covered in the user guide and contains the following concepts:

DocArray data structure#
Data structures coming from DocArray are the basic fundamental data structure in Jina.#
- Document#

Document is the basic object for representing multimodal data. More information can be found in DocArray’s Docs.

- DocumentArray#

DocumentArray is a list-like container of multiple Documents. It is the essential element of IO in Jina services. More information can be found in DocArray’s Docs.

Serving#
This layer contains all the objects and concepts that are used to actually serve the logic and receive and respond to queries. These components are designed to be used#
as microservices ready to be containerized. #
These components can be orchestrated by Jina’s orchestration layer or by other container orchestration frameworks such as Kubernetes or Docker Compose.#
- Executor#

Executor is a Python class that can serve logic using DocumentArray. Loosely speaking, each Executor is a microservice.

- Gateway#

Gateway is the entrypoint of a Flow. It exposes multiple protocols for external communications; it routes all internal traffic.

Orchestration#
This layer contains the components making sure that the objects (especially the Executor) are deployed and scaled for serving.#
They wrap them to provide them the scalability and serving capabilities. They also provide easy translation to other orchestration#
frameworks (Kubernetes, Docker compose) to provide more advanced and production-ready settings. They can also be directly deployed to Jina AI Cloud#
with a single command line.#
- Deployment#

Deployment is a layer that orchestrates Executor. It can be used to serve an Executor as a standalone service or as part of a Flow. It encapsulates and abstracts internal replication and serving details.

- Flow#

Flow ties multiple Deploymentss together into a logic pipeline to achieve a more complex task. It orchestrates both Executors and the Gateway.

Client#
Client connects to a Gateway or Executor and sends/receives/streams data from it.#

Deployments on JCloud

At present, JCloud is only available for Flows. We are currently working on supporting Deployments.