From 0f3b7db699db7bceb7a16b1b99da3cfc34aa4f64 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Sun, 18 May 2025 17:42:43 +0200 Subject: [PATCH] Add Varnish caching layer for OpenRuntimes executor --- .env | 2 +- docker-compose.yml | 24 ++++++++++++++++++++++-- varnish.vcl | 11 +++++++++++ 3 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 varnish.vcl diff --git a/.env b/.env index 4980315c9a..840ff44f6c 100644 --- a/.env +++ b/.env @@ -83,7 +83,7 @@ _APP_COMPUTE_INACTIVE_THRESHOLD=600 _APP_COMPUTE_MAINTENANCE_INTERVAL=600 _APP_COMPUTE_RUNTIMES_NETWORK=runtimes _APP_EXECUTOR_SECRET=your-secret-key -_APP_EXECUTOR_HOST=http://exc1/v1 +_APP_EXECUTOR_HOST=http://fastly/v1 _APP_FUNCTIONS_RUNTIMES=php-8.0,node-18.0,python-3.9,ruby-3.1 _APP_SITES_RUNTIMES=static-1,node-22,flutter-3.29 _APP_MAINTENANCE_INTERVAL=86400 diff --git a/docker-compose.yml b/docker-compose.yml index 584e0f791b..737f6c45e4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -946,12 +946,32 @@ services: networks: - appwrite + fastly: + image: varnish:7.7.1 + container_name: fastly + hostname: fastly + ports: + - 1337:80 + volumes: + - ./varnish.vcl:/etc/varnish/default.vcl:ro + networks: + - appwrite + - runtimes + depends_on: + - openruntimes-executor + command: > + varnishd + -F + -f /etc/varnish/default.vcl + -a :80 + -s malloc,256m + openruntimes-executor: container_name: openruntimes-executor hostname: exc1 <<: *x-logging stop_signal: SIGINT - image: openruntimes/executor:0.7.15-streaming-1 + image: executor-openruntimes-executor:latest restart: unless-stopped networks: - appwrite @@ -1015,7 +1035,7 @@ services: - OPR_PROXY_SECRET=$_APP_EXECUTOR_SECRET - OPR_PROXY_LOGGING_CONFIG=$_APP_LOGGING_CONFIG - OPR_PROXY_ALGORITHM=random - - OPR_PROXY_EXECUTORS=exc1 + - OPR_PROXY_EXECUTORS=fastly - OPR_PROXY_HEALTHCHECK_INTERVAL=10000 - OPR_PROXY_MAX_TIMEOUT=600 - OPR_PROXY_HEALTHCHECK=enabled diff --git a/varnish.vcl b/varnish.vcl new file mode 100644 index 0000000000..d49505455a --- /dev/null +++ b/varnish.vcl @@ -0,0 +1,11 @@ +vcl 4.1; + +backend exc1 { + .host = "exc1"; + .port = "80"; + .first_byte_timeout = 10s; +} + +sub vcl_recv { + set req.backend_hint = exc1; +} \ No newline at end of file