Support concurrency for `@action` in the same process (scaling Action Server)
Issue by fabioz Thursday Feb 29, 2024 at 12:46 GMT Originally opened as https://github.com/robocorp/robocorp/issues/270
Target components
action_server
Why & who
Right now the Action Server creates a process where everything is scaled by the number of processes, so, it'll spawn a process to run one action and while that process is running that action, nothing else may be run in that same process.
This makes things simple, but also the maximum number of concurrent requests is based on the number of processes, which can be a heavyweight approach (as each new process needs its separate memory).
Feature or enhancement
The proposed approach would be allowing concurrent @action calls in the same process using threads.
Note: changes are required both in the action server as well as in the actions and logging (because a different log may have to be created for each thread).
Solution & alternative
- Why threads and not asyncio?
asyncio would be harder to implement because the logging does not do well with it at this point and everything, including the user code needs to be async for it to be performant (as a single slow action with asyncio stops all the other asyncio tasks running concurrently).