Skip to content

Commit 86e73d8

Browse files
authored
Merge pull request #9 from dragoonis/feat/improve_frankenphp_grafana_dashboard_#3
2 parents 38071b7 + f8e2dc9 commit 86e73d8

File tree

17 files changed

+1140
-1859
lines changed

17 files changed

+1140
-1859
lines changed

.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# https://symfony.com/doc/current/best_practices.html#use-environment-variables-for-infrastructure-configuration
1616

1717
###> symfony/framework-bundle ###
18-
APP_ENV=dev
18+
APP_ENV=prod
1919
APP_SECRET=2ca64f8d83b9e89f5f19d672841d6bb8
2020
#TRUSTED_PROXIES=127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16
2121
#TRUSTED_HOSTS='^(localhost|example\.com)$'

Dockerfile

Whitespace-only changes.

Makefile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
K6_SERVICE := k6
22

33
# Environment variables for k6 testing
4-
FRANKEN_URL := https://localhost:443
5-
FRANKEN_WORKER_URL := https://localhost:444
4+
FRANKEN_URL := http://localhost:8080
5+
FRANKEN_WORKER_URL := http://localhost:8081
66
FPM_URL := http://localhost:8088
77

88
.PHONY: k6 clean
@@ -64,7 +64,7 @@ up:
6464
docker-compose up -d redis
6565

6666
down:
67-
docker-compose up -d down
67+
docker-compose down
6868

6969

7070
ps:
@@ -287,9 +287,9 @@ k6-install:
287287
.PHONY: rebuild-projections
288288
rebuild-projections:
289289
@echo "Rebuilding all projections..."
290-
docker-compose exec app php bin/console app:rebuild-product-projections
291-
docker-compose exec app php bin/console app:rebuild-customer-projections
292-
docker-compose exec app php bin/console app:rebuild-order-projections
290+
@docker-compose exec app php bin/console app:rebuild-product-projections 2>&1 | grep -v "User Deprecated"
291+
@docker-compose exec app php bin/console app:rebuild-customer-projections 2>&1 | grep -v "User Deprecated"
292+
@docker-compose exec app php bin/console app:rebuild-order-projections 2>&1 | grep -v "User Deprecated"
293293

294294
.PHONY: rebuild-products
295295
rebuild-products:

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,8 @@ for detailed autoloader optimization guidelines and best practices.
261261
| Service | URL | Description |
262262
|-----------------------|-------------------------------|---------------------------------------|
263263
| FPM App | http://localhost:8088 | Main Symfony app (FPM) |
264-
| Franken | https://localhost:443 | FrankenPHP (HTTPS, alt runtime) |
265-
| Franken Worker | https://localhost:444 | FrankenPHP Worker (HTTPS) |
264+
| Franken | http://localhost:8080 | FrankenPHP (HTTP, regular mode) |
265+
| Franken Worker | http://localhost:8081 | FrankenPHP Worker (HTTP, optimized) |
266266
| Grafana | http://localhost:3000 | Metrics dashboard (admin/admin) |
267267
| Prometheus | http://localhost:9090 | Prometheus metrics |
268268
| Opcache Dashboard | http://localhost:42042 | PHP Opcache dashboard |

config/packages/prod/monolog.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
monolog:
2+
handlers:
3+
main:
4+
type: fingers_crossed
5+
action_level: error
6+
handler: nested
7+
excluded_http_codes: [404, 405]
8+
buffer_size: 50
9+
nested:
10+
type: stream
11+
path: php://stderr
12+
level: debug
13+
formatter: monolog.formatter.json
14+
console:
15+
type: console
16+
process_psr_3_messages: false
17+
channels: ["!event", "!doctrine", "!console", "!deprecation"]
18+
deprecation:
19+
type: stream
20+
channels: [deprecation]
21+
path: php://stderr
22+
level: error

data/database.sqlite

0 Bytes
Binary file not shown.

docker-compose.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,14 @@ services:
1717
context: .
1818
dockerfile: ./docker/Dockerfile.franken
1919
ports:
20-
- "443:443"
21-
- "443:443/udp"
20+
- "8080:80"
2221
- "2019:2019"
2322
volumes:
2423
- .:/var/www/html
2524
- ./docker/Caddyfile.regular:/etc/frankenphp/Caddyfile
2625
tty: true
2726
environment:
28-
SERVER_NAME: ":8080 https://localhost:443"
27+
SERVER_NAME: ":80"
2928
networks:
3029
- app-net
3130

@@ -34,8 +33,7 @@ services:
3433
context: .
3534
dockerfile: ./docker/Dockerfile.franken
3635
ports:
37-
- "444:443"
38-
- "444:443/udp"
36+
- "8081:80"
3937
- "2020:2019"
4038
volumes:
4139
- .:/var/www/html
@@ -45,7 +43,7 @@ services:
4543
tty: true
4644
environment:
4745
APP_RUNTIME: "Runtime\\FrankenPhpSymfony\\Runtime"
48-
SERVER_NAME: ":8080 https://localhost:443"
46+
SERVER_NAME: ":80"
4947
networks:
5048
- app-net
5149

docker/Caddyfile

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,32 @@
11
{
22
admin 0.0.0.0:2019
33
metrics
4+
auto_https off
45

56
frankenphp {
7+
num_threads 20 # Optimal: 16 workers + 4 handling threads
8+
max_threads auto # Keep stable, no dynamic scaling
9+
610
worker {
711
file ./public/index.php
8-
watch
9-
10-
num 1 # change number of worker
11-
12-
## Uncomment for incorrect config
13-
# num_threads 16
14-
# max_threads 8
15-
16-
## Uncomment for correct config
17-
# num_threads 16
18-
# max_threads 32
12+
num 16 # 2 workers per CPU core (8 cores * 2) - optimal balance
1913
}
2014

21-
php_ini memory_limit 512M
15+
# Aggressive PHP optimizations for worker mode
16+
#php_ini memory_limit 512M
17+
#php_ini opcache.enable 1
18+
#php_ini opcache.memory_consumption 256
19+
#php_ini opcache.interned_strings_buffer 16
20+
#php_ini opcache.max_accelerated_files 20000
21+
#php_ini opcache.validate_timestamps 0
22+
#php_ini opcache.jit 1255
23+
#php_ini opcache.jit_buffer_size 128M
24+
#php_ini realpath_cache_size 4M
25+
#php_ini realpath_cache_ttl 600
2226
}
2327
}
2428

25-
{$SERVER_NAME:localhost} {
29+
{$SERVER_NAME::80} {
2630
root {$SERVER_ROOT:public/}
2731
encode zstd br gzip
2832

docker/Caddyfile.regular

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
{
22
admin 0.0.0.0:2019
33
metrics
4+
auto_https off
45

5-
frankenphp {
6-
php_ini memory_limit 512M
7-
}
6+
frankenphp
87
}
98

10-
{$SERVER_NAME:localhost} {
9+
{$CADDY_EXTRA_CONFIG}
10+
11+
{$SERVER_NAME::80} {
1112
root {$SERVER_ROOT:public/}
12-
encode zstd br gzip
13+
encode zstd br gzip
1314

1415
{$CADDY_SERVER_EXTRA_DIRECTIVES}
1516

frankenphp.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,24 @@ comparison and monitoring.
1313
make up-franken
1414
```
1515

16-
Go to - https://localhost/
16+
Go to - http://localhost:8080/
1717

1818
# up worker mode franken
1919

2020
```
2121
make up-worker
2222
```
2323

24-
Go to - https://localhost:444/
24+
Go to - http://localhost:8081/
2525

2626
## Service Configuration
2727

2828
### FrankenPHP Services
2929

3030
| Service | Port | Mode | Caddyfile | Purpose |
3131
|-----------------------|------|---------|---------------------|------------------------------|
32-
| **FrankenPHP** | 443 | Regular | `Caddyfile.regular` | Traditional PHP server mode |
33-
| **FrankenPHP Worker** | 444 | Worker | `Caddyfile` | High-performance worker mode |
32+
| **FrankenPHP** | 8080 | Regular | `Caddyfile.regular` | Traditional PHP server mode |
33+
| **FrankenPHP Worker** | 8081 | Worker | `Caddyfile` | High-performance worker mode |
3434

3535
### Configuration Differences
3636

@@ -135,7 +135,7 @@ Caddy configuration can be extended via environment variables in the docker-comp
135135
```yaml
136136
environment:
137137
CADDY_GLOBAL_OPTIONS: "admin 0.0.0.0:2019\nmetrics"
138-
SERVER_NAME: ":8080 https://localhost:443"
138+
SERVER_NAME: ":80"
139139
```
140140
141141
### Environment Variables Explained
@@ -156,7 +156,8 @@ Injects global Caddy directives at the top of your configuration:
156156
Defines which addresses/domains Caddy will serve:
157157

158158
- `:8080` - HTTP on port 8080 (all interfaces)
159-
- `https://localhost:443` - HTTPS on localhost
159+
- `http://localhost:8080` - HTTP on localhost (regular mode)
160+
- `http://localhost:8081` - HTTP on localhost (worker mode)
160161
- Can specify multiple: `example.com www.example.com`
161162
- Caddy auto-provisions SSL certificates for domains
162163

@@ -326,7 +327,7 @@ curl http://localhost:2019/metrics | grep frankenphp_total_workers
326327
watch -n 1 'curl -s http://localhost:2019/metrics | grep frankenphp_total_workers'
327328
328329
# Run load test in another terminal
329-
k6 run k6/list_products.js --env BASE_URL=https://localhost:443/en
330+
k6 run k6/list_products.js --env BASE_URL=http://localhost:8080/en
330331
```
331332

332333
## Troubleshooting FrankenPHP
@@ -569,7 +570,7 @@ existing Makefile targets for consistent and reproducible testing.
569570

570571
### Available k6 Test Commands
571572

572-
#### FrankenPHP (Regular Mode - Port 443)
573+
#### FrankenPHP (Regular Mode - Port 8080)
573574

574575
```bash
575576
# Products testing
@@ -585,7 +586,7 @@ make k6-franken-orders-db # Test orders DB endpoint
585586
make k6-franken-orders-redis # Test orders Redis endpoint
586587
```
587588

588-
#### FrankenPHP Worker Mode (Port 444)
589+
#### FrankenPHP Worker Mode (Port 8081)
589590

590591
```bash
591592
# Products testing
@@ -854,8 +855,8 @@ curl http://localhost:2020/metrics | grep frankenphp
854855

855856
**Environment Variables Used:**
856857

857-
- `FRANKEN_URL`: https://localhost:443 (FrankenPHP regular mode)
858-
- `FRANKEN_WORKER_URL`: https://localhost:444 (FrankenPHP worker mode)
858+
- `FRANKEN_URL`: http://localhost:8080 (FrankenPHP regular mode)
859+
- `FRANKEN_WORKER_URL`: http://localhost:8081 (FrankenPHP worker mode)
859860
- `FPM_URL`: http://localhost:8088 (PHP-FPM for comparison)
860861

861862
**k6 Test Scripts:**

0 commit comments

Comments
 (0)