mirror of
https://github.com/php/doc-en.git
synced 2026-04-25 16:28:09 +02:00
e2695046bf
The current documentation implies that the apc.ttl setting would mark all cache entries as liable to be evicted if they have not been accessed in this many seconds. However, apc_cache_entry_expired() and apc_cache_entry_soft_expired() reveal that apc.ttl is only taken into account for entries that do not have an explicit TTL set. Accordingly, clarify that the effect of apc.ttl is limited only to entries that do not have an explicit TTL set.
392 lines
13 KiB
XML
392 lines
13 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<section xml:id="apcu.configuration" xmlns="http://docbook.org/ns/docbook">
|
|
&reftitle.runtime;
|
|
&extension.runtime;
|
|
<para>
|
|
Although the default APCu settings are fine for many installations, serious
|
|
users should consider tuning the following parameters.
|
|
</para>
|
|
<para>
|
|
There is one decision to be made configuring APCu.
|
|
How much memory is going to be allocated to APCu.
|
|
The ini directive that controls this is <literal>apc.shm_size</literal>
|
|
Read the sections on this carefully below.
|
|
</para>
|
|
<para>
|
|
Once the server is running, the <literal>apc.php</literal> script that
|
|
is bundled with the extension should be copied somewhere into the docroot and
|
|
viewed with a browser as it provides a detailed analysis of the internal
|
|
workings of APCu. If GD is enabled in PHP, it will even display some
|
|
interesting graphs.</para>
|
|
<para>
|
|
If APCu is working, the <literal>Cache full count
|
|
</literal> number (on the left) will display the number of times the cache
|
|
has reached maximum capacity and has had to evict entries to free up memory.
|
|
During eviction, if <literal>apc.ttl</literal> was specified, APCu will first
|
|
attempt to remove expired entries, i.e. entries whose TTL has either expired,
|
|
or entries that have no TTL set and haven't been accessed in the last
|
|
<literal>apc.ttl</literal> seconds. If <literal>apc.ttl</literal> was not set,
|
|
or removing expired entries did not free up enough space, APCu will clear the
|
|
entire cache.
|
|
</para>
|
|
<para>
|
|
The number of evictions should be minimal in a well-configured cache. If the
|
|
cache is constantly being filled, and thusly forcefully freed, the resulting
|
|
churning will have disparaging effects on script performance. The easiest way
|
|
to minimize this number is to allocate more memory for APCu.
|
|
</para>
|
|
<para>
|
|
When APCu is compiled with mmap support (Memory Mapping), it will use only one
|
|
memory segment, unlike when APCu is built with SHM (SysV Shared Memory) support
|
|
that uses multiple memory segments. MMAP does not have a maximum limit like SHM
|
|
does in <literal>/proc/sys/kernel/shmmax</literal>. In general MMAP support is
|
|
recommended because it will reclaim the memory faster when the webserver is
|
|
restarted and all in all reduces memory allocation impact at startup.
|
|
</para>
|
|
<para>
|
|
<table>
|
|
<title>APCu configuration options</title>
|
|
<tgroup cols="4">
|
|
<thead>
|
|
<row>
|
|
<entry>&Name;</entry>
|
|
<entry>&Default;</entry>
|
|
<entry>&Changeable;</entry>
|
|
<entry>&Changelog;</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry><link linkend="ini.apcu.enabled">apc.enabled</link></entry>
|
|
<entry>"1"</entry>
|
|
<entry>PHP_INI_SYSTEM</entry>
|
|
<entry></entry>
|
|
</row>
|
|
<row>
|
|
<entry><link linkend="ini.apcu.shm-segments">apc.shm_segments</link></entry>
|
|
<entry>"1"</entry>
|
|
<entry>PHP_INI_SYSTEM</entry>
|
|
<entry></entry>
|
|
</row>
|
|
<row>
|
|
<entry><link linkend="ini.apcu.shm-size">apc.shm_size</link></entry>
|
|
<entry>"32M"</entry>
|
|
<entry>PHP_INI_SYSTEM</entry>
|
|
<entry></entry>
|
|
</row>
|
|
<row>
|
|
<entry><link linkend="ini.apcu.entries-hint">apc.entries_hint</link></entry>
|
|
<entry>"4096"</entry>
|
|
<entry>PHP_INI_SYSTEM</entry>
|
|
<entry></entry>
|
|
</row>
|
|
<row>
|
|
<entry><link linkend="ini.apcu.ttl">apc.ttl</link></entry>
|
|
<entry>"0"</entry>
|
|
<entry>PHP_INI_SYSTEM</entry>
|
|
<entry></entry>
|
|
</row>
|
|
<row>
|
|
<entry><link linkend="ini.apcu.gc-ttl">apc.gc_ttl</link></entry>
|
|
<entry>"3600"</entry>
|
|
<entry>PHP_INI_SYSTEM</entry>
|
|
<entry></entry>
|
|
</row>
|
|
<row>
|
|
<entry><link linkend="ini.apcu.mmap-file-mask">apc.mmap_file_mask</link></entry>
|
|
<entry>NULL</entry>
|
|
<entry>PHP_INI_SYSTEM</entry>
|
|
<entry></entry>
|
|
</row>
|
|
<row>
|
|
<entry><link linkend="ini.apcu.slam-defense">apc.slam_defense</link></entry>
|
|
<entry>"1"</entry>
|
|
<entry>PHP_INI_SYSTEM</entry>
|
|
<entry></entry>
|
|
</row>
|
|
<row>
|
|
<entry><link linkend="ini.apcu.enable-cli">apc.enable_cli</link></entry>
|
|
<entry>"0"</entry>
|
|
<entry>PHP_INI_SYSTEM</entry>
|
|
<entry></entry>
|
|
</row>
|
|
<row>
|
|
<entry><link linkend="ini.apcu.use-request-time">apc.use_request_time</link></entry>
|
|
<entry>"0"</entry>
|
|
<entry>PHP_INI_ALL</entry>
|
|
<entry>Prior to APCu 5.1.19, the default was "1".</entry>
|
|
</row>
|
|
<row>
|
|
<entry><link linkend="ini.apcu.serializer">apc.serializer</link></entry>
|
|
<entry>"php"</entry>
|
|
<entry>PHP_INI_SYSTEM</entry>
|
|
<entry>Prior to APCu 5.1.15, the default was "default".</entry>
|
|
</row>
|
|
<row>
|
|
<entry><link linkend="ini.apcu.coredump-unmap">apc.coredump_unmap</link></entry>
|
|
<entry>"0"</entry>
|
|
<entry>PHP_INI_SYSTEM</entry>
|
|
<entry></entry>
|
|
</row>
|
|
<row>
|
|
<entry><link linkend="ini.apcu.preload-path">apc.preload_path</link></entry>
|
|
<entry>NULL</entry>
|
|
<entry>PHP_INI_SYSTEM</entry>
|
|
<entry></entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</table>
|
|
&ini.php.constants;
|
|
</para>
|
|
|
|
&ini.descriptions.title;
|
|
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry xml:id="ini.apcu.enabled">
|
|
<term>
|
|
<parameter>apc.enabled</parameter>
|
|
<type>bool</type>
|
|
</term>
|
|
<listitem>
|
|
<para>
|
|
<literal>apc.enabled</literal> can be set to 0 to disable APC. This is
|
|
primarily useful when APC is statically compiled
|
|
into PHP, since there is no other way to disable
|
|
it (when compiled as a DSO, the <literal>extension</literal>
|
|
line in <literal>php.ini</literal> can just be commented-out).
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry xml:id="ini.apcu.shm-segments">
|
|
<term>
|
|
<parameter>apc.shm_segments</parameter>
|
|
<type>int</type>
|
|
</term>
|
|
<listitem>
|
|
<para>
|
|
The number of shared memory segments to allocate
|
|
for the compiler cache. If APC is running out of
|
|
shared memory but <literal>apc.shm_size</literal>
|
|
is set as high as the system allows, raising
|
|
this value might prevent APC from exhausting its memory.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry xml:id="ini.apcu.shm-size">
|
|
<term>
|
|
<parameter>apc.shm_size</parameter>
|
|
<type>string</type>
|
|
</term>
|
|
<listitem>
|
|
<para>
|
|
The size of each shared memory segment given by a shorthand notation as
|
|
described in <link linkend="faq.using.shorthandbytes">this FAQ</link>.
|
|
By default, some systems (including most BSD
|
|
variants) have very low limits on the size of a
|
|
shared memory segment.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry xml:id="ini.apcu.entries-hint">
|
|
<term>
|
|
<parameter>apc.entries_hint</parameter>
|
|
<type>int</type>
|
|
</term>
|
|
<listitem>
|
|
<para>
|
|
A "hint" about the number of distinct variables that might be stored.
|
|
Set to zero or omit if not sure.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry xml:id="ini.apcu.ttl">
|
|
<term>
|
|
<parameter>apc.ttl</parameter>
|
|
<type>int</type>
|
|
</term>
|
|
<listitem>
|
|
<para>
|
|
Consider cache entries without an explicit TTL to be
|
|
expired if they have not been accessed in this many
|
|
seconds. Effectively, this allows such entries to be
|
|
removed opportunistically during a cache insert, or
|
|
prior to a full expunge. Note that because removal is
|
|
opportunistic, entries can still be readable even if
|
|
they are older than <literal>apc.ttl</literal> seconds.
|
|
This setting has no effect on cache entries that have
|
|
an explicit TTL specified.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry xml:id="ini.apcu.gc-ttl">
|
|
<term>
|
|
<parameter>apc.gc_ttl</parameter>
|
|
<type>int</type>
|
|
</term>
|
|
<listitem>
|
|
<para>
|
|
The number of seconds that a cache entry may
|
|
remain on the garbage-collection list. This value
|
|
provides a fail-safe in the event that a server
|
|
process dies while executing a cached source file;
|
|
if that source file is modified, the memory
|
|
allocated for the old version will not be
|
|
reclaimed until this TTL reached. Set to zero to
|
|
disable this feature.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry xml:id="ini.apcu.mmap-file-mask">
|
|
<term>
|
|
<parameter>apc.mmap_file_mask</parameter>
|
|
<type>string</type>
|
|
</term>
|
|
<listitem>
|
|
<para>
|
|
If compiled with MMAP support by using <literal>--enable-mmap</literal>
|
|
this is the mktemp-style file_mask to pass to the
|
|
mmap module for determining whether your mmap'ed memory
|
|
region is going to be file-backed or shared memory
|
|
backed. For straight file-backed mmap, set it to
|
|
something like <literal>/tmp/apc.XXXXXX</literal>
|
|
(exactly 6 <literal>X</literal>s).
|
|
To use POSIX-style shm_open/mmap put a <literal>.shm</literal>
|
|
somewhere in your mask. e.g. <literal>/apc.shm.XXXXXX</literal>
|
|
You can also set it to <literal>/dev/zero</literal> to use your
|
|
kernel's <literal>/dev/zero</literal> interface to anonymous mmap'ed
|
|
memory. Leaving it undefined will force an anonymous mmap.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry xml:id="ini.apcu.slam-defense">
|
|
<term>
|
|
<parameter>apc.slam_defense</parameter>
|
|
<type>int</type>
|
|
</term>
|
|
<listitem>
|
|
<para>
|
|
On very busy servers whenever you start the server or
|
|
modify files you can create a race of many processes
|
|
all trying to cache the same file at the same time.
|
|
This option sets the percentage of processes that will
|
|
skip trying to cache an uncached file. Or think of it
|
|
as the probability of a single process to skip caching.
|
|
For example, setting <literal>apc.slam_defense</literal>
|
|
to <literal>75</literal> would mean that there is
|
|
a 75% chance that the process will not cache an uncached
|
|
file. So, the higher the setting the greater the defense
|
|
against cache slams. Setting this to <literal>0</literal>
|
|
disables this feature.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry xml:id="ini.apcu.enable-cli">
|
|
<term>
|
|
<parameter>apc.enable_cli</parameter>
|
|
<type>int</type>
|
|
</term>
|
|
<listitem>
|
|
<para>
|
|
Mostly for testing and debugging. Setting this enables APC
|
|
for the CLI version of PHP. Under normal circumstances, it is
|
|
not ideal to create, populate and destroy the APC cache on every
|
|
CLI request, but for various test scenarios it is useful to be
|
|
able to enable APC for the CLI version of PHP easily.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry xml:id="ini.apcu.serializer">
|
|
<term>
|
|
<parameter>apc.serializer</parameter>
|
|
<type>string</type>
|
|
</term>
|
|
<listitem>
|
|
<para>
|
|
Used to configure APC to use a third party serializer.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry xml:id="ini.apcu.coredump-unmap">
|
|
<term>
|
|
<parameter>apc.coredump_unmap</parameter>
|
|
<type>bool</type>
|
|
</term>
|
|
<listitem>
|
|
<para>
|
|
Enables APC handling of signals, such as SIGSEGV, that write
|
|
core files when signaled. When these signals are received,
|
|
APC will attempt to unmap the shared memory segment in order
|
|
to exclude it from the core file. This setting may improve
|
|
system stability when fatal signals are received and a large
|
|
APC shared memory segment is configured.
|
|
</para>
|
|
<warning>
|
|
<para>
|
|
This feature is potentially dangerous. Unmapping the shared
|
|
memory segment in a fatal signal handler may cause undefined
|
|
behaviour if a fatal error occurs.
|
|
</para>
|
|
</warning>
|
|
<note>
|
|
<para>
|
|
Although some kernels may provide a facility to ignore various
|
|
types of shared memory when generating a core dump file, these
|
|
implementations may also ignore important shared memory segments
|
|
such as the Apache scoreboard.
|
|
</para>
|
|
</note>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry xml:id="ini.apcu.preload-path">
|
|
<term>
|
|
<parameter>apc.preload_path</parameter>
|
|
<type>string</type>
|
|
</term>
|
|
<listitem>
|
|
<para>
|
|
Optionally, set a path to the directory that APC will load
|
|
cache data at startup.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
|
|
<varlistentry xml:id="ini.apcu.use-request-time">
|
|
<term>
|
|
<parameter>apc.use_request_time</parameter>
|
|
<type>bool</type>
|
|
</term>
|
|
<listitem>
|
|
<para>
|
|
Use the <acronym>SAPI</acronym> request start time for
|
|
<acronym>TTL</acronym>.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</section>
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|