Rank 1: Thread
I have a logic that fetches around 5000 data entries from the Facebook API. I use batch calls that can pack up to 50 requests, so it's around 100 single API calls. The 5000 received data objects are then saved to the database. For which I used a batched parallel execution with 100 database calls concurrently.
So: the only activity the logic does is fetching data from the API and interacting with the Appwrite database (reading/writing).
When running it for those 5000 entries with 100 database calls in parallel, i get two different problematic behaviors:
Behavior 1:
Function fails with Internal curl errors has occurred within the executor! Error Number: 52. Error Msg: Empty reply from server\nError Code: 500, and it always has a duration of 1m (screenshot 1). Function timeout is set to 900 seconds and it is executed async.
When this happens that the function is labeled "failed", CPU usage stays at around 30% (screenshot 2).
Behavior 2:
Here the function runs for >1m, and i can see in the Sentry logs that some hundred of the data entries are processed. CPU usage is high, fluctuating between 40% and 90%. After 1-2 minutes it jumps to 100% on all 4 cores and stays there (see screenshot 3). Seems to be the app/http.php process. But before this constant 100%, there is another process at the top, node --max_old_space_size=8192 server.js (see screenshot 4).
To get out of the 100% blockage, i need to restart Appwrite with sudo docker compose down and sudo docker compose up -d .
When I fetch with a lower volume of 200 entries at that 100 calls concurrency it all works fine.
When I fetch that high volume of 5000 entries with a concurrency of 10 database requests, the CPU usage is a bit higher but it also works fine. CPU stays around 20-30%.
But fetching those 5000 objects with 100 database requests concurrency results in those two behaviors above.
Rest of text see below ⬇️