Modul 3: Flowy advanced
Module 3: Flowy advanced
Building on the foundations laid in Module 2, the advanced module focuses on the concepts and practices that turn a working Flowy setup into a robust, maintainable and scalable solution. Where the base training explained what the individual objects are and how to compose a first workflow, this module concentrates on how to do it well: modelling data with entities, integrating static resources, monitoring and optimising performance and structuring your system according to proven architectural and operational best practices.
Throughout this module we upgrade one example: the CreateOrder workflow you built in Module 2. It keeps its order of steps and its variables, such as $.order, $.customer and $.totalPrice, and gains an entity, parallel lookups, sub-processes and real error handling. Each chapter covers a part of it, and a short exercise after each topic links back to the Module 2 concept it builds on. The Practical Application chapter shows the techniques at work and ends with the finished workflow, which you can test end to end.
Entities
Entities are central to defining data structures and describing their interrelationships. In contrast to plain process variables, an entity gives you a first-class, versioned definition of your data model, together with the supporting objects needed to read and write it. This chapter covers the correct usage of entities, the generation of their persistence layer and related Flowy objects and how version control and lifecycle management apply to them.
Correct Usage
An entity should be used whenever you have structured, persistent data whose shape you want to define, validate and evolve in a controlled manner - for example customers, orders or products. Modelling such data as an entity, rather than manipulating ad-hoc records in individual steps, gives you a single source of truth for the structure and keeps validation and access logic consistent across every process that touches the data.
Flowy entities are technically compatible with a wide range of database systems, including Firebird, MariaDB, MySQL and PostgreSQL. Official support is currently limited to PostgreSQL and MySQL.
Generating Persistence and Flowy Objects
One of the main advantages of entities is that Flowy can generate the supporting infrastructure for you. Flowy supports generating the persistence layer adaptable to various target systems and can automatically create a standardized set of supporting resources that provide a ready-to-use CRUD interface while ensuring validation and logic consistency. These generated resources include:
- REST triggers - endpoints for the Create, Read, Update and Delete operations
- Processes - the workflows implementing each CRUD operation
- Validations - rules that guarantee the integrity of the data being persisted
The generated objects follow a consistent naming convention that combines the entity name, an optional namespace or scope identifier and a descriptive suffix. Generated objects are not editable.
Note
Regenerating resources for the same entity will overwrite any previously generated objects that share the same names. Keep custom logic in clearly separated objects.
Version Control and Lifecycle
Entities support version control both for the entity definitions themselves and for their persistence layers throughout their lifecycle. This allows precise tracking and management of any modification to the structure over time - you can see how a data model evolved, compare revisions and understand the impact of a change before rolling it out.
Managing an entity therefore becomes a lifecycle activity: define the structure, generate the persistence and supporting objects, evolve the definition as requirements change and rely on version control to keep the history traceable and the changes accountable.
Data-Level Access Control
Entity permissions operate on two independent levels. Resource permissions - View, Use and Edit - govern who may see or modify the entity definition, while a separate set of data permissions - Read, Create, Update and Delete - governs who may act on the records themselves. Assign both deliberately: the ability to execute a generated CRUD process does not by itself grant unrestricted access to the underlying data. Keeping the two levels distinct lets you, for example, allow a process to read entity data while reserving deletion for a narrow set of roles.
You can find more details about entities and other objects in the Flowy documentation.
The Order Entity
In Module 2, the hand-built validations OrderRequest and OrderItem checked the request. An order is structured, persistent data, so CreateOrder now relies on an entity instead: define Order with its customerId and an optional status, as the request doesn't send one, and OrderItem with its productId and quantity, related to Order. Then generate the persistence layer, REST triggers, processes and validations. This changes three things:
- The generated validation replaces
OrderRequestandOrderItemon thePOST /api/orderstrigger. Like them, it checks the data, not whether a record exists, so unknown customers and products are still detected by theNOT_FOUNDresponse code of the lookups. CreateOrderand its trigger stay your own objects. Generated objects are not editable, so the stock check and everything else specific to this shop stays inCreateOrder.- The generated REST triggers and processes give you the CRUD operations on orders without any further work. The example doesn't use them and doesn't save the order. Calling the generated process from
CreateOrderwith Execute Process is a possible extension.
Exercise: Create the Order and OrderItem entities and generate their objects. Compare the generated validation with the ones you built in Module 2, and try to edit it. Then link it to your REST trigger in place of OrderRequest and repeat the three requests of that exercise.
Static Resources
Static resources allow you to manage the assets used by your templates and rendered output centrally, rather than embedding them repeatedly. Flowy supports the following types of static resources:
- CSS
- Fonts
- JavaScript
- Images
Proper Integration and Use
Static resources are managed centrally and referenced from within templates. This keeps presentation assets in one place, avoids duplication and lets you update styling, fonts, or imagery in a single location that all consuming templates inherit. Typical use cases include applying corporate styling to generated PDFs, embedding logos and fonts in documents, or providing shared stylesheets across multiple templates.
Because static resources are shared, treat them like any other reusable object: group them into the relevant module, which also bundles them for export and reuse, and consider the impact of a change on every template that references them.
You can find more details about static resources in the Flowy documentation.
Styling the Invoice
The Invoice template from Module 2 is plain HTML. For production, it gets the corporate look from three kinds of static resources: the logo as an image, the stylesheet as CSS and the corporate typeface as a font. They stay out of the template itself, so updating the logo or the brand colours in one place updates every invoice, receipt or report that references them. CreateOrder doesn't change, as its PDF step still only names the template.
Exercise: Create a logo and a stylesheet as static resources. Create a module for your order workflow and add them to it. Then go through your plain Invoice template: what would you add to it for production, such as colours, a logo and a font? Which of that belongs in a static resource rather than in the template, and which of your other templates would inherit a change?
Composing and Orchestrating Processes
Module 2 introduced the individual control-flow steps in isolation. What turns a collection of steps into a robust, maintainable solution is how you compose them: extracting reusable logic into its own processes, choosing the right execution mode when one process calls another, running independent work in parallel and recovering gracefully when a step fails. This chapter covers the orchestration patterns that distinguish a production-grade Flowy system from a first working draft.
Reusable Sub-Processes with Execute Process
The Execute Process step calls another Flowy process as a sub-process, passing input variables to it and receiving its results back into the calling process's cache. This is the workflow-level counterpart to the Libraries advice in the Best Practices chapter: where a Library centralises reusable code, Execute Process centralises reusable workflow logic.
Whenever the same sequence of steps appears in more than one process - validating a customer record, rendering an invoice PDF, posting a notification to several channels - extract it into a dedicated process and call it via Execute Process rather than duplicating the steps. The benefits mirror those of any modular design: a single place to maintain and test the logic, smaller and more readable parent processes and a change that propagates everywhere the sub-process is used. Sub-processes also make large workflows comprehensible, because each parent reads as a short sequence of high-level operations rather than hundreds of low-level steps.
Keep the interface of a reusable process deliberate: define clearly which variables it expects as input and which it returns as output, so it behaves like a well-defined function that any process can call with confidence.
In the order workflow, CreateBackorder becomes such a process. In Module 2 it was a single REST step, but Module 3 needs a backorder in two places, as Protecting the Reservation shows. Its interface is small: it expects $.orderReference, which is the $.flowy.eventId of the order, and $.lines, and it returns $.backorderStatus.
Choosing an Execution Mode
When one process calls another, the execution mode determines whether the caller waits for the result, how the child is scheduled and whether the call is recorded. Execute Process offers four modes:
- Inline - the caller runs the sub-process synchronously within its own execution context and waits for it to finish before continuing, mapping the child's results back into its own cache. This is the default choice for ordinary synchronous composition: whenever the parent needs the sub-process's output in order to proceed - for example calling
CreateBackorderand then branching on$.backorderStatus- reach for Inline first. - Synchronous - the caller also waits for the result, but the child runs as a separate synchronous event rather than inside the parent's own execution. This gives the sub-process its own distinct execution entry while still blocking the parent until it completes.
- Asynchronous - the caller fires the sub-process as an independent child event and continues immediately without waiting (fire-and-forget). Use it when the work can proceed in the background and the parent does not need the result straight away, or when you intend to launch several sub-processes and join them later with a Wait step (see below). Record the identifier of each child event it creates, through its
childEventIdPathfield, so you can wait on it afterwards. - Embedded - like Inline, the child runs synchronously and the caller waits for its result, but this mode deliberately creates no execution log. Because it skips the overhead of persisting execution and cache data for the call, this yields a significant performance boost, which makes it well suited to hot paths and high-volume production workloads. The trade-off is that you lose the execution trace and cannot debug that call through the log and debug view, so reserve it for cases where the execution trace genuinely does not matter.
In Inline, Synchronous and Asynchronous mode, a failed child does not fail its parent. If a child ends as failed through an uncaught step exception, the Execute Process step still succeeds and the parent carries on, and a Try/Catch around it won't catch this. Handling Errors Gracefully below shows how to make such a failure visible.
These choices interact directly with the concurrency and priority settings discussed in the performance and architecture chapters - deciding which processes may run asynchronously is a deliberate architectural decision, not an afterthought.
As a quick reference, this is where each mode fits in the order workflow:
| Mode | Waits for the result? | Used in this example | Why |
|---|---|---|---|
| Inline | Yes | CreateBackorder | The parent needs it done before notifying |
| Embedded | Yes, no execution log | NormaliseItem in Example 2 | Less overhead on a hot path, but no trace |
| Synchronous | Yes, own execution | Not used in this example | The parent waits, the child has its own entry |
| Asynchronous | No, fire-and-forget | ERP, Billing, Shipping posts | Heavy work, joined later by Wait |
Exercise: Move the Create backorder step of your CreateOrder into a new process CreateBackorder, using $.orderReference in its body. Start the process with a Set Variables step that sets $.backorderStatus to failed, and set it to created if the response code is OK. Call it with an Inline Execute Process step that passes $.flowy.eventId as orderReference and $.lines, and maps $.backorderStatus back. Let the Switch below it check $.backorderStatus == 'created', and run the "Out of stock" and "Backorder failed" cases of the Module 2 tests.
Running Work in Parallel
The Execute Parallel Steps step runs several independent batches of steps concurrently within a single process, seeding each batch with its own input and merging every batch's results back into the process cache once all of them have finished. Each batch runs in its own thread, while the steps within a batch run one after the other. It is the right tool when a process must perform multiple operations that do not depend on one another - calling several external APIs, enriching a record from several data sources at once, or generating a set of documents - and you want the total time to be that of the slowest batch rather than the sum of them all.
Because the step waits for every batch before continuing, it acts as a synchronisation barrier: use it precisely when you genuinely need all the results together before the process can move on. Batches that share no data run cleanly in parallel; avoid having parallel batches write to the same cache variables, which reintroduces the ordering dependencies that parallelism is meant to remove.
In Module 2, the lookups ran one after the other, although the customer and the items don't depend on each other. CreateOrder now runs them as two batches: one loads the customer, the other holds the For Each with the price and stock lookups, as these are made per item. The notifications become two batches as well, email and SMS, as neither depends on the outcome of the other. Example 4 shows both.
Each batch writes its own variables, and that changes one detail. In Module 2, a failed item lookup set $.order.status. In Module 3 the items batch sets its own $.lookupStatus instead, which Start order sets to ok, and the check at the start of its For Each reads that variable.
A failed lookup stops the order as before, but only after the barrier, as a batch doesn't know how the other one is doing. So an unknown customer no longer saves the item lookups. One Switch Lookups OK? below the Execute Parallel Steps step replaces both Customer loaded? and the Lookups OK? of Module 2, and checks both batches: $.customerResponseCode == 'OK' && $.lookupStatus == 'ok'. All the remaining work stays in its first branch, and its else branch holds Mark order failed, so the process ends there. This covers every response code other than OK, including REQUEST_TIMEOUT: a failed stock lookup is never treated as out of stock.
Module 2 also warned that a REST step that throws leaves the response code of the previous record in place. Look up items closes that gap for the lookups: each pass starts with a Set Variables step that sets $.productResponseCode and $.stockResponseCode to none, so only a call that really succeeded can give OK.
Exercise: Move Load customer and Look up items of your CreateOrder into two batches of an Execute Parallel Steps step and make the changes above. Do the same with the SMTP and Twilio steps of each notification. Let your mock delay its answers and compare the runtime with the sequential version in the process log. Then run the "Unknown customer" and "Unknown product" cases of the Module 2 tests. Do the item lookups still run for the unknown customer?
Joining Asynchronous Work with the Wait Step
Parallelism can also span separate executions rather than batches within one process. When you launch sub-processes asynchronously with Execute Process - or fire an AI Agent step in its asynchronous mode - each call creates a child event that runs on its own and returns an identifier. The Wait step lets the parent pause until one or more of those child events have finished, then continue.
Wait only joins: it returns no child results, and the asynchronous mode ignores the output mapping. If the parent needs what a child produced, the child must save it to a database or through entities, and the parent reads it from there after the Wait step. The Storage step can't be used for this: it is keyed by process ID, so the parent can't see what the child writes.
The pattern is: fire several Execute Process steps in the asynchronous mode, collecting the child event identifiers into a cache variable, then place a Wait step that references those identifiers in its childEventIds field. The parent proceeds only once every awaited child has finished, and failed and timed-out children count as finished. A failed child does not fail its parent: the parent carries on, so it must check the child's persisted outcome itself. This gives you fan-out/fan-in concurrency across whole processes - useful when the work is heavy enough to warrant distinct executions (each with its own log and its own place in the execution queue) rather than in-process batches. The Wait step is governed by a polling interval (pollingIntervalMs) and a timeout (timeoutMs), so configure the timeout generously enough to cover the slowest child you expect, while still protecting the parent from waiting indefinitely on a child that never completes. If that timeout is reached, the Wait step itself throws a WaitStepTimeoutException.
Choose between the two concurrency mechanisms by scope: use Execute Parallel Steps for independent batches inside one process, and asynchronous Execute Process plus Wait when you want the concurrent work to run as separate executions that you later join.
In the order workflow, the three posts become this kind of fan-out once the invoice exists. Each is heavy enough to warrant its own execution, and the parent must know that all three worked before it marks the order as completed:
The parent runs its steps one after the other. Each Execute Process step only starts its child, passes it orderReference and writes the child event id to the variable shown, so the three children below the Groovy step have already been started by then, and run side by side. Groovy only builds the list from the three ids and doesn't wait for any child. The Wait step is the join.
The Wait step tells the parent nothing about how the children ended, so the parent reads their outcomes first. Each child saves its outcome to a database or through an entity, keyed by the order: the parent passes its $.flowy.eventId to every child as orderReference through the input mapping, together with $.lines and $.totalPrice. Example 3 shows such a child.
A child that failed early may have saved nothing, and one that hasn't finished when the timeout hits has no record yet, so a missing record counts as a failure. The flow only continues to the customer if all three records say the order was posted. As in Module 2, the yes branch also sets $.restResponse, and the else branch uses Mark order failed.
A failed post sets $.order.status to failed and notifies support instead of the customer, by email through the same SMTP step type and Mail credential as the customer notification, with a SupportNotice template of your own. The order isn't undone: an invoice has already been generated, the stock stays reserved and the other two systems may have the order. The example doesn't retry failed children, so the order stays failed until support has dealt with it.
Exercise: Create the table order_outcomes with the columns order_reference, target_system and outcome, and a JDBC credential for it. Build PostToERP as shown in Example 3, plus PostToBilling and PostToShipping in the same way. Their REST steps use $.orderReference in the body, as $.flowy.eventId would be the id of the child. Replace the three REST steps and the Switch in your CreateOrder with the flow above. Read the outcomes with SELECT target_system, outcome FROM order_outcomes WHERE order_reference = $.flowy.eventId. Run an order, read $.outcomes in the debug view and use what you see to write the condition of the all posted? Switch, so that only three posted records pass. Then let your mock answer ERP posts with a 503, and put it back to 200 afterwards. Finally, disable the JDBC step of PostToBilling. Does the parent treat the missing record as a failure?
Handling Errors Gracefully
Robust processes anticipate failure. The Try/Catch step wraps a block of steps so that, if any of them raises an exception, the remaining steps in the block are skipped and the failure is routed to a matching catch block. Each catch block can be scoped to particular exception types, letting you respond differently to, say, a database error than to a Wait step timeout - retrying, substituting a default, logging the problem or notifying an operator. An optional finally block runs whether or not an exception occurred, which makes it the natural place for cleanup such as releasing a resource or writing a closing audit entry. It doesn't run after a process interrupt or once the process timeout expires.
Catch order matters, as the first matching catch block wins: define the most specific exceptions first and the more generic ones later. To catch any exception, add exception to the exceptions list and define it last. It is case-insensitive and matches everything except a process interrupt. All other names must match exactly, including case, and a simple name doesn't match subclasses: to include them, use the fully qualified name, such as java.lang.RuntimeException. An exception with no matching catch block doesn't stop the process: Flowy continues with the next step after the Try/Catch, skipping the rest of the try block, so a failure can pass unnoticed if nothing catches it.
Use Try/Catch deliberately around the steps most likely to fail - external calls to databases or messaging systems, file handling and integrations - rather than blanketing an entire process in a single catch that obscures where things went wrong. Where a business rule itself makes an execution invalid, the Throw Exception step lets you raise an exception on purpose, carrying context values into the cache so the enclosing catch block can read them; this turns a domain condition ("order total exceeds the allowed limit") into a controlled, catchable event rather than a silent continuation. Throw Exception doesn't stop the process by itself: outside a try block, later steps keep running and the event ends as failed.
A failed REST call never reaches a catch block by itself. As Module 2 showed, the REST step writes HTTP errors and network failures to its target variables and finishes successfully. So check the response code explicitly after the call, and use Throw Exception if the failure should reach a catch block. REST only throws when it can't make the call, such as a malformed URL (java.net.MalformedURLException) or a missing credential. A wrong secret doesn't throw, it gives UNAUTHORIZED or FORBIDDEN. Add exception to the exceptions list to catch the calls that couldn't be made too.
A failed child doesn't reach a catch block in the parent either. To make the failure visible in Inline or Synchronous mode, catch the error in the child, write a status variable and map it through the output, then have the parent check it with an If step and use Throw Exception if needed.
CreateBackorder runs Inline and the customer is notified afterwards, so a failed backorder must not go unnoticed. The child therefore catches its own errors and writes $.backorderStatus, and the parent only treats created as a success:
CreateBackorder (input $.orderReference, $.lines; output $.backorderStatus)
→ Set Variables: $.backorderStatus = failed
→ Try
→ REST: Create backorder, response code → $.backorderResponseCode
→ If $.backorderResponseCode == 'OK'
→ Set Variables: $.backorderStatus = created
Catch (exception)
→ Log: the call could not be made
Some outcomes do reach the parent and can be caught there, for example a child process that isn't found, a timeout in Synchronous mode or a validation failure in Inline mode. A timeout in Inline mode instead ends the parent as timed out.
Together these patterns realise the Best Practices guidance to cover negative cases as well as positive ones: a process that validates its inputs, isolates risky work in Try/Catch and joins its concurrent work explicitly behaves predictably under the unexpected conditions that production inevitably produces.
Protecting the Reservation
The Module 2 workflow decides on stock in All in stock?, using the lookups. Between that lookup and the reservation, another order can buy the last units. The Switch then took the right decision on old data, and the reservation fails although the item looked available. If some items of the order are already reserved by then, they must be released, or that stock stays blocked.
So the reservation loop moves into a Try/Catch, which wraps the Warehouse call only, and its status check is no longer needed, as an exception ends the loop. The REST step won't throw by itself, so a response code check and Throw Exception follow it inside the try block. In our example, the Warehouse answers a 409 if the stock has gone, which gives the status name CONFLICT. That is the only code that means out of stock. Any other code than OK, such as SERVICE_UNAVAILABLE or REQUEST_TIMEOUT for no response at all, is a Warehouse failure and says nothing about the stock. A real Warehouse may use another status for this, so check its API.
Set Variables: $.releaseStatus = ok
Try
→ For Each $.lines
→ REST: Reserve stock, response code → $.reservationResponseCode
→ Switch
├─ $.reservationResponseCode == 'OK' → Groovy: add $.line to $.reservedItems
├─ $.reservationResponseCode == 'CONFLICT' → Throw Exception OUT_OF_STOCK, carrying $.line.productId
└─ else → Throw Exception WAREHOUSE_FAILED, carrying $.line.productId
Catch (OUT_OF_STOCK)
→ Mark order failed
→ Release reserved items
→ Execute Process (Inline) → CreateBackorder, passing orderReference and $.lines
← returns $.backorderStatus
→ If $.backorderStatus == 'created'
→ Mark order as backorder
Catch (WAREHOUSE_FAILED)
→ Mark order queued
→ Release reserved items
→ JDBC: write order to the retry queue
Catch (exception)
→ Mark order failed
→ Release reserved items
Finally
→ JDBC: write a closing audit entry with $.order.status and $.releaseStatus
Switch: All reserved?
├─ $.order.status == 'open' → PDF: Create invoice → … the remaining work
└─ $.order.status == 'backorder' → Notify customer
$.reservedItems is set to [] in Read order. The loop adds each item once the Warehouse has confirmed it, which is how the catch blocks know what to release. Release reserved items is a For Each over $.reservedItems with the record name $.reservedItem, holding a REST step that sends the item to #baseUrl/releases and an If step that sets $.releaseStatus to failed if $.releaseResponseCode isn't OK. A failed release isn't retried, and the audit entry is where support finds it. An item whose call gave REQUEST_TIMEOUT isn't in the list either, although that code doesn't tell you whether the Warehouse processed the reservation.
The three catch blocks are in the required order, with the exception catch-all last. It takes the calls that couldn't be made at all, which a retry wouldn't help. The names of the other two must match the Throw Exception steps exactly, including case: a Catch (Out_Of_Stock) would never fire, and the failure would end up in exception instead.
An exception only skips the remaining steps of the try block. After the catch block and the finally block, the flow continues with whatever follows the Try/Catch, so an invoice step placed directly below it would run for an out-of-stock order too. The order is therefore stopped as described in Stopping an Order: All reserved? stays below the Try/Catch and holds the remaining work, and each catch block changes $.order.status as its first step. The Module 2 else branch of All reserved?, Mark order failed, goes, as it would overwrite retryQueued and ACCEPTED, and a backorder condition is added. The status is still open only if the whole loop went through. In all other cases, the first branch doesn't run, and only an order that really went on backorder notifies the customer. A failed or retryQueued order matches neither branch, and as nothing follows the Switch, the process ends.
Mark order failed is the step from Module 2. Mark order as backorder sets $.order.status to backorder, $.restResponse.statusCode to OK and $.restResponse.body.text to Order placed on backorder. Mark order queued sets them to retryQueued, ACCEPTED and Order queued for retry. The Catch (OUT_OF_STOCK) block marks the order as failed first, so it stays failed if CreateBackorder doesn't report created, for whatever reason. If the Execute Process step itself fails, the next step in the catch block finds no created or doesn't run, and either way the status stays failed. Processing the retry queue is a separate job and not part of this example.
The Finally block writes the audit entry whichever way the block ended, with two exceptions: after a process interrupt or once the process timeout has expired, it doesn't run and no audit entry is written. A process interrupt skips the catch blocks too, so stock that is already reserved stays held. The docs don't say whether catch blocks run on a process timeout, so don't rely on them to release the stock in that case either.
Exercise: Add the Try/Catch shown in Handling Errors Gracefully to your CreateBackorder. Add a second product to your test systems, and POST /releases to the Warehouse, answering 200. Wrap Reserve items of your CreateOrder as shown above and order both products. Use Log steps in place of the JDBC steps for now. Let the second reservation answer with a 409, then with a 503. Compare it with the response code check in Stopping an Order: what does $.order.status hold in each case, what was released, and which steps ran after the Try/Catch?
Logging and Performance Monitoring
Logging and performance monitoring involve the tracking and recording of events and metrics during the operation of a Flowy process. Done well, they let you diagnose and debug issues, verify that a workflow behaves as intended and identify potential areas for optimisation. Module 2 introduced the individual log types; this chapter focuses on using them deliberately as a monitoring discipline.
Reviewing Logs for Insight
Flowy produces process logs, step logs and event logs. Together they describe the full lifecycle of an execution: which event triggered it, when and where it ran, the outcome and cache state of each step and any exceptions that occurred. The debug view - opened from a process or event log - overlays this execution data onto the actual process, making it straightforward to see which step succeeded, which failed and how data flowed between them.
Analysing Step Performance with the Optimizer
When step logs are enabled, Flowy offers an optimizer function directly within the process editor. It provides an easy way to see, for each step, the number of actual executions together with the average, minimum and maximum duration. Overlaying these real measurements onto the process is invaluable for analysing how a workflow actually behaves and performs: it gives a clear indication of where the bottlenecks are, so you can direct optimisation effort at the steps that genuinely dominate the runtime rather than guessing. Because it relies on step logs, it is most useful in development, testing and active troubleshooting - the same environments where detailed logging is worth its cost.
In CreateOrder, read the number of executions along with the duration: the steps inside Look up items and Reserve items run once per item, so a small delay there adds up on large orders.
Exercise: Enable step logs on CreateOrder in your development environment and run a few orders. Let your mock delay its price answers and open the optimizer. Does it point to Load price?
Monitoring Errors
Errors deserve dedicated attention. Configuring a Time to Live (TTL) for errors that keeps them available long enough for operations to review periodically is strongly recommended. Regularly reviewing errors is one of the most effective ways to spot recurring issues and to drive improvements in reliability and performance over time.
Balancing Observability and Cost
Detailed logging is invaluable during development and troubleshooting, but persisting logs and cache after every step has a cost. The guiding principle is to keep observability high where it helps you learn - development, testing and active debugging - and to reduce it in high-performance production scenarios where the overhead outweighs the benefit.
Performance and Scalability Optimisations
This chapter presents strategies and techniques to improve the efficiency and speed of Flowy processes. Several process-level configurations directly influence performance and scalability and monitoring and adjusting them throughout the lifetime of a process keeps the system running optimally.
Simultaneous Executions
Two parameters govern how many instances of a process may run concurrently:
- Max Simultaneous Executions Per Instance - the maximum number of active executions of a process on a single instance. This value must not exceed the overall maximum.
- Overall Max Simultaneous Executions - the maximum number of active executions across all connected instances. This value must be equal to or higher than the per-instance maximum.
Tuning these settings lets you make full use of available capacity while preventing process congestion and avoiding overload of downstream systems.
Note that Max Simultaneous Executions Per Instance is only effective up to the capacity of the instance itself. The real ceiling on concurrent work is the Max Processing Threads setting of the processing instance. Size the two together, and treat this value as workload-sensitive rather than a figure to maximise.
Choosing the Most Suitable Step
Before tuning concurrency, caching and logging, make sure each step is the right step for the job - the choice of step is often the single most impactful performance decision. Flowy ships with a large catalogue of purpose-built steps, each implemented and optimised natively for its task: parsing CSV, transforming XML or YAML, calling REST, querying a database, extracting text with OCR, rendering a PDF. Reaching for the most specific built-in step that matches your need is almost always faster - and more maintainable - than assembling the same behaviour by hand in a generic code step.
Reserve the scripting steps for logic that no built-in step covers. When custom code genuinely is required, Flowy offers three engines - Groovy, JavaScript and Python - and they do not perform equally. Prefer Groovy: it runs directly on the JVM and consistently outperforms the JavaScript and Python engines, which carry the overhead of a separate interpreter. Choose JavaScript or Python only when you have a concrete reason - an existing library, syntax you must reuse or a specific team skill - and, following the Best Practices guidance, centralise any such reusable code in a Library rather than duplicating it across individual code steps.
The order workflow follows this order of preference. Start order is a Set Variables step and the lookups are REST steps, not scripts. There is no built-in step for the total price, so it is a Groovy step. A returns process needs the same calculation, so instead of copying the script, keep it in a Library named OrderPricing and select that in the libraryName field of Calculate total.
Exercise: With step logs enabled, run a few orders and note the average duration of Start order in the optimizer. Temporarily replace it with a Groovy step that sets the same values, run a few orders and compare the two, then put Start order back. Next, go through the Groovy steps of your CreateOrder and decide for each one whether a built-in step is possible, it stays in the step, or it belongs in a Library. Why is your Calculate total step the Library candidate?
Cache Storage and Logging
Cache storage and logging are the settings with the most direct impact on throughput. When disabled at the process level, they take precedence over the same setting at the step level. For high-performance and production usage these should generally be disabled; they should be enabled on development environments and during troubleshooting to aid in identifying and resolving issues. Remember that cache is only persisted when logging is enabled.
Keeping the Cache Lean
The Process Cache is held in memory for the duration of an execution, so its size has a direct bearing on throughput and stability. Keep it as small as the workflow allows and stay within the recommended maximum. File-type variables - such as those produced by the FTP, IMAP, Image, PDF, S3 and ZIP steps - are never persisted to step logs, so they do not inflate log storage, but they do occupy cache while the process runs. For large payloads, prefer moving data out to Storage or an external store rather than carrying it through the whole process.
Time to Live (TTL)
TTL settings keep the underlying data stores lean, which in turn preserves performance and scalability:
- TTL for Logs - the maximum duration logs are retained, applied to events as well as process and step logs. A value of 0 disables cleaning and keeps logs indefinitely.
- TTL for Errors - the maximum duration errors are retained. It must be equal to or lower than the log TTL. A value of 0 halts dedicated error cleaning, although errors are still removed when their age matches the log TTL.
Optimisation Strategy
Optimisation is an ongoing activity rather than a one-off exercise. Regularly monitor execution metrics and error rates, adjust simultaneous-execution limits in line with real workload, disable non-essential logging and cache persistence in production and configure TTLs to match your data-retention requirements. Applied consistently, these techniques let a Flowy deployment scale predictably as demand grows.
Recommended Architecture
A recommended architecture outlines the structure and design of your Flowy system to ensure optimal performance, reliability and scalability. There is no single correct layout; the right design depends on the size and nature of your workloads, your business requirements and your IT resources and constraints. The principles below help you arrive at a sound structure.
Separate Configuration from Business Logic
Flowy draws a clear line between configuration data and business logic and your architecture should preserve it. Configuration data - such as credentials and settings - is expected to differ between environments, while business logic - triggers, processes, templates, translations, validations, libraries, plugins and modules - should remain identical as it moves from development to testing to production. Keeping the two separated means promoting a workflow between environments is primarily a matter of configuration and that production only ever runs code that has already been thoroughly tested.
Design for Scale and Resilience
Account for concurrency and resilience from the outset: set simultaneous-execution limits deliberately, decide which processes may run asynchronously and establish the maximum acceptable duration for long-running work. Two further process-level levers help a deployment stay responsive under load:
- Event priority - each event carries a priority from 1 to 128, settable at the trigger level, that controls its position in the execution queue. Lower numbers run first, so raising the priority means setting a lower number than the default of 64. A value of 20 on the
POST /api/orderstrigger, for example, lets orders jump ahead of routine background work when instances are busy, while leaving the default in place keeps ordinary work in fair order. It could also let new orders jump ahead of child events, so check thepriorityfield on your Execute Process steps. - Max processing duration - the ceiling after which an execution is stopped and marked as timed out. It is checked after every step, so it protects the platform from runaway executions that would otherwise tie up capacity indefinitely, but it can't end a single long-running step. It doesn't stop a hanging Warehouse call: the
timeoutfield of the REST step does, as Module 2 explains.Reserve stockthen finishes withREQUEST_TIMEOUT, which takes theWAREHOUSE_FAILEDpath.
Because Flowy provides load distribution, fault tolerance and automatic logging, an architecture that uses these capabilities intentionally - rather than relying on defaults - will remain reliable as workloads grow.
Exercise: Set a timeout on Reserve stock and let your mock delay its reservation answers for longer than that. Check that the order ends as retryQueued and not as backorder. Then set the priority on your REST trigger and find it on the event of the next order.
Organise with Modules
Group related objects into modules so that your architecture is not only performant but also comprehensible. Logical grouping simplifies export, import and sharing and keeps complex systems maintainable as they evolve.
Tag Objects by Cross-Cutting Concern
Modules and tags both group objects, but they exist for different purposes. A module is a packaging boundary geared towards export, import and sharing; an object can belong to no module, one or several. A tag is a lightweight label geared towards classification: it lets you mark any set of related objects by a concern that packaging does not follow - a customer, a project, a compliance area or a release - and one object can of course carry several tags. Because tags are orthogonal to modules, they let you slice your system along a dimension that module membership alone cannot express.
Tags earn their place on two fronts. In the Admin UI they make large systems navigable: filtering by a tag surfaces every object that shares a concern, however it is otherwise grouped. And because a tag is itself a first-class Flowy object with queryable usages, applications can resolve a tag at runtime - acting on "every object tagged orders" - so the same label that organises the Admin UI also drives behaviour in the solutions you build on top of Flowy.
Use modules and tags together: modules to decide what ships as a unit, tags to classify what belongs to the same concern across those units.
Automate Promotion Between Environments
Separating configuration from business logic pays off only if promoting that logic between environments is straightforward. Modules can be exported and imported manually through the Admin UI, which is convenient for occasional moves and for reviewing what a module contains before applying it. For repeatable, hands-off promotion, the Flowy command-line tool automates the same export and import of modules and resources, and can encrypt or decrypt sensitive configuration files along the way. Wiring it into a CI/CD pipeline turns environment promotion into a controlled, auditable step, so that production only ever receives logic that has already passed through testing.
Best Practices
Best practices provide guidelines and standards for designing, implementing and managing Flowy processes. They consolidate the lessons of the previous chapters into habits that keep a system correct, secure and maintainable.
- Build iteratively and test continuously - start with a small slice of functionality and grow it, verifying at each step. Cover both positive cases (the workflow does what it should under expected conditions) and negative cases (it handles errors and unexpected input gracefully).
- Apply the principle of least privilege - give each object only the permissions it needs to perform its function. Use the mass modification feature to review and adjust permissions efficiently across many objects at once.
- Use code steps judiciously, and prefer Groovy - the most specific built-in step is almost always faster and more maintainable than the same logic hand-written in a code step, so favour built-in steps wherever one fits. When custom scripting is unavoidable, prefer Groovy: it runs on the JVM and outperforms the JavaScript and Python engines. Reach for JavaScript or Python only for a concrete reason, and keep custom code modular, readable and well commented.
- Centralise shared code in Libraries - when custom logic is unavoidable, extract reusable JavaScript, Groovy or Python into Libraries rather than duplicating it across individual code steps. Libraries are synced automatically across the platform and give you a single, testable place to maintain shared logic, keeping your workflows DRY.
- Separate configuration from business logic - keep credentials and settings out of the process definition so the same logic runs unchanged across environments.
- Rely on version control - all Flowy objects except credentials are versioned. Use the history to trace changes, compare configurations, revert when needed and recover deleted objects. Enable history cleaning in production to keep the system lean.
- Tune logging and cache per environment - enable them for development and troubleshooting, disable them for high-performance production use and set TTLs that match your retention needs.
- Organise objects into modules - group related objects to improve modularity, reusability and maintainability and review your modules regularly to keep them logical and efficient.
- Tag objects by cross-cutting concern - use tags as a lightweight, many-to-many label that cuts across module boundaries, so you can filter related objects in the Admin UI and resolve them programmatically from your applications.
- Vet external code and modules - treat plugins and Hub modules from untrusted sources as a security risk and verify their authenticity before using them.
Exercise: Go through this list with your CreateOrder. Which test cases from Module 2 cover negative cases, and which object has more permissions than it needs?
The Module Hub and Its Usage
The Module Hub is a repository of reusable Flowy modules. Using it, you can speed up development, reduce duplication and leverage proven solutions built by others instead of reimplementing common functionality from scratch. This chapter explains how modules work and how to use the Hub responsibly.
Modules as Reusable Building Blocks
A module is a logical grouping of any combination of Flowy objects. Local modules let you cluster related objects together, which streamlines export and import, encourages reuse and even supports the automatic generation of Swagger files for the REST triggers they contain. Encapsulating related functionality into modules is the foundation on which Hub sharing builds.
Sharing and Retrieving through the Hub
The Module Hub extends local modules beyond individual usage by acting as a centralized repository. Users can upload their own modules to make them available to a broader audience and incorporate modules created by others into their own projects. Access to the Hub requires one or more credentials of the Flowy type, which act as the gateway for uploading modules to and downloading modules from, remote instances. This capability enables sharing both within an organization and across the wider Flowy community.
When a module is exported, the values of any credentials it contains are removed - only the credential shell (its name, type and roles) travels with the module. Sensitive values must be re-supplied in the target environment. This is by design and reinforces the separation of configuration from business logic described in the architecture chapter: a module carries the reusable logic, never the secrets.
Using the Hub Safely
Treat the Hub as you would any external dependency: prefer trusted sources, review a module's contents before adopting it and validate it in an isolated environment before promoting it toward production.
You can find more details about Module Hub Functionality in the Flowy documentation.
Exercise: Add all objects of the order workflow to a module and export it. Which values are missing from the Warehouse credential in the export?
Practical Application of Training
The chapters above introduced each advanced concept. The examples below apply them to the order workflow, so you can see when to reach for each execution mode, how the concurrency mechanisms differ in practice and how the optimizer and performance levers work as a monitoring-and-tuning loop. Every example names the concrete Flowy steps involved and shows how data moves through the Process Cache as $.variableName.
Example 1 - Inline Execute Process for synchronous composition
CreateOrder needs to know whether a backorder was really created before it tells the customer about it. The logic lives in its own reusable CreateBackorder process, as both All in stock? and the Catch (OUT_OF_STOCK) block use it.
CreateOrder
→ Execute Process (Inline) → CreateBackorder, passing orderReference and $.lines
← returns $.backorderStatus: created|failed
→ Switch $.backorderStatus == 'created'
├─ yes → Mark order as backorder → Notify customer
└─ else → Mark order failed
Inline is the correct mode here: the parent cannot proceed until it has the verdict, so it must wait, and it maps the child's $.backorderStatus straight back into its own cache.
The check is what makes the failure visible. A failed child does not fail its parent, so without $.backorderStatus the customer would be told about a backorder that doesn't exist.
Example 2 - Embedded Execute Process on a high-volume hot path
Suppose you add a small NormaliseItem process to Look up items, which maps the product code of the shop to the one of the Warehouse. It isn't part of the workflow in this module, but it shows the mode well. The parent needs the result immediately, like with Inline, but during a sale, thousands of orders each call it once per item, and the cost of persisting an execution log and cache snapshot for every single call becomes the bottleneck.
For Each $.order.items
→ Execute Process (Embedded) → NormaliseItem, passing $.item
← returns the normalised item, no execution log written
Embedded maps the result back like Inline, but writes no execution log, which removes the per-call overhead on the hot path at the price of the execution trace. A sound pattern is to develop and debug NormaliseItem with Inline (full logs), then switch to Embedded once it is proven and moving to production volume.
Example 3 - Asynchronous Execute Process + Wait for fan-out/fan-in
The parent side of this example is the flow in Joining Asynchronous Work with the Wait Step. Each Asynchronous call is fire-and-forget and returns a child event identifier, and the Wait step joins them, so the total time is that of the slowest post rather than their sum. The Groovy step between them builds the list that Wait needs, from the identifier each call wrote to its own variable.
If the Wait timeout is reached, Wait throws a WaitStepTimeoutException. It is the only step inside a Try/Catch, so the parent logs the timeout and continues to the outcome check, where a child that hasn't finished has no record yet.
The child side looks like this, and PostToBilling and PostToShipping follow the same pattern:
PostToERP (input $.orderReference, $.lines, $.totalPrice)
→ Set Variables: $.outcome = failed
→ REST: post the order to the ERP with $.orderReference, response code → $.erpResponseCode
→ If $.erpResponseCode == 'OK'
→ Set Variables: $.outcome = posted
→ JDBC: save $.outcome with ERP and $.orderReference to order_outcomes
A child has no output mapping in the asynchronous mode, as it is ignored, so the JDBC step is the only way back to the parent. The order reference comes in through the input mapping, so the parent can find the record by a key it already knows.
The child sets failed first, so the only way to posted is a call that returned OK. If the REST step throws, the child ends as failed, but its next steps still run and the record says failed. The parent counts only posted from all three children as a success, and with failed or no record, it takes the else branch. There is no outcome in between, so a failed status means what it says: something wasn't posted and support has to look at it.
Example 4 - Execute Parallel Steps for in-process concurrency
The lookups of CreateOrder and its notifications are batches of one process. They are individually lightweight, so they do not warrant separate executions.
Execute Parallel Steps
├─ Batch customer: REST: Load customer → $.customer, $.customerResponseCode
└─ Batch items: For Each $.order.items
→ If $.lookupStatus == 'ok'
→ Set Variables: reset both response codes to none
→ REST: Load price → $.product, $.productResponseCode
→ REST: Load stock → $.stock, $.stockResponseCode
→ Switch: both OK?
├─ yes → add to $.lines, set $.stockStatus if short
└─ else → Set Variables: $.lookupStatus = failed
(barrier: both batches merge back before the process continues)
→ Switch: Lookups OK?
Notify customer: Execute Parallel Steps
├─ Batch email: SMTP → $.customer.email
└─ Batch SMS: Twilio → $.customer.phone
Each batch has its own target variables: $.customer and $.customerResponseCode for one, $.lines, $.stockStatus and $.lookupStatus for the other. One batch per lookup wouldn't fit, as the price and stock lookups are made per item.
Example 5 - Try/Catch and Throw Exception for graceful failure
Protecting the Reservation wraps just the risky call, the Warehouse reservation with its response code check, rather than blanketing the whole process, so it stays clear where things went wrong. There is one order per run, so the catch blocks only decide what happens to this order. Throw Exception turns the business case "the stock has gone" into a catchable event and carries $.line.productId into the cache, through its cacheValues field, for the catch block to read.
Each failure takes its own way through the block, and the Switch below it decides what happens next:
| Reservation result | Catch block | $.order.status | How the order ends |
|---|---|---|---|
All OK | None | open | Invoice and posts follow |
CONFLICT, backorder created | OUT_OF_STOCK | backorder | Released, customer notified |
CONFLICT, anything else | OUT_OF_STOCK | failed | Released, customer not told |
Other code or REQUEST_TIMEOUT | WAREHOUSE_FAILED | retryQueued | Released, retry queue, customer not told |
| REST throws | exception | failed | Released, customer not told |
The finally block writes the audit entry in all of these rows. It is the natural home for this, as no row has to remember it.
Example 6 - The Optimizer as a tuning loop
CreateOrder runs correctly but orders take longer than expected. Rather than guessing, enable step logs in a testing environment and open the optimizer in the process editor.
Suppose the optimizer reveals that Load price in Example 4 averages 1.8 s while every other step is under 50 ms - it dominates the runtime. That measurement, not intuition, tells you where to act: cache the prices, or negotiate a faster endpoint. After the change, re-run and read the optimizer again to confirm the bottleneck is gone.
Example 7 - Promoting to production: the performance levers together
Once the process is correct and tuned, its move to production is primarily a matter of configuration - the business logic stays identical. The advanced settings from the performance and architecture chapters are set deliberately:
- Cache storage and logging - disabled at the process level for production throughput (in development they were enabled so the optimizer and debug view could work).
- Simultaneous executions - set Max Simultaneous Executions Per Instance in line with
Max Processing Threadson the instance, and Overall Max Simultaneous Executions equal to or above it, so a sale uses available capacity without overloading the Warehouse. - Event priority - raise the priority on the order trigger, which means a lower number, so orders jump ahead of routine background work when instances are busy.
- Max processing duration - set a ceiling so a runaway execution is stopped after its current step instead of tying up capacity. A stuck external call needs the REST step's
timeoutfield, as the ceiling can't end a running step. - TTL for logs and errors - configure a log TTL that matches your retention policy and an error TTL (equal to or lower than the log TTL) long enough for operations to review failures periodically.
Applied together, these levers let the same tested logic scale predictably. Optimisation is ongoing: keep watching execution metrics and error rates and revisit these values as the real workload evolves.
Final Workflow Overview
This is the Module 2 flow after all upgrades, in the same order. It is a summary, so the steps you built in the chapters above stay the reference for the details. Protecting the Reservation has the Set Variables: $.releaseStatus = ok step before the Try/Catch, and Joining Asynchronous Work with the Wait Step has the Groovy: collect the three ids step and the Try/Catch around Wait.
"Finish" is not a step: the branch has no steps left, and neither has the process. "Notify customer" is the Execute Parallel Steps step with the email and SMS batches. It exists as three copies: two with the BackorderNotice template, and one with OrderConfirmation and the invoice as an attachment.
Some things are deliberately left open. A failed child isn't retried, nothing in this module works through the retry queue, and only the reservation and backorder calls and the Wait step have a Try/Catch. If the write to the retry queue fails, the order stays retryQueued with nothing in the queue. As in Module 2, a failed PDF step doesn't stop the order. A try block around it, or a check of $.invoicePdf, is a good next step.
Although the customer only sees a single button, many Flowy objects cooperate behind it: a trigger and an event, entity-backed validation, parallel lookups with their credentials, a plugin and a Library, sub-processes joined by a Wait step, a Try/Catch around the riskiest call, a PDF with its static resources, and the logs and performance levers that keep it all predictable under load.
Test the Finished Workflow
Extend your test systems with a second product and with POST /releases on the Warehouse, answering 200. Next to order_outcomes, create the tables retry_queue with the columns order_reference and lines, and order_audit with the columns order_reference, status and release_status. The Log steps you used in Protecting the Reservation now become the JDBC steps. Then send orders as in Module 2 and check the results in the debug view:
| Case | Change | Expected result |
|---|---|---|
| In stock | None | completed, three posted records, email and SMS |
| Out of stock | "quantity": 10 | backorder, no reservation |
| Backorder failed | "quantity": 10, backorder 503 | failed, customer not told |
| Unknown customer | "customerId": 999 | failed with NOT_FOUND, item lookups still ran |
| Failed stock lookup | Answer stock lookups with a 503 | failed, not treated as out of stock |
| Sold out in the race | Two items, second reservation 409 | backorder, first item released, no invoice |
| Race, backorder fails | Same, and backorder 503 | failed, first item released, customer not told |
| Warehouse failure | Two items, second reservation 503 | retryQueued, first item released, no invoice |
| Warehouse silent | Delay reservations past timeout | retryQueued, REQUEST_TIMEOUT, not backorder |
| Call not possible | Reserve stock target URL host/api | failed through exception, not in the queue |
| Release failed | Second reservation 409, releases 503 | backorder, $.releaseStatus is failed |
| ERP failed | Answer ERP posts with a 503 | failed, support email, invoice generated |
| Missing outcome | PostToBilling without its JDBC step | failed, support email |
| Child too slow | Delay ERP posts past timeoutMs | failed, support email |

