php / php/frankenphp

Server become slower or unresponsive with frankenphp worker mode and laravel octane

Open
#1,821 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

awaiting user response bug
Dominant language
Go
Stars
11.3k
Forks
488
Avg merge
4d 10h
Merged PRs (30d)
11

Description

What happened?

Dockerfile

FROM dunglas/frankenphp

# Be sure to replace "your-domain-name.example.com" by your domain name
#ENV SERVER_NAME=api.********
ENV FRANKENPHP_CONFIG="worker /app/public/frankenphp-worker.php 8"
# If you want to disable HTTPS, use this value instead:
ENV SERVER_NAME=:80

# install packages
RUN apt-get update && apt-get install -y \
        git \
        curl \
        libpng-dev \
        libjpeg-dev \
        libfreetype6-dev \
        libzip-dev \
        libonig-dev \
        libpq-dev \
        nodejs \
        npm \
        supervisor \
        # Clean up apt caches to reduce image size
        && rm -rf /var/lib/apt/lists/*

# add additional extensions here:
RUN install-php-extensions \
	pdo_mysql \
	gd \
	intl \
    pcntl \
	zip \
	opcache \
    redis \
    imagick \
    xml \
    simplexml \
    iconv \
    @composer


# Set working directory
WORKDIR /app

# copy php.ini
#COPY ./.docker/php/php.ini /usr/local/etc/php/conf.d/zz-production.ini

php.ini

memory_limit = 256M
upload_max_filesize = 128M
post_max_size = 100M

display_errors = Off
display_startup_errors = Off
log_errors = On
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
expose_php = Off
date.timezone = UTC

[opcache]
opcache.enable=1
opcache.memory_consumption=128
opcache.interned_strings_buffer=16
opcache.max_accelerated_files=10000
opcache.validate_timestamps=1
opcache.revalidate_freq=2
opcache.jit_buffer_size=100M
opcache.jit=tracing

/app/public/frankenphp-worker.php

<?php

// Set a default for the application base path and public path if they are missing...
$_SERVER['APP_BASE_PATH'] = $_ENV['APP_BASE_PATH'] ?? $_SERVER['APP_BASE_PATH'] ?? __DIR__.'/..';
$_SERVER['APP_PUBLIC_PATH'] = $_ENV['APP_PUBLIC_PATH'] ?? $_SERVER['APP_BASE_PATH'] ?? __DIR__;

require __DIR__.'/../vendor/laravel/octane/bin/frankenphp-worker.php';

Docker compose file

services:
  app:
    image: dazzle-backend:latest
    build:
      context: .
    restart: always
    volumes:
      - ./:/app
      - caddy_data:/data
      - caddy_config:/config
    depends_on:
      - redis
      - typesense
    networks:
      - dazzle_network
      - traefik_proxy
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.laravel.rule=Host(`#####`)"
      - "traefik.http.routers.laravel.entrypoints=websecure"
      - "traefik.http.routers.laravel.tls.certresolver=letsencrypt"
      - "traefik.http.services.laravel.loadbalancer.server.port=80"
  redis:
    image: redis:alpine
    hostname: redis
    restart: always
    command: redis-server /usr/local/etc/redis/redis.conf
    volumes:
      - ./.docker/redis/redis.conf:/usr/local/etc/redis/redis.conf
    networks:
      - dazzle_network
  supervisor:
    image: dazzle-backend:latest
    entrypoint: ["./.docker/entrypoint.sh"]
    restart: always
    volumes:
      - ./:/app
    depends_on:
      - redis
      - typesense
      - app
    networks:
      - dazzle_network
      - traefik_proxy
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.reverb.tls=true"
      - "traefik.http.routers.reverb.entrypoints=websecure"
      - "traefik.http.routers.reverb.rule=Host(`####`)"
      - "traefik.http.services.reverb.loadbalancer.server.port=8080"
      - "traefik.http.services.reverb.loadbalancer.server.scheme=http"
  typesense:
    image: typesense/typesense:27.1
    restart: on-failure
    environment:
      TYPESENSE_API_KEY: ${TYPESENSE_API_KEY}
    command: '--data-dir /data --api-key=typesense_dazzle'
    volumes:
      - typesense_data:/data
    networks:
      - dazzle_network
# Volumes needed for Caddy certificates and configuration
volumes:
  caddy_data:
  caddy_config:
  typesense_data:
networks:
  dazzle_network:
    driver: bridge
  traefik_proxy:
    external: true

When worker is enabled then backend becomes slow or unresponsive after certain load. But after disabling worker mode everything is working fine. Whats wrong with this setup? And what is correct setup with laravel, docker and frankenphp (woker mode)?

Build Type

Docker (Debian Bookworm)

Worker Mode

Yes

Operating System

GNU/Linux

CPU Architecture

x86_64

PHP configuration
memory_limit = 256M
upload_max_filesize = 128M
post_max_size = 100M

display_errors = Off
display_startup_errors = Off
log_errors = On
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
expose_php = Off
date.timezone = UTC

[opcache]
opcache.enable=1
opcache.memory_consumption=128
opcache.interned_strings_buffer=16
opcache.max_accelerated_files=10000
opcache.validate_timestamps=1
opcache.revalidate_freq=2
opcache.jit_buffer_size=100M
opcache.jit=tracing
Relevant log output

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the report from the supplied Dockerfile, php.ini, public/frankenphp-worker.php, and Docker Compose configuration, using the Laravel Octane FrankenPHP worker entry point. Start by isolating the worker-mode behavior under load and collecting relevant logs, since the issue provides no log output. Done means identifying the configuration or runtime cause and documenting a verified working Laravel, Docker, and FrankenPHP worker setup.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, docker-compose, php
Domain
backend, devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.