The difference between PHP thread safety and non-thread safe version deep parsing _php tips

Source: Internet
Author: User
Tags vc9 nginx server

The first Windows version of PHP3.0.17, released on October 20, 2000, started with a thread-safe version, because the Windows system is a multithreaded way of working with the Linux/unix system, which uses multiple processes. Running PHP in CGI under IIS can be very slow because the CGI pattern is based on multiple processes, not multithreading.

Normally we would configure PHP to run as an ISAPI, and ISAPI is a multithreaded way, which is much faster. There is a problem, however, that many of the commonly used PHP extensions are developed with Linux/unix ideas, which can cause errors to take down IIS when they run in the ISAPI mode. Therefore, the CGI mode is the safest way to run PHP under IIS, but the CGI model needs to reload and uninstall the entire PHP environment for each HTTP request, and its consumption is enormous.

To accommodate the efficiency and security of PHP under IIS, Microsoft has fastcgi solutions. FASTCGI allows PHP processes to be reused rather than to restart a process with every new request. FastCGI can also allow several processes to execute at the same time. This solves the problem that the CGI process mode consumes too much, and utilizes the advantage that the CGI process mode has no thread security problem.

Therefore, if you are using ISAPI to run PHP you must use the thread safe version, while running PHP in fastcgi mode does not require thread safety checks, with none thread safe (NTS, non-threading security) Version to better improve efficiency.

PHP official http://php.net/on widows version of 4: VC9 x86 Non thread SAFE,VC9 x86 thread SAFE,VC6 x86 Non thread SAFE,VC6 x86 thread SAF e; So what's the difference?

1. Supported servers are different
The VC9 version is for the IIS server version and has no support for Apache, while the VC6 version provides support for both IIS and Apache

What is VC6?
VC6 is Legacy Visual Studio 6 compiler, which is compiled using this compiler.
What is VC9?
VC9 is the Visual Studio 2008 compiler, which is compiled with the Microsoft VS Editor.

So how do we choose which version of PHP to download?
If you are using apache+php under Windows, please select the VC6 version;
If you are using iis+php under Windows, please select the VC9 version;

2. Different modes of operation
PHP operates in 2 ways: ISAPI and fastcgi.

ISAPI execution is in the form of DLL dynamic library, can be executed after the user request, after processing a user request will not disappear immediately, so the need for thread security checks, so as to improve the efficiency of program execution, so if you are using ISAPI to execute PHP, it is recommended to select thread Safe version;

The fastcgi execution is done with a single thread, so there is no need for thread security checks, and the removal of thread security checks can improve execution efficiency, so if you are fastcgi to execute PHP, it is recommended that you choose non thread safe version.

For the Apache server, you typically choose the ISAPI method, and for the Nginx server, you choose the FastCGI method.

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.