Skip to content

Modular logistics and supply chain operating system (LSOS)

perf: Optimize FrankenPHP/Octane configuration for high load

roncodesa5a5ddb0d58d
diff --git a/Caddyfile b/Caddyfile
index 8657e219..ffd0243e 100644
--- a/Caddyfile
+++ b/Caddyfile
@@ -1,6 +1,9 @@
{
frankenphp {
- num_threads 24
+ # Reduced from 24 to 20 for better resource management
+ # With 4 containers: 20 × 4 = 80 total workers
+ # Requires db.t3.large (591 max connections) or better
+ num_threads 20
}
order php_server before file_server
}
@@ -8,6 +11,15 @@
http://:8000 {
root * /fleetbase/api/public
encode zstd br gzip
+
+ # Request timeouts to prevent hanging
+ timeouts {
+ read_body 10s
+ read_header 5s
+ write 60s
+ idle 120s
+ }
+
php_server {
resolve_root_symlink
}
diff --git a/api/config/octane.php b/api/config/octane.php
index 6be27774..81b6bc33 100644
--- a/api/config/octane.php
+++ b/api/config/octane.php
@@ -105,8 +105,8 @@ return [
OperationTerminated::class => [
FlushOnce::class,
FlushTemporaryContainerInstances::class,
- // DisconnectFromDatabases::class,
- // CollectGarbage::class,
+ DisconnectFromDatabases::class, // ✅ Release DB connections after each request
+ CollectGarbage::class, // ✅ Prevent memory leaks
],
WorkerErrorOccurred::class => [
diff --git a/docker/Dockerfile b/docker/Dockerfile
index 4886924c..acab6ccc 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -158,14 +158,14 @@ CMD ["php", "artisan", "queue:work"]
# Application dev stage
FROM base AS app-dev
ENTRYPOINT ["docker-php-entrypoint"]
-CMD ["sh", "-c", "php artisan octane:frankenphp --max-requests=250 --port=8000 --host=0.0.0.0 --watch"]
+CMD ["sh", "-c", "php artisan octane:frankenphp --workers=20 --max-requests=1000 --port=8000 --host=0.0.0.0 --watch"]
# Application release stage
FROM base AS app-release
ENTRYPOINT ["docker-php-entrypoint"]
-CMD ["sh", "-c", "php artisan octane:frankenphp --max-requests=250 --port=8000 --host=0.0.0.0"]
+CMD ["sh", "-c", "php artisan octane:frankenphp --workers=20 --max-requests=1000 --port=8000 --host=0.0.0.0"]
# Application stage
FROM base AS app
ENTRYPOINT ["/sbin/ssm-parent", "-c", ".ssm-parent.yaml", "run", "--", "docker-php-entrypoint"]
-CMD ["sh", "-c", "php artisan octane:frankenphp --max-requests=250 --port=8000 --host=0.0.0.0"]
+CMD ["sh", "-c", "php artisan octane:frankenphp --workers=20 --max-requests=1000 --port=8000 --host=0.0.0.0"]