Thread-Safe Resource Manager Thread Safety FastCGI NTS TS

http://php.net/manual/en/internals2.memory.tsrm.php

When PHP is built with Thread Safety enabled, the engine requires a way to isolate contexts from one another, such that the threads of a process may service individual requests without interference. TSRM is omnipotent within PHP, extension authors have to do very little in order to make sure their extensions can function in both a Thread Safe and Non Thread Safe architecture.

Thread Safety

NTS builds are for single-threaded use cases, typically PHP running via FastCGI or on the CLI. TS builds support multithreaded SAPIs and are intended for PHP loaded as a web server module. So, if you want to use PHP as FastCGI with IIS, use the Non-Thread Safe (NTS) builds of PHP, or if you want to use the Apache HTTP Server, use the Thread Safe (TS) builds of PHP.

 
https://www.php.cn/faq/418642.html
  • ts(Thread-Safety)线程安全,多线程访问时,采用了加锁机制,当一个线程访问该类的某个数据时,进行保护,其他线程不能进行访问直到该线程读取完,其他线程才可使用。不会出现数据不一致或者数据污染php以ISAPI方式加载的时候选择这个版本.,php以ISAPI方式加载的时候选择这个版本.

  • nts(None-Thread Safe)非线程安全,就是不提供数据访问保护,有可能出现多个线程先后更改数据造成所得到的是 脏数据php以fast cgi方式运行的时候选择这个版本,具有更好的性能;

  • ISAPI(Internet Server Application Programming Interface), 通常是指被http服务器所加载,以服务器的模块形式运行,由微 软提出,故只能在win平台上运行,例如win下的apache,iis[据说用fast cgi 方式工作更稳定],而linux上php 则以 Apache模块或者php-fpm的方式运行。

    • cgi(Common Gateway Interface):HTTP服务器与你的或其它机器上的程序进行“交谈”的一种工具,说白了,cig就是一种 后台语言,其可以和服务器之间进行通讯。此时的php是作为一个独立的程序运行的。特点就是耗费内存。

       
    • fast cgi.是一个常驻(long-live)型的CGI,它可以一直执行着,只要激活后,不会每次都要花费时间去fork.这种方式 是与语言无关的、可伸缩架构的CGI开放扩展,其主要行为是将CGI解释器进程保持在内存中并因此获得较 高的性能。



 
 
 
posted @ 2017-01-05 19:26  papering  阅读(168)  评论(0)    收藏  举报