Skip to content

Spike RAM and CPU usage after deploy #2215

Description

@kitro

What happened?

Hi!

I tested frankenphp in production environment. using the classic mode as drop-in replacement of fpm.
Durning the 5 days of test. I see a good performance and resource wise usage. with tweaking the config based on the doc and the help of contributors here.

I see an issue happen when I deploy a new version of the app. I'm using Ansistrano tools for deployment. using the symlink strategy for ~zero-down-time.

In deploying I saw sometimes the CPU stagnated at 100% (Happened the server is busy to handle requests). Also the RAM increased.

I usually see the spike as normal since the deploy phase need CPU/ RAM to build the app as old-fashioned method. but Ii need to cool-down after the deploy finished. but It doesn't happen when using franakenphp.

This a normal workload of normal day:
Memory usage is seem stable

Image

This is issue happen when I deploy :

Image

The app is a classic Laravel (InertiaJs + Vue ).

I searched for the issue, I got the resolve_root_symlink can be harmful in our case.

"The 100% CPU spike is almost certainly a "cache thrashing" event where the engine is recursively trying to resolve paths that changed underneath it." LLM.

"resolve_root_symlink can actually cause a race condition during the exact millisecond Ansistrano runs ln -sfn." LLM

I tried to disable resolve_root_symlink (since it enabled by default in frankenphp). and using reload (service frankenphp reload) frankenphp service but still the issue persist .

It resolved only when I restart the frankenphp service (service frankenphp restart). Then the CPU/RAM usage cool down as normal usage.
As seeing in this graph.

Image

FrankenPHP v1.11.2 PHP 8.4 Caddy v2.10.2 h1:g/gTYjGMD0dec+UgMw8SnfmJ3I9+M2TdvoRL/Ovu6U8=

PHP 8.4.18 (cli) (built: Feb 13 2026 15:32:33) (ZTS gcc 10.2.1 x86_64) Copyright (c) The PHP Group Built by Static PHP <https://static-php.dev> #StandWithUkraine Zend Engine v4.4.18, Copyright (c) Zend Technologies with Zend OPcache v8.4.18, Copyright (c), by Zend Technologies

Ubuntu 24.04 . Installed frankenphp by apt.

Caddyfile. I tested both with resolve_root_symlink and resolve_root_symlink false.

{
	metrics

	frankenphp {
		num_threads 16
		max_threads auto
		max_wait_time 30s
		php_ini {
			upload_max_filesize 50M
			post_max_size 50M
			memory_limit 256M
			expose_php 0
		}
	}

}

example.com {
	import security.conf

	root * /var/www/html/current/public

	encode zstd gzip

	request_body {
		max_size 50MB
	}

	php_server {
		try_files {path} index.php
		resolve_root_symlink
	}

	log {
		output file /var/log/caddy/access.log
		format json
	}
}

Any thought please?

Thank you,!

Build Type

deb packages

Worker Mode

No

Operating System

GNU/Linux

CPU Architecture

x86_64

PHP configuration

-

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions