I have a function that can handle 30 synchronous requests simultaneously. However, I’ve noticed that the worker function processes these requests sequentially, similar to a single thread handling multiple tasks by serving them partially. This method increases the total execution time and leads to uneven completion times for some calls. On the other hand, if I duplicate the same function across multiple deployments and distribute the calls among them, it could significantly reduce the execution time. In other words, creating multiple threads to handle the calls. However, this would involve duplicating the same function across multiple deployments. Is this second option the better choice?
Is there anything I can do to make the worker function execute as multi-threaded?
I attempted to double the _APP_WORKER_PER_CORE, but it didn’t result in any improvement. Any advice would be appreciated.
How are you executing the function?
Synchronous From the SDK
??
Are you looking for something like this? https://github.com/appwrite/appwrite/issues/1425
I believe my issue is related to this in some ways. My tests were conducted on a function that requires 4 seconds to complete execution for one call. If I execute it 8 times at the same time, it will execute all calls without any delay in the execution time, each taking 4 seconds. However, if I increase the calls to more than 8, it will delay some of them, as I mentioned in my first message (similar to a single thread handling multiple tasks by serving them partially).So Let's consider a scenario where I call it 24 times at the same time. In this case, some executions need 14 seconds to finish and some them need 8 seconds and so on. But, if I duplicate the same function in other deployments, say 3 times, and distribute the calls among them, then each deployed function has to handle 8 calls. In this scenario, there won't be any delay in the call execution.
.
@Nour just wondering: are you using cloud? When I tested this the functions were executing sequentially. So the next execution would wait for the previous one to complete. I'm using self hosted i'm guessing these executions are managed when using cloud.
I’m also using the self-hosted version of Appwrite. Have you figured out the asynchronous flag for execution? It should be set to False for parallel execution and True for sequential executions.
Synchronous shouldn't be blocked like this...what language is your runtime?
How many cores does your server have?
Python 3.11
8 CPUs.
And
The _APP_FUNCTIONS_CPUS is empty, as stated in the Appwrite documentation. When it’s empty, the CPU limit will be disabled.
??
I have been contemplating duplicating a function multiple times and have a routing function that triggers them sequentially basis last triggered time .. Would that approach work ?
Hmm, this is an interesting idea.
Recommended threads
- How to Avoid Double Requests in function...
I'm currently using Appwrite's `functions.createExecution` in my project. I want to avoid double requests when multiple actions (like searching or pagination) a...
- Send Email Verification With REST
I am using REST to create a user on the server side after receiving form data from the client. After the account is successfully created i wanted to send the v...
- Use different email hosts for different ...
Hello, I have 2 projects and i want to be able to set up email templates in the projects. Both projects will have different email host configurations. I see ...