Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# https://symfony.com/doc/current/best_practices.html#use-environment-variables-for-infrastructure-configuration

###> symfony/framework-bundle ###
APP_ENV=dev
APP_ENV=prod
APP_SECRET=2ca64f8d83b9e89f5f19d672841d6bb8
#TRUSTED_PROXIES=127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16
#TRUSTED_HOSTS='^(localhost|example\.com)$'
Expand Down
Empty file removed Dockerfile
Empty file.
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
K6_SERVICE := k6

# Environment variables for k6 testing
FRANKEN_URL := https://localhost:443
FRANKEN_WORKER_URL := https://localhost:444
FRANKEN_URL := http://localhost:8080
FRANKEN_WORKER_URL := http://localhost:8081
FPM_URL := http://localhost:8088

.PHONY: k6 clean
Expand Down Expand Up @@ -64,7 +64,7 @@ up:
docker-compose up -d redis

down:
docker-compose up -d down
docker-compose down


ps:
Expand Down Expand Up @@ -287,9 +287,9 @@ k6-install:
.PHONY: rebuild-projections
rebuild-projections:
@echo "Rebuilding all projections..."
docker-compose exec app php bin/console app:rebuild-product-projections
docker-compose exec app php bin/console app:rebuild-customer-projections
docker-compose exec app php bin/console app:rebuild-order-projections
@docker-compose exec app php bin/console app:rebuild-product-projections 2>&1 | grep -v "User Deprecated"
@docker-compose exec app php bin/console app:rebuild-customer-projections 2>&1 | grep -v "User Deprecated"
@docker-compose exec app php bin/console app:rebuild-order-projections 2>&1 | grep -v "User Deprecated"

.PHONY: rebuild-products
rebuild-products:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,8 @@ for detailed autoloader optimization guidelines and best practices.
| Service | URL | Description |
|-----------------------|-------------------------------|---------------------------------------|
| FPM App | http://localhost:8088 | Main Symfony app (FPM) |
| Franken | https://localhost:443 | FrankenPHP (HTTPS, alt runtime) |
| Franken Worker | https://localhost:444 | FrankenPHP Worker (HTTPS) |
| Franken | http://localhost:8080 | FrankenPHP (HTTP, regular mode) |
| Franken Worker | http://localhost:8081 | FrankenPHP Worker (HTTP, optimized) |
| Grafana | http://localhost:3000 | Metrics dashboard (admin/admin) |
| Prometheus | http://localhost:9090 | Prometheus metrics |
| Opcache Dashboard | http://localhost:42042 | PHP Opcache dashboard |
Expand Down
22 changes: 22 additions & 0 deletions config/packages/prod/monolog.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
monolog:
handlers:
main:
type: fingers_crossed
action_level: error
handler: nested
excluded_http_codes: [404, 405]
buffer_size: 50
nested:
type: stream
path: php://stderr
level: debug
formatter: monolog.formatter.json
console:
type: console
process_psr_3_messages: false
channels: ["!event", "!doctrine", "!console", "!deprecation"]
deprecation:
type: stream
channels: [deprecation]
path: php://stderr
level: error
Binary file modified data/database.sqlite
Binary file not shown.
10 changes: 4 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@ services:
context: .
dockerfile: ./docker/Dockerfile.franken
ports:
- "443:443"
- "443:443/udp"
- "8080:80"
- "2019:2019"
volumes:
- .:/var/www/html
- ./docker/Caddyfile.regular:/etc/frankenphp/Caddyfile
tty: true
environment:
SERVER_NAME: ":8080 https://localhost:443"
SERVER_NAME: ":80"
networks:
- app-net

Expand All @@ -34,8 +33,7 @@ services:
context: .
dockerfile: ./docker/Dockerfile.franken
ports:
- "444:443"
- "444:443/udp"
- "8081:80"
- "2020:2019"
volumes:
- .:/var/www/html
Expand All @@ -45,7 +43,7 @@ services:
tty: true
environment:
APP_RUNTIME: "Runtime\\FrankenPhpSymfony\\Runtime"
SERVER_NAME: ":8080 https://localhost:443"
SERVER_NAME: ":80"
networks:
- app-net

