...
For workflows that require handling multiple simultaneous tasks, such as a multi-threaded web server managing concurrent connections, parallel processing is a powerful technique to improve efficiency and scalability. This approach is only suitable for when the order in which messages are processed is not important.
In IguanaX, parallel processing within components is achieved using the component.clone
method to create multiple Lua instances (or threads) for processing. Messages can then be distributed across a pool of these threads with component.call
, which invokes the main()
function of the processing component and passes the data to be processed. Each thread processes messages independently, allowing for faster performance in high-throughput scenarios.
Let’s take a look at a simple example:
...
title | STEP 1: Add two custom components to your Iguana, name one "Dispatcher" and the other "Worker" |
---|
Expand | |||||||
---|---|---|---|---|---|---|---|
| |||||||
Typically, the
|
Expand | |||||
---|---|---|---|---|---|
| |||||
In the dispatcher, the data is prepared and component.call is used to call the For component.call to work, the target component must be running.
|
link Call a function within another Component
Multithreaded web service For an example use case, refer to the Web Service Multithreaded component.