[PHP] How to Handle autoload

Source: Internet
Author: User
Tags autoload apc autoloader

With cache such as APC, PHP's autoloader becomes a performance point that needs to be carefully considered.

See:

Http://stackoverflow.com/questions/4788452/does-autoload-really-kill-performance-when-using-apclatest-versions-up-to-date

Http://tournasdimitrios1.wordpress.com/2013/04/15/boosting-the-performance-of-a-php-project-with-an-autoload-class-map-2/

It is said that autoloader does not conflict with APC. However, autoloader still needs to go to require_once for each request, which will lead to an additional disk Stat () operation. Can we continue optimization?

The idea is to use class_exists and regularly check whether the PHP file has been updated. This avoids the disk Stat () operation caused by a pile of require_once requests.

Most applications do not care whether PHP files are updated to the latest version after 100 milliseconds. Regular and delayed PHP file version updates should be acceptable. I do not know whether such optimization is performed within require_once.

Maybe you should let the require_once () function take a parameter directly to specify the call interval of the disk Stat. This can be simple but effective to improve performance.

I checked the APC information:

APC. Stat

APC. include_once_override

It seems that APC has noticed this problem, but the APC solution seems immature. StillExperimental.

ArticleArticleA good explanation of the relationship between APC and require_once: http://www.laruence.com/2012/09/12/2765.html

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.