Analysis of apc extension in php (2)

Source: Internet
Author: User
Tags apc
: This article mainly introduces the apc extension analysis of php (2). If you are interested in the PHP Tutorial, please refer to it. "Runtime Settings": the configuration information of the running apc is displayed here. we can adjust the apc parameter as needed. the parameter Settings are carried out in php. ini.


There are many apc parameters. The following describes several commonly used parameters:

1 apc. cache_by_default and apc. filters: apc. cache_by_default. whether to enable the system cache. it is usually used in combination with apc. filters to control the php files that need to be cached and do not need to be cached. The value of the apc. filters parameter is a POSIX extension separated by commas (,).Regular expressionList, ifRegular expressionIf the first character is +, all matched files will be cached. if it is-, all matched files will not be cached.

Demo1: disable system cache. only files starting with a and B are cached. other files are not cached.

  apc.cache_by_default = 0  apc.filters=+a.*.php,+b.*.php

Demo2: enable system cache. files starting with a and B are not cached. other files will be cached.

  apc.cache_by_default = 1  apc.filters = -a.*.php,-b.*.php

2 apc. shm_size and apc. shm_segments: apc. shm_size, the size of each shared memory block in MB. The system cache is shared with the user cache. you can adjust this value to change the size of the apc shared memory block. If apc. when the shm_size value has been set to the maximum value that the system can reach, we need to use apc. shm_segments, which indicates the number of shared memory blocks to be allocated by the compiler cache. we can adjust this value to change the number of shared memory blocks (but during testing, this option does not take effect ).

3 apc. stat: used to check whether the script is updated. it is enabled by default. it checks whether the script is updated every time the script is requested. this will adversely affect the performance. if the script files in the production environment are not updated frequently, we can disable it, which will greatly improve the performance. The disadvantage is that the web server needs to be restarted when the script is updated (for nginx, restart php-fpm) to make it take effect.

4 apc. ttl and apc. user_ttl: the number of seconds that cache entries can stay in the buffer zone. The difference is that apc. ttl is for the system cache, while apc. user_ttl is for the user cache. These two options did not perform well during the test. for example, if the value is set to 10, the cache entries will be cleared if they are not accessed for 10 seconds, however, after 10 seconds, these entries still exist and are not cleared.

5 apc. num_files_hint and apc. user_entries_hint: estimate the number of different source files contained or requested on the Web server. apc. num_files_hint for system cache, apc. user_entries_hint is used for user caching. Like the cache time, the number of cached files does not seem to have any effect. for example, if the number is set to 3, more than 3 files will still be cached. I don't know why.

Other parameters are not described too much. the cache time and cache quantity may not be opened in the correct way and cannot always get the expected results, if anyone has a deep understanding and research on these parameters, I hope you will not be enlightened.

Summary:

1 The apc official manual clearly states that apc has two major configuration options: one is how much memory is allocated to apc (option apc. shm_size), one is to request the apc to check whether the file is modified (option apc. stat). It can be seen that these two options are crucial for apc, and you have time to focus on these two options.

2 apc. cache_by_defaultEnable and disableIt only affects the system cache and does not affect the user cache.

3. the apc shared memory block is shared by the system cache and the user cache.

4 apc 3.1.15-dev version, php 5.5.10, centos6.5 operating system, not effective when apc. shm_segments is set.

5. when the apc cache is full, the system cache performance is different from the user cache performance. if the system cache file reaches the cache limit during the request, apc will clear all the system cache files except the request. if the user cache variable reaches the cache limit during the request, all other user cache variables except the request variable will be cleared, that is, the system cache and user cache will not affect each other.

The above introduces the apc extension analysis of php (II), including some content, and hopes to help friends who are interested in PHP tutorials.

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.