---
id: architecture-runtime
title: "Running flows"
summary: "How a flow is compiled and run - generated types, in-process calls between components, scripting engines, hosting strategies and the ways flows call each other."
audience: user
keywords: "runtime, compilation, roslyn, assembly, memorypack, hosting strategy, private host, tag based host, shared host, flow to flow, scripting, python, javascript, csharp"
---
# Running flows

When you start a flow, its Controller hands it to a Host. The Host turns the flow into a .NET assembly, loads it and
calls its start pins. From then on, records pass from component to component as method calls inside that process.

## Compilation

1. **Types become classes.** Every type the flow uses is generated as a C# class, together with its JSON
   serialization code.
2. **The flow becomes code.** The components, their configuration and the connections between them are generated
   as C#, and so are the bindings in configuration fields. C# script components are part of the same code.
3. **Roslyn compiles it.** The result is one assembly per flow, loaded into its own isolated load context, so a flow
   is replaced or unloaded without touching the other flows in the Host.

A mistake in a script, a binding or a type mapping stops the flow at compilation with the component and the error,
before any record is processed.

## Execution

A component receives a record on an input pin, does its work and passes its result to an output pin. The record
reaches the next component through a direct call, in the same process: there is no bus and no serialization between
components. Records are serialized only where they leave the flow, for example to the data monitor, to a log entry
or to another system.

Components can work synchronously or asynchronously. Listener components (Http listener, Kafka consumer, TCP server)
process requests concurrently; [Fork](/documentation/plugins/flow/fork-plugin), the queue plugins and
[Scatter](/documentation/plugins/flow/scatter) / [Gather](/documentation/plugins/flow/gather) move work to other threads or
split and join it.

How a flow starts, stays alive and stops is described in [Concepts](/documentation/overview/concepts#starting-and-stopping).

## Scripting engines

| Language | Component | Runs as |
|---|---|---|
| C# | [C# script](/documentation/plugins/scripting/csharp-script), [C# shared script](/documentation/plugins/scripting/csharp-shared-script) | Compiled into the flow's assembly, at the speed of the rest of the flow. |
| Python | [Python script](/documentation/plugins/scripting/python-script) | CPython 3.11 or newer (3.12 by default), embedded in the Host. Packages installed into that Python are available to the script. |
| JavaScript | [JavaScript script](/documentation/plugins/scripting/java-script-script) | The V8 engine, embedded in the Host. |

All three see the same flow services: logging, storage, assets, repository access and batches, under the same names.

## Hosting strategies

Each flow has a hosting strategy that decides which Host process it runs in.

| Strategy | Runs the flow | Use it for |
|---|---|---|
| **Private host** | in a process of its own | Flows that must be isolated: a crash, a memory leak in a library or a restart affects that flow only. |
| **Tag based host** | in one process with the other flows of the same hosting tag | Groups of related flows. They share memory and can share listener ports, so many small flows stay cheap. |
| **Shared host** | in one process with all the environment's shared-host flows | Development, debugging and small installations. About 100 flows fit into a container with 1 GB of memory. |

You change a flow's strategy in its settings; the next start uses the new one.

## Flows calling flows

| Need | Use |
|---|---|
| Reuse a flow as a component, with a request and a response | [Publish it as a plugin](/documentation/plugins/flow/entry-point) and place it in other flows. |
| Start another flow | [Start flow](/documentation/plugins/flow/start-flow), optionally waiting until it finishes. |
| Send records to a long-running flow | [Pipe client](/documentation/plugins/pipes/port-client) and [Pipe listener](/documentation/plugins/pipes/port-listener). |
| Call a flow from outside Viaducta | [Webhook receiver](/documentation/plugins/web/webhook-receiver), [Rest handler](/documentation/plugins/web/rest-api-listener), [Http listener](/documentation/plugins/web/http-listener), [SOAP handler](/documentation/plugins/web/soap-handler), or TCP, UDP and WebSocket listeners. |

[Sync call](/documentation/plugins/flow/sync-call) orders the steps inside one flow; it does not call another flow.
