search
HomeBackend DevelopmentPHP TutorialAnalysis of two sets of configuration files and parameters of PHP APC

This article mainly introduces 2 sets of PHP APC configuration files and detailed parameters. Friends who need it can refer to

1. Install APC

The compilation parameters are as follows:

./configure --enable-apc --enable-apc-spinlocks --disable-apc-pthreadmutex

I won’t go into the installation process, the standard PHP extension installation mode.

2. 2 sets of configuration files

High performance, not suitable for frequent updates:

apc.enabled=1
apc.stat = 0
apc.stat_ctime = 0
apc.shm_size = 64M
apc.shm_segments = 1
apc.num_files_hint = 1000
apc.ttl = 0
apc.slam_defense = 0
apc.write_lock = 1
apc.file_update_protection = 2

Slightly lower performance:

apc.enabled=1
apc.stat = 1
apc.stat_ctime = 1
apc.shm_size = 64M
apc.shm_segments = 1
apc.num_files_hint = 1000
apc.ttl = 86400
apc.slam_defense = 0
apc.write_lock = 1
apc.file_update_protection = 2

The key to the 2 sets of configurations is apc.stat. After it is turned on, APC will not check whether the file is updated, so you can Reduce a large number of unnecessary system calls.
However, for newly released problems, PHP needs to be restarted. You can choose according to the situation.

In addition, attach a parameter description:

apc.enabled boolean
apc.enabled can be set to 0 to disable APC. It is mainly used when APC is statically compiled into PHP, because there is no other way to disable it (compiled as DSO, you can comment out the extension line in php.ini).

apc.shm_segments integer
The number of shared memory blocks to be allocated by the compiler cache. If APC runs out of shared memory but has set apc.shm_size to the maximum allowed by the system, you can try increasing this value.

apc.shm_size integer
The size of each shared memory block in MB. Some systems (including most BSD variants) have a very low shared memory block size by default.

apc.optimization integer
Optimization level. Set to 0 to disable the optimizer, higher values ​​to use more aggressive optimization. Expect very limited speed improvements. Still in testing.

apc.num_files_hint integer
A rough estimate of the number of different origin files that are included or requested on the Web server. Set to 0 or remove this option if unsure; this setting is mainly used on sites with thousands of source files.

apc.user_entries_hint integer
Similar to apc.num_files_hint, stores cache variables based on the number of unique users. If unsure, set it to 0 or remove this item.

apc.ttl integer
The number of seconds the cache entry is allowed to stay in the buffer. 0 means never times out. The recommended value is 7200~86400. Setting it to 0 means that the buffer may be filled with old cache entries, resulting in the inability to cache new entries.

apc.user_ttl integer
Similar to apc.ttl, but for each user, the recommended value is 7200~86400. Setting to 0 means that the buffer may fill up with old cache entries, preventing new entries from being cached. If greater than 0, APC will attempt to delete expired entries.

apc.gc_ttl integer
The number of seconds the cache entry can exist in the garbage collection table. This value provides a safety measure that if the file is modified while the server process is executing a cached source file, the older version will not be recycled until this TTL is reached. Set to zero to disable this feature.

apc.cache_by_default boolean
The default is on, but it can be set to off and used together with apc.filters starting with a plus sign, then the file will only be cached when matching the filter .

apc.filters string
A comma-separated list of POSIX extended regular expressions. If any of the patterns match the source file name, the file is not cached. Note that the file name used to match is the file name passed to include/require, not the absolute path. If the first character of the regular expression is t it means any file matching the expression will be cached, if the first character is - then any matches will not be cached. - is the default value and can be omitted.

apc.mmap_file_mask string
If MMAP support was compiled for APC using --enable-mmap (enabled by default), the value here is the mktemp-style file passed to the mmap module Mask (recommended value is "/tmp/apc.XXXXXX"). This mask is used to determine whether the memory mapped area should be file-backed or shared memory backed. For direct file-backed memory mapping, set it to look like "/tmp/apc.XXXXXX" (exactly 6 X's). To use POSIX-style shm_open/mmap you need to set it to "/apc.shm.XXXXXX". You can also set it to "/dev/zero" to use the kernel's "/dev/zero" interface for anonymously mapped memory. Not defining this directive forces the use of anonymous mapping.

apc.slam_defense integer
On a very busy server, whether starting a service or modifying a file, a race condition may result from multiple processes trying to cache a file at the same time. This option sets the percentage at which the process skips the caching step when processing files that have not been cached. For example, setting it to 75 means that there is a 75% probability of not caching when an uncached file is encountered, thereby reducing the chance of collision. Use of this directive is deprecated and is encouraged to be set to 0 to disable this feature. It is recommended to use the apc.write_lock instruction.

Deprecated by apc.write_lock.

apc.file_update_protection integer
When you modify files on a running server, you should perform atomic operations. That is, first write to a temporary file, and then rename (mv) the file to the final name. Text editors and programs such as cp and tar do not operate in this way, resulting in the possibility of buffering incomplete files. The default value 2 means that when accessing a file, if the modification time is found to be less than 2 seconds from the access time, no buffering will be performed. The unlucky visitor may get corrupted content, but the bad effect is not magnified by caching. If you can ensure that all update operations are atomic, you can turn off this feature with 0. If your system updates slowly due to heavy IO operations, you may need to increase this value.

apc.enable_cli integer
Whether to enable APC functionality for the CLI version, turn this option on only for testing and debugging purposes. Under normal circumstances it is not ideal to create, populate and destroy the APC cache on every request to the CLI, but it is useful in various testing scenarios to be able to easily make the CLI version of PHP APC

apc. max_file_size integer
Default is 1M, files larger than this value will not be cached.

apc.stat integer
Whether to enable script update check. Be very careful when changing this command value. The default value On indicates that APC checks whether the script has been updated each time it is requested. If it is updated, it will automatically recompile and cache the compiled content. However, doing so has a negative impact on performance. If set to Off, no checking is performed, resulting in significant performance improvements. But in order for the updated content to take effect, you must restart the web server (Translator's Note: If you use cgi/fcgi, you need to restart the cgi/fcgi process). On production servers where script files rarely change, significant performance improvements can be achieved by disabling this option.

This directive is also valid for include/require files. But it should be noted that if you use a relative path, APC must check to locate the file every time include/require. Using absolute paths can skip the check, so you are encouraged to use absolute paths for include/require operations.

apc.write_lock boolean
On a busy server, when the web server is started for the first time, or many files are modified at the same time, APC may compile the same file multiple times File, write lock guarantees that only one process will attempt to compile and cache an uncached script. Other processes trying to use the script will not use the opcode cache, instead locking and waiting for the cache to be generated.

apc.report_autofilter boolean
Whether to record all scripts that are automatically not cached due to early/late binding reasons.

apc.include_once_override boolean
Optimize the include_once() and require_once() functions to avoid executing additional system calls.

apc.rfc1867 boolean
Enable monitoring file upload progress function

apc.rfc1867_prefix string
Buffering for uploading files Item entry name prefix

apc.rfc1867_name string
Hidden form item name for uploaded files that need to be processed by APC

apc.rfc1867_freq string
Update frequency of user uploaded file cache items. The value can be a percentage of the total file size, or an absolute size (case-insensitive) ending in "k", "m", or "g" kilobytes, megabytes, or gigabytes. 0 means the fastest possible update, but This may result in slower upload speeds.

apc.rfc1867_ttl bool
TTL for rfc1867 entries.

apc.localcache boolean
Use non-locking local process shadow- cache, which reduces competition between locks when writing to the buffer.

apc.localcache.size integer
The size of the local process shadow-cache, should be set to a sufficiently large value, approximately half of apc.num_files_hint.

apc.coredump_unmap boolean
Enable APC signal handler, such as SIGSEGV signal, when the signal is written to the core file. When these signals are received, APC will attempt to unmap the shared memory segment, excluding it from the core file. This setting can improve system stability when receiving a fatal signal or using APC's large shared memory segment configuration.

apc.stat_ctime integer
Verifying ctime (creation time) can avoid problems caused by SVN or rsync and ensure that the inode has not changed since the last statistics. APC usually only checks mtime (modification time).

apc.canonicalize bool
If set to on, the relative path will be changed to an absolute path in no-state mode (no checking for file updates).

apc.preload_path string
apc.use_request_time bool
Use the SAPI request start time for TTL.

apc.file_md5 bool
Record the md5 value of the file

##apc.lazy_functions integer
Enable function lazy loading

apc.lazy_classes integer
Enable class lazy loading

The above is the entire content of this article. I hope it will be helpful to everyone's study. For more related content, please pay attention to the PHP Chinese website!

Related recommendations:

3 ways to generate random numbers in PHP

Comparison of commonly used framework functions in PHP

The above is the detailed content of Analysis of two sets of configuration files and parameters of PHP APC. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
php怎么把负数转为正整数php怎么把负数转为正整数Apr 19, 2022 pm 08:59 PM

php把负数转为正整数的方法:1、使用abs()函数将负数转为正数,使用intval()函数对正数取整,转为正整数,语法“intval(abs($number))”;2、利用“~”位运算符将负数取反加一,语法“~$number + 1”。

php怎么实现几秒后执行一个函数php怎么实现几秒后执行一个函数Apr 24, 2022 pm 01:12 PM

实现方法:1、使用“sleep(延迟秒数)”语句,可延迟执行函数若干秒;2、使用“time_nanosleep(延迟秒数,延迟纳秒数)”语句,可延迟执行函数若干秒和纳秒;3、使用“time_sleep_until(time()+7)”语句。

php字符串有没有下标php字符串有没有下标Apr 24, 2022 am 11:49 AM

php字符串有下标。在PHP中,下标不仅可以应用于数组和对象,还可应用于字符串,利用字符串的下标和中括号“[]”可以访问指定索引位置的字符,并对该字符进行读写,语法“字符串名[下标值]”;字符串的下标值(索引值)只能是整数类型,起始值为0。

php怎么除以100保留两位小数php怎么除以100保留两位小数Apr 22, 2022 pm 06:23 PM

php除以100保留两位小数的方法:1、利用“/”运算符进行除法运算,语法“数值 / 100”;2、使用“number_format(除法结果, 2)”或“sprintf("%.2f",除法结果)”语句进行四舍五入的处理值,并保留两位小数。

php怎么根据年月日判断是一年的第几天php怎么根据年月日判断是一年的第几天Apr 22, 2022 pm 05:02 PM

判断方法:1、使用“strtotime("年-月-日")”语句将给定的年月日转换为时间戳格式;2、用“date("z",时间戳)+1”语句计算指定时间戳是一年的第几天。date()返回的天数是从0开始计算的,因此真实天数需要在此基础上加1。

php怎么读取字符串后几个字符php怎么读取字符串后几个字符Apr 22, 2022 pm 08:31 PM

在php中,可以使用substr()函数来读取字符串后几个字符,只需要将该函数的第二个参数设置为负值,第三个参数省略即可;语法为“substr(字符串,-n)”,表示读取从字符串结尾处向前数第n个字符开始,直到字符串结尾的全部字符。

php怎么替换nbsp空格符php怎么替换nbsp空格符Apr 24, 2022 pm 02:55 PM

方法:1、用“str_replace(" ","其他字符",$str)”语句,可将nbsp符替换为其他字符;2、用“preg_replace("/(\s|\&nbsp\;||\xc2\xa0)/","其他字符",$str)”语句。

php怎么查找字符串是第几位php怎么查找字符串是第几位Apr 22, 2022 pm 06:48 PM

查找方法:1、用strpos(),语法“strpos("字符串值","查找子串")+1”;2、用stripos(),语法“strpos("字符串值","查找子串")+1”。因为字符串是从0开始计数的,因此两个函数获取的位置需要进行加1处理。

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft