Why is this certain PHP installation so slow?

154 Views Asked by At

I have a VPS under Ubuntu 20, running php (php-fpm), installed the ordinary way from ppa:ondrej/php repo. And it has Opcache enabled by default, and I would expect for server like this to complete a request (for example default vanilla Laravel page) for not more than 80 ms. But actually it is more than 750 ms (according to Clockwork). This can not be right.

The settings are a lot, could you tell me where to start tweaking?

Some parts of the config which may matter:

APCu Support    Enabled
Version 5.1.22
APCu Debugging  Disabled
MMAP Support    Enabled
MMAP File Mask  no value
Serialization Support   php
apc.coredump_unmap  Off Off
apc.enable_cli  Off Off
apc.enabled On  On
apc.entries_hint    4096    4096
apc.gc_ttl  3600    3600
apc.mmap_file_mask  no value    no value
apc.preload_path    no value    no value
apc.serializer  php php
apc.shm_segments    1   1
apc.shm_size    32M 32M
apc.slam_defense    Off Off
apc.smart   0   0
apc.ttl 0   0
apc.use_request_time    Off Off

...

Opcode Caching  Up and Running
Optimization    Enabled
SHM Cache   Enabled
File Cache  Disabled
JIT Disabled
Startup OK
Shared memory model mmap
Cache hits  582
Cache misses    654
Used memory 24600512
Free memory 109617216
Wasted memory   0
Interned Strings Used memory    5320360
Interned Strings Free memory    3068248
Cached scripts  654
Cached keys 1246
Max keys    16229
OOM restarts    0
Hash keys restarts  0
Manual restarts 0
Directive   Local Value Master Value
opcache.blacklist_filename  no value    no value
opcache.consistency_checks  0   0
opcache.dups_fix    Off Off
opcache.enable  On  On
opcache.enable_cli  Off Off
opcache.enable_file_override    Off Off
opcache.error_log   no value    no value
opcache.file_cache  no value    no value
opcache.file_cache_consistency_checks   On  On
opcache.file_cache_only Off Off
opcache.file_update_protection  2   2
opcache.force_restart_timeout   180 180
opcache.huge_code_pages Off Off
opcache.interned_strings_buffer 8   8
opcache.jit tracing tracing
opcache.jit_bisect_limit    0   0
opcache.jit_blacklist_root_trace    16  16
opcache.jit_blacklist_side_trace    8   8
opcache.jit_buffer_size 0   0
opcache.jit_debug   0   0
opcache.jit_hot_func    127 127
opcache.jit_hot_loop    64  64
opcache.jit_hot_return  8   8
opcache.jit_hot_side_exit   8   8
opcache.jit_max_exit_counters   8192    8192
opcache.jit_max_loop_unrolls    8   8
opcache.jit_max_polymorphic_calls   2   2
opcache.jit_max_recursive_calls 2   2
opcache.jit_max_recursive_returns   2   2
opcache.jit_max_root_traces 1024    1024
opcache.jit_max_side_traces 128 128
opcache.jit_prof_threshold  0.005   0.005
opcache.lockfile_path   /tmp    /tmp
opcache.log_verbosity_level 1   1
opcache.max_accelerated_files   10000   10000
opcache.max_file_size   0   0
opcache.max_wasted_percentage   5   5
opcache.memory_consumption  128 128
opcache.opt_debug_level 0   0
opcache.optimization_level  0x7FFEBFFF  0x7FFEBFFF
opcache.preferred_memory_model  no value    no value
opcache.preload no value    no value
opcache.preload_user    no value    no value
opcache.protect_memory  Off Off
opcache.record_warnings Off Off
opcache.restrict_api    no value    no value
opcache.revalidate_freq 2   2
opcache.revalidate_path Off Off
opcache.save_comments   On  On
opcache.use_cwd On  On
opcache.validate_permission Off Off
opcache.validate_root   On  On
opcache.validate_timestamps On  On

Thanks

1

There are 1 best solutions below

1
Blum On

I solved it. So, here are completely identical requests, to the same page of the same website. enter image description here

enter image description here

The first is with FastCGI PHP 8.2 set by ISPConfig. It turns php by

/var/www/php-fcgi-scripts/web23/.php-fcgi-starter

which includes quite long open_basedir list. According to this answer:

Realpath cache is disabled if safe_mode or open_basedir are set. This dramatically reduce performance of PHP Engine and this behavior can bring a server to its knees.

The second screenshot is with my own php.fcgi, no open_basedir added. More than 20 times faster.

Cheers