Hello all, I have a question about the functions working on a self hosted instance.
My function response gets cooked in 30 seconds or so, due to calling different apis, retrieving some information in the cluster somewhere and sorting things through blabla. I have outsourced the heavy parts to other machines but I question if I could use Appwrite functions to combine them all in one place, instead of JWT token validating the user account in those machines.
Question is: Do the self hosted functions run in serial or in parallel? I mean does one request wait for the previous one to finish so it can start working on its current request (right after the first one quit blocking the machine) ? If so, Can I limit the resource that one thread uses so there might be more resources to start other threads? If not, how many functions in parallel can Appwrite handle?
Thank you.
async=false can run in parallel, event-triggered/scheduled/async=true runs in serial, unless you spin up multiple function workers.
First, check this https://github.com/appwrite/appwrite/issues/5629 You'll find a lot of information on how Appwrite function works - specifically on self-hosted.
The semi-solution
part will make your function runs much faster and will make the execution of your function much more reliable.
For check how much function Appwrite can handle in parallel, check the table at the bottom of the link.
In the default configuration, there is a queue from which workers read. By default, there is only one worker, which means that only one execution can run at a time. However, you have the option to scale the number of workers by duplicating the functions worker in the docker-compose file. By doing this, you can have multiple workers, such as 2, 3, 5, or even more, depending on your server's capacity. Each worker enables concurrent handling of jobs, allowing multiple executions to occur simultaneously.
By default, the executions run in a serial manner, with only one execution processed at a time. However, if you create an execution with async=false, it is handled by the API server instead of a worker. The API server allows concurrency at a rate of 8 times the number of CPU cores by default. This means that for async=false executions, you can typically run multiple executions concurrently, potentially dozens of them simultaneously.
very valueable information from you both.
I need to make a research and come back
Well... Thank you Appwrite for being transparent about that painpoint and offering a solution, hacky but still.
For the reference I checked Supabase and they're offering a way to host functions on the cloud. (https://www.youtube.com/watch?v=cPGxPl1lx4Y)
But Appwrite has a better solution still
We do have Appwrite Cloud https://cloud.appwrite.io/
pricing information is still not revealed.
I would call functions in the cloud by JWT validating
We are free as of now, the pricing will be released soon but we will have a generous free tier
instead of calllling them on the local machine
const sdk = require('node-appwrite');
let client = new sdk.Client();
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
.setSelfSigned() // Use only on dev mode with a self-signed SSL cert
;
I can run this on a Lambda function and get the user information in an instant and do not block the Self Hosted Appwrite Functions
And respond from there.
Yes. That's of course also an option
The use of function its just very easy and make you put all the logic stuff in one place.
And it can 'write' the response to the database for user to read from the local instance
What you mean by write
write to the database
Yes you can do anything you want with the node SDK.
I was thinking that user would read them from there but no need actually
Recommended threads
- Need help with createExecution function
Hi, Need some help understanding createExecution. When requesting function execution via createExecution, the function handler arguments are incorrect and rese...
- Realtime with multiple connections
I need the Realtime on multiple Collections for diffrent applicational logic. So my question is: Is there a way to have only 1 Websocket connection or do I need...
- Can't login or deploy functions in Appwr...
Hello, since i updatet to the appwrite cli 6.1.0 i can't login or deploy functions with the cli. When i call the command: "appwrite get account --verbose" i ge...