From 505b4815378622a1c3988c26e087c2fcc8dc6832 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Mon, 19 Feb 2024 14:10:35 +0000 Subject: [PATCH] Revert "Add smarter traefik load balancing with health check" This reverts commit 2ab6156db4f9a9c454931b2dcf7a59714df2a916. --- .env | 2 +- app/controllers/api/health.php | 10 +--------- app/controllers/web/home.php | 1 - app/http.php | 7 ------- docker-compose.yml | 9 +++------ 5 files changed, 5 insertions(+), 24 deletions(-) diff --git a/.env b/.env index 56fde8a4fb..b915f91516 100644 --- a/.env +++ b/.env @@ -1,6 +1,6 @@ _APP_ENV=development _APP_LOCALE=en -_APP_WORKER_PER_CORE=1 +_APP_WORKER_PER_CORE=6 _APP_CONSOLE_WHITELIST_ROOT=disabled _APP_CONSOLE_WHITELIST_EMAILS= _APP_CONSOLE_WHITELIST_IPS= diff --git a/app/controllers/api/health.php b/app/controllers/api/health.php index f6ab3e8eec..a85f9da321 100644 --- a/app/controllers/api/health.php +++ b/app/controllers/api/health.php @@ -51,16 +51,8 @@ App::get('/v1/health/version') ->label('sdk.response.code', Response::STATUS_CODE_OK) ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) ->label('sdk.response.model', Response::MODEL_HEALTH_VERSION) - ->inject('http') ->inject('response') - ->action(function (mixed $http, Response $response) { - $stats = $http->stats(); - \var_dump(\gethostname() . ': ' . $stats['idle_worker_num'] . '/' . $stats['worker_num']); - - if(($stats['idle_worker_num'] ?? 0) <= 1) { - throw new Exception(Exception::GENERAL_SERVER_ERROR, 'Can not process more requests at the moment.'); - } - + ->action(function (Response $response) { $response->dynamic(new Document([ 'version' => APP_VERSION_STABLE ]), Response::MODEL_HEALTH_VERSION); }); diff --git a/app/controllers/web/home.php b/app/controllers/web/home.php index 5a8a7e1a93..27b2614c37 100644 --- a/app/controllers/web/home.php +++ b/app/controllers/web/home.php @@ -10,7 +10,6 @@ App::get('/versions') ->label('scope', 'public') ->inject('response') ->action(function (Response $response) { - \sleep(60); $platforms = Config::getParam('platforms'); $versions = [ diff --git a/app/http.php b/app/http.php index 4b740516ee..5b32d8f134 100644 --- a/app/http.php +++ b/app/http.php @@ -327,11 +327,4 @@ $http->on('request', function (SwooleRequest $swooleRequest, SwooleResponse $swo } }); -$register->set('http', function () use ($http) { - return $http; -}); -App::setResource('http', function ($register) { - return $register->get('http'); -}, ['register']); - $http->start(); diff --git a/docker-compose.yml b/docker-compose.yml index 8e017c3e50..de71e3937a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -44,9 +44,7 @@ services: - appwrite appwrite: - deploy: - mode: replicated - replicas: 3 + container_name: appwrite <<: *x-logging image: appwrite-dev build: @@ -55,6 +53,8 @@ services: DEBUG: false TESTING: true VERSION: dev + ports: + - 9501:80 networks: - appwrite labels: @@ -62,9 +62,6 @@ services: - "traefik.constraint-label-stack=appwrite" - "traefik.docker.network=appwrite" - "traefik.http.services.appwrite_api.loadbalancer.server.port=80" - - "traefik.http.services.appwrite_api.loadbalancer.healthcheck.path=/v1/health/version" - - "traefik.http.services.appwrite_api.loadbalancer.healthcheck.interval=3s" - - "traefik.http.services.appwrite_api.loadbalancer.healthcheck.timeout=2s" #http - traefik.http.routers.appwrite_api_http.entrypoints=appwrite_web - traefik.http.routers.appwrite_api_http.rule=PathPrefix(`/`)