Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Snuffleupagus associated with high CPU load #481

Open
gnd opened this issue Jan 26, 2024 · 6 comments
Open

Snuffleupagus associated with high CPU load #481

gnd opened this issue Jan 26, 2024 · 6 comments
Assignees

Comments

@gnd
Copy link

gnd commented Jan 26, 2024

Hello,

we recently activated Snuffleupagus on a AMD 2core 8gb ram VM in GCP. We are using it with one php8.2 FPM pool. The machine has literally zero traffic as it being used only sporadically for some tests.

However after enabling Snufleupagus the CPU load has gone to 100% making it hard to work with the box.

After tweaking around we found out that the load goes away as soon as we disable Snuffleupagus and comes back after enabling it.

Do you have any ideas what might have caused this ? We are running Snuffleupagus also on other machines but have not encountered this issue before. Do you have some benchmarks that would show how much Snuffleupagus consumes when in "rest" conditions (eg. no traffic to PHP) ?

@gnd gnd changed the title Snuffleupagus associates with high cpu load Snuffleupagus associated with high CPU load Jan 26, 2024
@gnd
Copy link
Author

gnd commented Jan 26, 2024

Nevermind, i found the issue: we were loading a non-existent rules file but also having this option on:

sp.allow_broken_configuration=true

closing the issue

@gnd gnd closed this as completed Jan 26, 2024
@jvoisin jvoisin self-assigned this Jan 26, 2024
@jvoisin jvoisin reopened this Jan 26, 2024
@jvoisin
Copy link
Owner

jvoisin commented Jan 26, 2024

Snuffleupagus shouldn't eat all the CPU even when provided with an invalid config.

@deba12
Copy link

deba12 commented Jan 26, 2024

We have High CPU usage too, i will check for broken config later today and report back.

@wargio
Copy link
Collaborator

wargio commented Jan 27, 2024

please provide a configuration which allows us to reproduce this.

@gnd
Copy link
Author

gnd commented Jan 29, 2024

Hello, sorry for delay, i was trying to find the minimal setup that can replicate this. If you follow these steps on a fresh Debian i believe you should be able to replicate the issue:

Install minimal PHP packages:

# apt-get purge php*
# apt autoremove
# apt-get install php8.2-fpm php8.2-dev

Compile Snuffleupagus:

$ git clone https://github.com/jvoisin/snuffleupagus
$ cd snuffleupagus/src
$ phpize
$ ./configure --enable-snuffleupagus
$ make
$ make install

Create a new FPM pool:

# rm /etc/php/8.2/fpm/pool.d/www.conf 
# vi /etc/php/8.2/fpm/pool.d/www.conf 

Add this minimal FPM config:

[www]
user = www-data
group = www-data
listen = 127.0.0.1:9000
listen.owner = www-data
listen.group = www-data

; Choose how the process manager will control the number of child processes. 
pm = ondemand
pm.max_children = 150
pm.start_servers = 1
pm.min_spare_servers = 3
pm.max_spare_servers = 10 
pm.process_idle_timeout = 10s

; ext-snuffleupagus
php_admin_value[sp.configuration_file] = /etc/snuffleupagus/nonexistent.rules

Add an empty directory for Snuffleupagus rules:

# mkdir -p /etc/snuffleupagus

Load Snuffleupagus into PHP:

# vi /etc/php/8.2/fpm/php.ini

Add these lines to the top of the file:

extension=snuffleupagus.so
sp.allow_broken_configuration=true

Restart FPM:

# service php8.2-fpm restart

Watch the logs:

# tail -f /var/log/php8.2-fpm.log

[29-Jan-2024 14:46:58] NOTICE: fpm is running, pid 457231
[29-Jan-2024 14:46:58] NOTICE: ready to handle connections
[29-Jan-2024 14:46:58] NOTICE: systemd monitor interval set to 10000ms

Keep log open. All is OK until any request comes to FPM. Simulate by a curl call to port 9000 in a new shell:

$ curl localhost:9000

Log now looks like this and load goes up:

[29-Jan-2024 14:48:30] NOTICE: [pool www] child 459856 started
[29-Jan-2024 14:48:30] WARNING: [pool www] child 459856 exited with code 255 after 0.001239 seconds from start
[29-Jan-2024 14:48:30] NOTICE: [pool www] child 459857 started
[29-Jan-2024 14:48:30] WARNING: [pool www] child 459857 exited with code 255 after 0.001296 seconds from start
[29-Jan-2024 14:48:30] NOTICE: [pool www] child 459858 started
[29-Jan-2024 14:48:30] WARNING: [pool www] child 459858 exited with code 255 after 0.001267 seconds from start
[29-Jan-2024 14:48:30] NOTICE: [pool www] child 459859 started
[29-Jan-2024 14:48:30] WARNING: [pool www] child 459859 exited with code 255 after 0.001247 seconds from start
[29-Jan-2024 14:48:30] NOTICE: [pool www] child 459860 started
[29-Jan-2024 14:48:30] WARNING: [pool www] child 459860 exited with code 255 after 0.001270 seconds from start
[29-Jan-2024 14:48:30] NOTICE: [pool www] child 459861 started
[29-Jan-2024 14:48:30] WARNING: [pool www] child 459861 exited with code 255 after 0.001240 seconds from start
[29-Jan-2024 14:48:30] NOTICE: [pool www] child 459862 started
[29-Jan-2024 14:48:30] WARNING: [pool www] child 459862 exited with code 255 after 0.001261 seconds from start
[29-Jan-2024 14:48:30] NOTICE: [pool www] child 459863 started

@jvoisin
Copy link
Owner

jvoisin commented Jan 29, 2024

It seems that PHP doesn't like when one of its processes exists, so it keep trying to respawn new ones, sigh.

I guess screaming in the logs and returning "Success, everything's dandy!" is the way to go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants