PHP Thread safe (thread safety) and the None thread safe (NTS, non thread safe)

Source: Internet
Author: User
Tags http request

Windows version of PHP starts with thread safe (thread safety) and none thread safe (NTS, non-5.2.1) from version
Thread-safe), the difference between the two is where. What kind of it should be used. Here's a simple introduction.

The first Windows version of PHP3.0.17, released from October 20, 2000, starts with a thread-safe version, which is
In contrast to the Linux/unix system, which uses multiple processes, the Windows system is a multi-threaded way of working. If
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. But there is a
Problem, many of the commonly used PHP extensions are developed with a linux/unix idea of how the ISAPI works
Error will take down IIS. So in IIS, the CGI mode is the safest way to run PHP, but the CGI schema for each HTTP request
Need to reload and uninstall the entire PHP environment, its consumption is enormous.

To accommodate the efficiency and security of PHP under IIS, Microsoft has fastcgi solutions. FastCGI can make the PHP process heavy
Reuse rather than each new request to restart a process. FastCGI can also allow several processes to execute at the same time. This solves both
The problem of the CGI process mode consumption is too large, and the use of the CGI process mode does not exist the advantage of thread security problems.

Therefore, if you are using ISAPI to run PHP, you must use the thread safe version;
fastcgi mode to run PHP there is no need for thread security checks, with none thread safe (NTS, non-threading safety)
Version to better improve efficiency.

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.