Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Execute functions up to 5 seconds faster #1308

Merged
merged 2 commits into from Jun 21, 2021
Merged

Execute functions up to 5 seconds faster #1308

merged 2 commits into from Jun 21, 2021

Conversation

Meldiron
Copy link
Contributor

What does this PR do?

Updated INTERVALS of php-resque

In general, this PR speeds up functions, webhooks and tasks by up to 5 seconds. Also, it speeds up the overall speed of the appwrite.

Test Plan

I run a whole project on Appwrite using functions and real-time feature.
Before using this fork, the time between running createExecuton and receiving the update event using real-time took 4-5 seconds.
Using this fork, I reduced the time to 1s.

Addational research info

I tested everything on a function that takes ~1s to execute (load libraries into NodeJS, connect to MySQL server, get some data, process them and console log result). If a request takes 1s, it means 0ms delay due to Appwrite.

Currently, Appwrite uses the default INTERVAL configuration which is 5 seconds:
https://github.com/resque/php-resque/blob/master/lib/Resque.php#L13
https://github.com/resque/php-resque/blob/master/lib/Resque/Worker.php#L160

By changing this number to 0.1s, the MAXIMUM possible delay was reduced from 5000ms to 100ms. This resulted in really fast function executions but also highly increased CPU usage:
image

I switched to INTERVAL=1 which fixed the high CPU and still increased the speed of every request by up to 4 seconds:
image

Then I wanted to see what happens when I set INTERVAL=1 on everything but set INTERVAL=0.1 on the functions container. This was the result:
image
Also, of course, MAXIMUM of 100ms delay between creating and starting execution.

Finally, I decreased INTERVAL on functions, webhook and tasks real-time to 0.1 which resulted in these stats:
image


Current PR sets INTERVAL=1 on everything except functions, tasks and webhooks. These have even faster INTERVAL=0.1

I am not fully sure what to think about these stats, so it will need some more benchmarking but these screenshots should provide solid ground.

bin/worker-usage Outdated Show resolved Hide resolved
@eldadfux eldadfux merged commit ecadb1b into appwrite:master Jun 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants