PHP APC Configuration file 2 sets and parameters detailed _php tips

Source: Internet
Author: User
Tags anonymous apc apc configuration garbage collection posix

First, the installation of APC
Download http://pecl.php.net/get/APC-3.1.9.tgz

The compilation parameters are as follows:

Copy Code code as follows:
./configure--ENABLE-APC--enable-apc-spinlocks--disable-apc-pthreadmutex

The installation process is not said, the standard PHP extended installation mode.

Two, 2 sets of configuration files

High performance, not suitable for frequent updates:

Copy Code code as follows:
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:
Copy Code code as follows:
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

2 sets of configuration key is Apc.stat, after the APC will not check the file is updated, this can reduce a large number of unnecessary system calls.
However, you will need to restart PHP for newly released issues. Can be selected according to the situation.

In addition, the parameter description is attached:

Apc.enabled Boolean

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

Apc.shm_segments integer

The number of shared memory blocks that the compiler caches to allocate. You can try to increase this value if the APC runs out of shared memory but has set the apc.shm_size to the maximum that the system can allow.

Apc.shm_size integer

The size of each shared memory block in megabytes. By default, some systems, including most BSD variants, have a very low shared memory block size.

Apc.optimization integer

Optimization level. Set to 0 disables the optimizer, while higher values use more proactive optimizations. Expect very limited speed to ascend. is still in the experiment.

Apc.num_files_hint integer

The approximate estimate of the number of different source files that are contained or requested on the WEB server. If unsure, set to 0 or remove this item, which is mainly used in sites with thousands of source files.

Apc.user_entries_hint integer

Like Apc.num_files_hint, cache variables are stored based on the number of unique users. If you are unsure, set to 0 or remove this item.

Apc.ttl integer

The number of seconds the cache entry allowed to linger in the buffer. 0 means never times out. A recommended value of 7200~86400 set 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, the recommended value is 7200~86400 for each user. A setting of 0 means that the buffer may be filled with old cache entries, resulting in the inability to cache new entries. 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 security measure that when a server process executes a cached source file, the old version will not be reclaimed until the TTL is reached if the file is modified. Setting to zero disables this attribute.

Apc.cache_by_default Boolean

The default is on, but can be set to off and used with a apc.filters that begins with a plus sign, the file is cached only when the filter is matched.

Apc.filters string

A comma-delimited list of POSIX-extended regular expressions. If either pattern matches the source file name, the file is not cached. Note the filename 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 that any file that matches the expression will be cached, and if the first character is-then no matches will be cached. -is the default value and can be omitted.

Apc.mmap_file_mask string

If you compile MMAP support for APC using--ENABLE-MMAP (default enabled), the value here is the Mktemp-style file mask passed to the Mmap module (the recommended value is/TMP/APC. XXXXXX "). The mask is used to determine whether the memory-mapped area is to be file-backed or shared memory backed. For a direct file-backed memory mapping, set to "/TMP/APC." XXXXXX "appearance (exactly 6 x). To use POSIX-style shm_open/mmap, you need to set it to "/apc.shm.xxxxxx." You can also set the "/dev/zero" to use the kernel's "/dev/zero" interface for anonymous mapped memory. Not defining this directive means enforcing the use of anonymous mappings.

Apc.slam_defense integer

On very busy servers, either starting a service or modifying a file can cause a race condition because multiple processes attempt to cache a file at the same time. This option is used to set the percentage of steps that the process skips when processing files that are not cached. For example, set to 75 means that when you encounter a file that is not cached, 75% of the probability is not cached, thereby reducing the collision probability. Against the use of this directive, encourage the setting to 0来 to disable this feature. It is recommended that the Apc.write_lock directive be used.

Deprecated by Apc.write_lock.

Apc.file_update_protection integer

When you modify a file on a running server, you should perform an atomic operation. That is, first write in a temporary file, and then rename the file (MV) to the final name. Programs such as text editors and CP, TAR, and so on, do not operate this way, resulting in the possibility of buffering the defective files. The default value of 2 indicates that when the file is accessed, it is not buffered if it finds that the modified time distance is less than 2 seconds. The unfortunate visitor may get the incomplete content, but the bad effect will not be magnified by the cache. If you can make sure that all of the update operations are atomic, you can turn off this feature with 0. If your system is slow to update due to a large number of IO operations, you need to increase this value.

APC.ENABLE_CLI integer

Whether to enable APC for the CLI version and open this option only for testing and debugging purposes. Under normal circumstances it is not ideal to create, populate, and destroy the APC cache on each request of the CLI, but various test scenarios are useful to make it easy for the CLI version of the PHP APC

Apc.max_file_size integer

The default 1M, for files that are larger than this value, will not be cached.

Apc.stat integer

Whether to enable script update checking. Change this instruction value to be very careful. The default value on indicates that the APC checks whether the script is updated each time the script is requested and automatically recompile and cache the compiled content if it is updated. But doing so has a detrimental effect on performance. If set to OFF, the performance is significantly improved by not checking. But in order for the updated content to take effect, you must restart the Web server (note: If you use cgi/fcgi similar, you need to restart the cgi/fcgi process). The script files on the production server are rarely changed, and you can achieve significant performance gains by disabling this option.

This instruction is also valid for Include/require files. However, it is important to note that if you are using a relative path, the APC must check every time it include/require to locate the file. Using an absolute path allows you to skip the check, so you are encouraged to use an absolute path for include/require operations.

Apc.write_lock Boolean

On a busy server, the Web server is first started, or many files are modified at the same time, the APC may compile the same file multiple times, and the write lock guarantees that only one process will attempt to compile and cache the cached script. Other processes attempting to use the script will not use the opcode cache, instead of locking and waiting for cache generation.

Apc.report_autofilter Boolean

Whether to log 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 performing additional system calls.

apc.rfc1867 Boolean

Turn on the monitoring file upload progress function

Apc.rfc1867_prefix string

Buffer entry name prefix for uploading files

Apc.rfc1867_name string

Hidden table item name for uploaded files that need to be processed by APC

Apc.rfc1867_freq string

The frequency at which users upload file cache entries. The value can be a percentage of the total file size, or an absolute dimension (insensitive to case insensitive) ending with "K", "M", or "G" kilobytes, megabytes, or gigabytes. 0 indicates that the update is as fast as possible, but this may result in a drop in upload speed.

APC.RFC1867_TTL BOOL

TTL for rfc1867 entries.

Apc.localcache Boolean

Using a Shadow-cache local process, it can reduce the contention between locks when writing to a buffer.

Apc.localcache.size integer

The size of the local process Shadow-cache, should is set to a sufficiently large value, approximately half of Apc.num_fil Es_hint.

Apc.coredump_unmap Boolean

Enable the APC's signal handle, such as the SIGSEGV signal, when the signal is written to the core file. When these signals are received, APC will attempt to cancel the mapped shared memory segment and exclude it from the core file. This setting can improve system stability when receiving fatal signals or using APC's large shared memory segment configuration.

Apc.stat_ctime integer

Verifying CTime (creation time) avoids problems with SVN or rsync and ensures that the inode has not changed since the last time the statistics were used. APC usually only checks Mtime (modification time).

apc.canonicalize BOOL

If set to ON, the relative path is changed to an absolute path in no-state mode (without checking for file updates).

Apc.preload_path string

apc.use_request_time BOOL
Use the SAPI request to start time for TTL.

APC.FILE_MD5 BOOL

MD5 value of the record file

Apc.lazy_functions integer

Enable function Delay loading

Apc.lazy_classes integer

Enable class deferred loading

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.