Back

We Stress testing our selfhosted

  • 0
  • Self Hosted
  • Functions
Mosh Ontong
13 Sep, 2024, 09:13

When we create a report, it will trigger the cloud function. Now, when we try to spam the button like we will click to many times. It will trigger the cloud function many times. Now some cloud function cannot be done until the other function's execution is done.

The result of this, some cloud function will 'Executed Timeout' Because there are 50 execution are pending that is why the other will be 'Executed Timeout'. I need your help to scale up our cloud function:

_APP_FUNCTIONS_TIMEOUT=900 _APP_FUNCTIONS_BUILD_TIMEOUT=900 _APP_FUNCTIONS_CONTAINERS=10 _APP_FUNCTIONS_CPUS=0 _APP_FUNCTIONS_MEMORY=0 _APP_FUNCTIONS_MEMORY_SWAP=0 _APP_FUNCTIONS_RUNTIMES=node-21.0,node-18.0,bun-1.0 _APP_EXECUTOR_SECRET=your-secret-key _APP_EXECUTOR_HOST=http://exc1/v1 _APP_EXECUTOR_RUNTIME_NETWORK=appwrite_runtimes _APP_FUNCTIONS_ENVS=node-21.0,node-18.0,bun-1.0 _APP_FUNCTIONS_INACTIVE_THRESHOLD=60

These are the environments is there a variable need to be update? IN the image attached that is the resources we subscribe

TL;DR
Developers are struggling with scaling up cloud functions due to execution timeouts. They are advised to add `_APP_WORKERS_NUM=12` to `appwrite-worker-functions` in docker-compose.yml to control the number of async executions. Adjust other variables like `_APP_FUNCTIONS_TIMEOUT` and `_APP_FUNCTIONS_BUILD_TIMEOUT` as needed. Consider using Hetzner or Digital Ocean with Singapore servers. Replicating the `appwrite-worker-functions` container is suggested.
Joshi
13 Sep, 2024, 09:19

Cloud functions triggered by events are run in async. There can only be one async execution run by default. Add this line - _APP_WORKERS_NUM=12 to appwrite-worker-functions in docker-compose.yml. I used the value 12 only as an example, you can set any other value. That value will specify how many async execution can be run at the same time

Joshi
13 Sep, 2024, 09:19

Also, DO is hella expensive lmao

D5
13 Sep, 2024, 09:29

Also, you can create replicas of the appwrite-worker-functions container

Mosh Ontong
13 Sep, 2024, 09:31

what is Do?

Joshi
13 Sep, 2024, 09:31

Digital Ocean

Mosh Ontong
13 Sep, 2024, 09:32

what can you suggest? that has SIngapore server

Joshi
13 Sep, 2024, 09:32

Yeah APAC region tend to be a lot more expensive

D5
13 Sep, 2024, 09:33

Hetzner

Joshi
13 Sep, 2024, 09:33

You can use hetzner. They just launched a singapore location a few weeks back

Mosh Ontong
13 Sep, 2024, 09:33

okat thank you guys.

Mosh Ontong
13 Sep, 2024, 09:35

appwrite-worker-functions: image: appwrite/appwrite:1.5.10 entrypoint: worker-functions <<: *x-logging container_name: appwrite-worker-functions restart: unless-stopped networks: - appwrite depends_on: - redis - mariadb - openruntimes-executor environment: - _APP_ENV - _APP_WORKER_PER_CORE - _APP_OPENSSL_KEY_V1 - _APP_REDIS_HOST - _APP_REDIS_PORT - _APP_REDIS_USER - _APP_REDIS_PASS - _APP_DB_HOST - _APP_DB_PORT - _APP_DB_SCHEMA - _APP_DB_USER - _APP_DB_PASS - _APP_FUNCTIONS_TIMEOUT - _APP_FUNCTIONS_BUILD_TIMEOUT - _APP_FUNCTIONS_CPUS - _APP_FUNCTIONS_MEMORY - _APP_EXECUTOR_SECRET - _APP_EXECUTOR_HOST - _APP_USAGE_STATS - _APP_DOCKER_HUB_USERNAME - _APP_DOCKER_HUB_PASSWORD - _APP_LOGGING_CONFIG - _APP_LOGGING_PROVIDER

Found this on docker-compose

Mosh Ontong
13 Sep, 2024, 09:35

basically

Mosh Ontong
13 Sep, 2024, 09:35

I will put this - _APP_WORKERS_NUM=12 under of _App_loging

Mosh Ontong
13 Sep, 2024, 09:35

am I right?

Joshi
13 Sep, 2024, 09:35

Yes

Mosh Ontong
13 Sep, 2024, 09:36

then command the docker-compose build?

Mosh Ontong
13 Sep, 2024, 09:36

or I need to down?

Joshi
13 Sep, 2024, 09:36

docker compose up -d

Mosh Ontong
13 Sep, 2024, 09:36

alright thank you

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more