Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What does nts mean in php

2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly shows you "what is the meaning of nts in php". It is easy to understand and clear. I hope it can help you solve your doubts. Let me lead you to study and learn this article "what does nts mean in php?"

In php, nts refers to "non-thread safety", which means no data access protection and no thread safety check during execution; it is possible for multiple threads to change the data one after another, resulting in dirty data.

Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer

The full name of nts is one-Thread Safe, that is, non-thread safety, which means there is no data access protection and no thread security check during execution; it is possible that multiple threads change the data one after another, resulting in dirty data.

Since there is non-thread safety, there is thread safety (Thread Safe).

Thread Safe is thread safety, and thread (thread) safety checks are performed during execution to prevent the CGI execution mode of starting new threads from running out of system resources when there are new requirements.

Differences between PHP thread-safe and non-thread-safe:

Because: the Linux/Unix system uses the multi-process work mode, while the Windows system uses the multi-thread work mode.

That is, the basic unit of task scheduling in Linux system is process, and the basic unit of task scheduling in Windows system is thread.

Generally, we configure PHP to run as ISAPI, and ISAPI is multithreaded, which is much faster.

However, there is a problem. Many commonly used PHP extensions are developed based on the multi-process idea of Linux/Unix. When these extensions are run in the way of ISAPI, they will make mistakes and destroy IIS.

Therefore, CGI mode is the safest way for PHP to run under IIS, but CGI mode requires reloading and unloading the entire PHP environment for each HTTP request, and its consumption is huge.

In order to balance the efficiency and security of PHP under IIS, Microsoft gives the solution of FastCGI.

FastCGI allows PHP processes to reuse instead of restarting a process with each new request. At the same time, FastCGI can also allow several processes to execute simultaneously. This not only solves the problem that the CGI process mode consumes too much, but also takes advantage of the fact that there is no thread safety problem in the CGI process mode.

Therefore:

If you use ISAPI to run PHP, you must use the Thread Safe (thread safe) version

If you run PHP in FastCGI mode, there is no need to use thread safety check. Using None Thread Safe (NTS, non-thread safe) version can improve the efficiency.

How should I choose which one to use (PHP thread safe, PHP non-thread safe)?

Windos server:

1. If you are PHP+IIS;, please select: PHP non-thread safe (None Thread Safe (NTS))

2. If you are PHP+apache;, please choose: PHP thread safety (Thread Safe (TS))

Linux server:

PHP under linux server, without the distinction between PHP thread-safe and non-thread-safe versions.

The above is all the content of this article "what does nts in php mean?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report