Container CPU stats in executor health endpoint

This commit is contained in:
Matej Bačo
2022-10-14 08:02:08 +00:00
parent 8fcab11610
commit 5807523488
5 changed files with 75 additions and 15 deletions
+2 -2
View File
@@ -85,5 +85,5 @@ _APP_LOGGING_CONFIG=
DOCKERHUB_PULL_USERNAME=
DOCKERHUB_PULL_PASSWORD=
DOCKERHUB_PULL_EMAIL=
# _APP_EXECUTORS=exc1=appwrite-executor,exc2=appwrite-executor2
_APP_EXECUTORS=exc1=appwrite-executor
_APP_EXECUTORS=exc1=appwrite-executor,exc2=appwrite-executor2
# _APP_EXECUTORS=exc1=appwrite-executor
+6 -3
View File
@@ -654,13 +654,16 @@ App::get('/v1/health')
->inject('response')
->action(function (string $name, Response $response) use ($orchestrationPool) {
$systemCores = System::getCPUCores();
$systemUsage = System::getCPUUtilisation() / $systemCores;
$systemUsage = System::getCPUUtilisation() / $systemCores / 100;
$functionsUsage = [];
try {
$orchestration = $orchestrationPool->get();
$runtimes = $orchestration->list(['label' => 'openruntimes-executor=' . $name]);
// $cpuUsages = $orchestration->getStats([ 'label' => 'openruntimes-executor=' . $name ]); // TODO: Add duration 4s, add label
$containerUsages = $orchestration->getStats(filters: [ 'label' => 'openruntimes-executor=' . $name ], cycles: 3);
foreach ($containerUsages as $containerUsage) {
$functionsUsage[$containerUsage['name']] = $containerUsage['cpu'];
}
} catch(\Exception $err) {
// TODO: Handle better
\var_dump($err);
+1 -1
View File
@@ -61,7 +61,7 @@
"utopia-php/storage": "0.11.*",
"utopia-php/websocket": "0.1.0",
"utopia-php/image": "0.5.*",
"utopia-php/orchestration": "0.6.*",
"utopia-php/orchestration": "dev-feat-usage-stats as 0.6.0",
"resque/php-resque": "1.3.6",
"matomo/device-detector": "6.0.0",
"dragonmantank/cron-expression": "3.3.1",
Generated
+15 -8
View File
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "60436077b574163b67a5d7cd221443cd",
"content-hash": "899a96df3f03fb61e9fedd0cc70367c8",
"packages": [
{
"name": "adhocore/jwt",
@@ -2396,16 +2396,16 @@
},
{
"name": "utopia-php/orchestration",
"version": "0.6.0",
"version": "dev-feat-usage-stats",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/orchestration.git",
"reference": "94263976413871efb6b16157a7101a81df3b6d78"
"reference": "e3434f1d5b7f7fada785281901350ead2ce10465"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/orchestration/zipball/94263976413871efb6b16157a7101a81df3b6d78",
"reference": "94263976413871efb6b16157a7101a81df3b6d78",
"url": "https://api.github.com/repos/utopia-php/orchestration/zipball/e3434f1d5b7f7fada785281901350ead2ce10465",
"reference": "e3434f1d5b7f7fada785281901350ead2ce10465",
"shasum": ""
},
"require": {
@@ -2445,9 +2445,9 @@
],
"support": {
"issues": "https://github.com/utopia-php/orchestration/issues",
"source": "https://github.com/utopia-php/orchestration/tree/0.6.0"
"source": "https://github.com/utopia-php/orchestration/tree/feat-usage-stats"
},
"time": "2022-07-13T16:47:18+00:00"
"time": "2022-10-14T07:14:57+00:00"
},
{
"name": "utopia-php/preloader",
@@ -5365,11 +5365,18 @@
"version": "dev-feat-upgrade-system-version",
"alias": "0.11.0",
"alias_normalized": "0.11.0.0"
},
{
"package": "utopia-php/orchestration",
"version": "dev-feat-usage-stats",
"alias": "0.6.0",
"alias_normalized": "0.6.0.0"
}
],
"minimum-stability": "stable",
"stability-flags": {
"appwrite/php-runtimes": 20
"appwrite/php-runtimes": 20,
"utopia-php/orchestration": 20
},
"prefer-stable": false,
"prefer-lowest": false,
+51 -1
View File
@@ -484,7 +484,7 @@ services:
- TESTING=true
- VERSION=dev
ports:
- 23421:80
- 9507:80
networks:
appwrite:
runtimes:
@@ -492,6 +492,56 @@ services:
- /var/run/docker.sock:/var/run/docker.sock
- ./app:/usr/src/code/app
- ./src:/usr/src/code/src
- ./vendor/utopia-php/orchestration:/usr/src/code/vendor/utopia-php/orchestration
- appwrite-functions:/storage/functions:rw
- appwrite-builds:/storage/builds:rw
- /tmp:/tmp:rw
depends_on:
- redis
- mariadb
- appwrite
- appwrite-functions-proxy
environment:
- _APP_ENV
- _APP_WORKER_PER_CORE
- _APP_VERSION
- _APP_FUNCTIONS_TIMEOUT
- _APP_FUNCTIONS_BUILD_TIMEOUT
- _APP_FUNCTIONS_CONTAINERS
- _APP_FUNCTIONS_RUNTIMES
- _APP_FUNCTIONS_CPUS
- _APP_FUNCTIONS_MEMORY
- _APP_FUNCTIONS_MEMORY_SWAP
- _APP_FUNCTIONS_INACTIVE_THRESHOLD
- _APP_EXECUTOR_SECRET
- OPEN_RUNTIMES_NETWORK
- _APP_LOGGING_PROVIDER
- _APP_LOGGING_CONFIG
- *x-env-storage
- DOCKERHUB_PULL_USERNAME
- DOCKERHUB_PULL_PASSWORD
appwrite-executor2:
container_name: appwrite-executor2
<<: *x-logging
entrypoint: executor
stop_signal: SIGINT
build:
context: .
args:
- DEBUG=false
- TESTING=true
- VERSION=dev
ports:
- 9508:80
networks:
appwrite:
runtimes:
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./app:/usr/src/code/app
- ./src:/usr/src/code/src
- ./vendor/utopia-php/orchestration:/usr/src/code/vendor/utopia-php/orchestration
- appwrite-functions:/storage/functions:rw
- appwrite-builds:/storage/builds:rw
- /tmp:/tmp:rw