| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 
 | <?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><constant>INI_SYSTEM</constant></entry>
      <entry></entry>
     </row>
     <row>
      <entry><link linkend="ini.apcu.shm-segments">apc.shm_segments</link></entry>
      <entry>1</entry>
      <entry><constant>INI_SYSTEM</constant></entry>
      <entry></entry>
     </row>
     <row>
      <entry><link linkend="ini.apcu.shm-size">apc.shm_size</link></entry>
      <entry>"32M"</entry>
      <entry><constant>INI_SYSTEM</constant></entry>
      <entry></entry>
     </row>
     <row>
      <entry><link linkend="ini.apcu.entries-hint">apc.entries_hint</link></entry>
      <entry>4096</entry>
      <entry><constant>INI_SYSTEM</constant></entry>
      <entry></entry>
     </row>
     <row>
      <entry><link linkend="ini.apcu.ttl">apc.ttl</link></entry>
      <entry>0</entry>
      <entry><constant>INI_SYSTEM</constant></entry>
      <entry></entry>
     </row>
     <row>
      <entry><link linkend="ini.apcu.gc-ttl">apc.gc_ttl</link></entry>
      <entry>3600</entry>
      <entry><constant>INI_SYSTEM</constant></entry>
      <entry></entry>
     </row>
     <row>
      <entry><link linkend="ini.apcu.mmap-file-mask">apc.mmap_file_mask</link></entry>
      <entry>NULL</entry>
      <entry><constant>INI_SYSTEM</constant></entry>
      <entry></entry>
     </row>
     <row>
      <entry><link linkend="ini.apcu.slam-defense">apc.slam_defense</link></entry>
      <entry>0</entry>
      <entry><constant>INI_SYSTEM</constant></entry>
      <entry></entry>
     </row>
     <row>
      <entry><link linkend="ini.apcu.enable-cli">apc.enable_cli</link></entry>
      <entry>0</entry>
      <entry><constant>INI_SYSTEM</constant></entry>
      <entry></entry>
     </row>
     <row>
      <entry><link linkend="ini.apcu.use-request-time">apc.use_request_time</link></entry>
      <entry>0</entry>
      <entry><constant>INI_ALL</constant></entry>
      <entry>Prior to APCu 5.1.19, the default was <literal>1</literal>.</entry>
     </row>
     <row>
      <entry><link linkend="ini.apcu.serializer">apc.serializer</link></entry>
      <entry>"php"</entry>
      <entry><constant>INI_SYSTEM</constant></entry>
      <entry>Prior to APCu 5.1.15, the default was <literal>"default"</literal>.</entry>
     </row>
     <row>
      <entry><link linkend="ini.apcu.coredump-unmap">apc.coredump_unmap</link></entry>
      <entry>0</entry>
      <entry><constant>INI_SYSTEM</constant></entry>
      <entry></entry>
     </row>
     <row>
      <entry><link linkend="ini.apcu.preload-path">apc.preload_path</link></entry>
      <entry>NULL</entry>
      <entry><constant>INI_SYSTEM</constant></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>bool</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.
      Setting <literal>apc.slam_defense</literal> to <literal>1</literal>
      can help prevent multiple processes from caching the
      same file simultaneously by introducing a probability
      mechanism. If the same key is attempted to be cached
      within a short period by different processes, it skips
      the caching for the current process to mitigate potential
      cache slams.
     </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
-->
 |