Expand Down
30 changes: 17 additions & 13 deletions docker/Caddyfile
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
{
admin 0.0.0.0:2019
metrics
auto_https off

frankenphp {
num_threads 20 # Optimal: 16 workers + 4 handling threads
max_threads auto # Keep stable, no dynamic scaling

worker {
file ./public/index.php
watch

num 1 # change number of worker

## Uncomment for incorrect config
# num_threads 16
# max_threads 8

## Uncomment for correct config
# num_threads 16
# max_threads 32
num 16 # 2 workers per CPU core (8 cores * 2) - optimal balance
}

php_ini memory_limit 512M
# Aggressive PHP optimizations for worker mode
#php_ini memory_limit 512M
#php_ini opcache.enable 1
#php_ini opcache.memory_consumption 256
#php_ini opcache.interned_strings_buffer 16
#php_ini opcache.max_accelerated_files 20000
#php_ini opcache.validate_timestamps 0
#php_ini opcache.jit 1255
#php_ini opcache.jit_buffer_size 128M
#php_ini realpath_cache_size 4M
#php_ini realpath_cache_ttl 600
}
}

{$SERVER_NAME:localhost} {
{$SERVER_NAME::80} {
root {$SERVER_ROOT:public/}
encode zstd br gzip

Expand Down
11 changes: 6 additions & 5 deletions docker/Caddyfile.regular
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
{
admin 0.0.0.0:2019
metrics
auto_https off

frankenphp {
php_ini memory_limit 512M
}
frankenphp
}

{$SERVER_NAME:localhost} {
{$CADDY_EXTRA_CONFIG}

{$SERVER_NAME::80} {
root {$SERVER_ROOT:public/}
encode zstd br gzip
encode zstd br gzip

{$CADDY_SERVER_EXTRA_DIRECTIVES}

Expand Down
23 changes: 12 additions & 11 deletions frankenphp.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,24 @@ comparison and monitoring.
make up-franken
```

Go to - https://localhost/
Go to - http://localhost:8080/

# up worker mode franken

```
make up-worker
```

Go to - https://localhost:444/
Go to - http://localhost:8081/

## Service Configuration

### FrankenPHP Services

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

### Configuration Differences

Expand Down Expand Up @@ -135,7 +135,7 @@ Caddy configuration can be extended via environment variables in the docker-comp
```yaml
environment:
CADDY_GLOBAL_OPTIONS: "admin 0.0.0.0:2019\nmetrics"
SERVER_NAME: ":8080 https://localhost:443"
SERVER_NAME: ":80"
```

### Environment Variables Explained
Expand All @@ -156,7 +156,8 @@ Injects global Caddy directives at the top of your configuration:
Defines which addresses/domains Caddy will serve:

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

Expand Down Expand Up @@ -326,7 +327,7 @@ curl http://localhost:2019/metrics | grep frankenphp_total_workers
watch -n 1 'curl -s http://localhost:2019/metrics | grep frankenphp_total_workers'

# Run load test in another terminal
k6 run k6/list_products.js --env BASE_URL=https://localhost:443/en
k6 run k6/list_products.js --env BASE_URL=http://localhost:8080/en
```

## Troubleshooting FrankenPHP
Expand Down Expand Up @@ -569,7 +570,7 @@ existing Makefile targets for consistent and reproducible testing.

### Available k6 Test Commands

#### FrankenPHP (Regular Mode - Port 443)
#### FrankenPHP (Regular Mode - Port 8080)

```bash
# Products testing
Expand All @@ -585,7 +586,7 @@ make k6-franken-orders-db # Test orders DB endpoint
make k6-franken-orders-redis # Test orders Redis endpoint
```

#### FrankenPHP Worker Mode (Port 444)
#### FrankenPHP Worker Mode (Port 8081)

```bash
# Products testing
Expand Down Expand Up @@ -854,8 +855,8 @@ curl http://localhost:2020/metrics | grep frankenphp

**Environment Variables Used:**

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

**k6 Test Scripts:**
Expand Down
Loading
Loading