Skip to content

Commit f8e2dc9

Browse files
committed
refactor(franken): change franken port to http and update stuff
1 parent 2cca5de commit f8e2dc9

File tree

8 files changed

+66
-81
lines changed

8 files changed

+66
-81
lines changed

.env

Lines changed: 1 addition & 5 deletions
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)$'
@@ -40,7 +40,3 @@ DATABASE_URL=sqlite:///%kernel.project_dir%/data/database.sqlite
4040
# MESSENGER_TRANSPORT_DSN=redis://localhost:6379/messages
4141
MESSENGER_TRANSPORT_DSN=doctrine://default?auto_setup=0
4242
###< symfony/messenger ###
43-
44-
###> FPM Status Configuration ###
45-
FPM_STATUS_URL=http://localhost/fpm-status?full&json
46-
###< FPM Status Configuration ###

Makefile

Lines changed: 5 additions & 5 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
@@ -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

docker-compose.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +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"
29-
CADDY_GLOBAL_OPTIONS: "admin 0.0.0.0:2019\n"
27+
SERVER_NAME: ":80"
3028
networks:
3129
- app-net
3230

@@ -35,8 +33,7 @@ services:
3533
context: .
3634
dockerfile: ./docker/Dockerfile.franken
3735
ports:
38-
- "444:443"
39-
- "444:443/udp"
36+
- "8081:80"
4037
- "2020:2019"
4138
volumes:
4239
- .:/var/www/html
@@ -46,7 +43,7 @@ services:
4643
tty: true
4744
environment:
4845
APP_RUNTIME: "Runtime\\FrankenPhpSymfony\\Runtime"
49-
SERVER_NAME: ":8080 https://localhost:443"
46+
SERVER_NAME: ":80"
5047
networks:
5148
- app-net
5249

docker/Caddyfile

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

56
frankenphp {
6-
num_threads 16 # 4 × CPU cores
7-
max_threads auto # let FrankenPHP scale
7+
num_threads 20 # Optimal: 16 workers + 4 handling threads
8+
max_threads auto # Keep stable, no dynamic scaling
89

910
worker {
1011
file ./public/index.php
11-
num 8 # 1 worker per CPU core
12+
num 16 # 2 workers per CPU core (8 cores * 2) - optimal balance
1213
}
1314

14-
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
1526
}
1627
}
1728

18-
{$SERVER_NAME:localhost} {
29+
{$SERVER_NAME::80} {
1930
root {$SERVER_ROOT:public/}
2031
encode zstd br gzip
2132

docker/Caddyfile.regular

Lines changed: 4 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,18 @@
1-
# The Caddyfile is an easy way to configure FrankenPHP and the Caddy web server.
2-
#
3-
# https://frankenphp.dev/docs/config
4-
# https://caddyserver.com/docs/caddyfile
5-
61
{
7-
skip_install_trust
8-
92
admin 0.0.0.0:2019
103
metrics
4+
auto_https off
115

12-
frankenphp {
13-
{$FRANKENPHP_CONFIG}
14-
}
6+
frankenphp
157
}
168

179
{$CADDY_EXTRA_CONFIG}
1810

19-
{$SERVER_NAME:localhost} {
20-
#log {
21-
# # Redact the authorization query parameter that can be set by Mercure
22-
# format filter {
23-
# request>uri query {
24-
# replace authorization REDACTED
25-
# }
26-
# }
27-
#}
28-
11+
{$SERVER_NAME::80} {
2912
root {$SERVER_ROOT:public/}
3013
encode zstd br gzip
3114

32-
# Uncomment the following lines to enable Mercure and Vulcain modules
33-
#mercure {
34-
# # Transport to use (default to Bolt)
35-
# transport_url {$MERCURE_TRANSPORT_URL:bolt:///data/mercure.db}
36-
# # Publisher JWT key
37-
# publisher_jwt {env.MERCURE_PUBLISHER_JWT_KEY} {env.MERCURE_PUBLISHER_JWT_ALG}
38-
# # Subscriber JWT key
39-
# subscriber_jwt {env.MERCURE_SUBSCRIBER_JWT_KEY} {env.MERCURE_SUBSCRIBER_JWT_ALG}
40-
# # Allow anonymous subscribers (double-check that it's what you want)
41-
# anonymous
42-
# # Enable the subscription API (double-check that it's what you want)
43-
# subscriptions
44-
# # Extra directives
45-
# {$MERCURE_EXTRA_DIRECTIVES}
46-
#}
47-
#vulcain
48-
4915
{$CADDY_SERVER_EXTRA_DIRECTIVES}
5016

51-
php_server {
52-
#worker /path/to/your/worker.php
53-
}
17+
php_server
5418
}
55-
56-
# As an alternative to editing the above site block, you can add your own site
57-
# block files in the Caddyfile.d directory, and they will be included as long
58-
# as they use the .caddyfile extension.
59-
60-
import Caddyfile.d/*.caddyfile

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)