PHP Thread Safe or Non Thread Safe binaries 区别

本文探讨了PHP非线程安全版本与线程安全版本的区别。解释了这两种版本的历史背景,以及它们如何影响Windows环境下IIS服务器上的PHP性能。讨论了使用非线程安全版本配置IIS的方式,以及它如何提高CGI接口的性能。

重装Windows系统,并顺便升级一下自己的软件。

 

PHP 最新版本已经到 5.3.2. 下载的时候,看到有 Thread Safe or Non Thread Safe binaries 的区别。

 

搜索了一下,区别和历史原因如下:

 

Difference between PHP thread safe and non thread safe binaries

Submitted by Dominic Ryan on Thu, 2007-09-27 14:35.

Since the release of PHP 5.2.1 back in Feburary there has been two new binary packages available for Windows, the non thread safe PHP binaries and the non thread safe PECL binaries. Since then I've read many threads in Internet forums where there seems to be a bit of confusion on what these extra binaries are, how they are used, and what effect they have. In this article I'll discuss the pro's and con's of these new binaries.

Since PHP first came to Windows back on the 20th of October 2000 with the release of PHP 3.0.17, the Windows binaries have always been released as thread safe packages. The reason for this is that Windows uses a multi threaded architecture as opposed to the multi proccess architecture of Linux and Unix. The problem this has when using PHP on IIS in CGI mode is that it makes it very slow as CGI was built on a multi process model, not a multi threaded model. On the flip side the problem this has when using PHP on IIS with the much faster ISAPI module is that there are several popular PHP extensions that have been developed with only Unix/Linux in mind (multi proccess model), and actually cause the PHP ISAPI module to crash on IIS. This making CGI the most stable environment for PHP on IIS, with the major disadvantage that it is terribly slow due to it having to load and unload the entire PHP environment from memory everytime there is a request.

There have been a few options available for a while to get PHP performing well on IIS. Firstly is the use of an opcode cache such as eAccelerator which stores PHP scripts in a partically precompiled state on disk and/or memory which drastically decreases script execution time. Another option is to configure IIS to use PHP in FastCGI mode which allows PHP processes to be recycled rather than killed off after each PHP request and also allows you to run several PHP processes at once, making PHP much much faster with the added bonus that as it is using the CGI interface there is little or no incompatibility issues with PHP extensions. This is still the fastest way to serve PHP, and is the way the IIS Aid PHP Installer is configured to install PHP on your IIS Environment.

What the non thread safe binaries allow you to do is to configure IIS (and other Windows based webservers) to use PHP as a standard CGI interface with massively increased performance as the PHP process is not required to wait for thread syncronisation. The performance increase is not to be sneezed at either as I've seen figures of upto 40% mentioned (though I'm yet to confirm myself), but it is still not as fast as the opcode/FastCGI method mentioned above. One of the biggest catches I've seen people getting themselves hooked on is that non thread safe binaries cannot be reliably used with the thread safe ones, and vise versa. This means that (for the moment at least) you cannot use opcode cache systems such as eAccelerator to give your non thread safe PHP environment a boost in the arm as they are all currently compiled as thread safe.

If the non thread safe binaries are not as fast as what you can configure the thread safe binaries to be then what is the point you ask? Here we come back to FastCGI, and in particular the efforts Microsoft have been making over the last year or so with the development of their own FastCGI handler. This new FastCGI handler from Microsoft enables you to configure the non thread safe PHP binaries in FastCGI mode, which is one massive shot in the arm for performance. Easiest way to put it is using the non thread safe PHP binaries with Microsoft's new FastCGI handler is like putting twin turbos on your car (without the inherent risk of blowing up your engine), and there is little doubt in my mind that this will be the future of PHP on IIS.

### RT-Thread Operating System on K210 Chip Configuration and Development #### Overview of the K210 Chip The K210 is a RISC-V architecture-based AIoT (Artificial Intelligence Internet of Things) processor designed by Kendryte. This chip features dual-core 64-bit processors, an NPU for neural network processing, and various peripherals that make it suitable for edge computing applications. #### Compatibility with RT-Thread OS RT-Thread supports multiple architectures including those based on the RISC-V instruction set such as the K210 chip[^1]. The versatility of this real-time operating system allows developers to leverage its rich ecosystem while working specifically within the constraints and capabilities offered by the K210 hardware platform. #### Setting Up the Development Environment To configure and develop using RT-Thread on the K210: For setting up the environment, one needs appropriate tools like JTAG debugger, serial terminal software along with specific compilers tailored towards compiling code targeting RISC-V cores found inside K210 devices[^2]. ```bash # Install necessary packages via package manager sudo apt-get install gcc-riscv64-linux-gnu binutils-riscv64-linux-gnu ``` Ensure access to source repositories through reliable mirrors or direct downloads from official sources provided by projects like RT-Thread which offer comprehensive support materials covering setup instructions down to detailed documentation about APIs available under their framework. #### Configuring RT-Thread for K210 Configuration involves selecting components required during compilation time according to project requirements. Utilize menuconfig utility included in RT-Thread SDK to customize settings easily without manually editing configuration files. ```c // Example C file demonstrating initialization process after configuring options. #include <rtthread.h> int main(void){ rt_hw_board_init(); // Initialize board-specific configurations /* Add application logic here */ return RT_EOK; } ``` This approach ensures only essential parts are compiled into final binaries reducing footprint significantly beneficial especially when dealing with resource-constrained environments typical among embedded systems built around chips similar to K210. #### Developing Applications With everything configured correctly, start developing applications taking advantage of both high-level abstractions presented by RT-Thread alongside low-level control over underlying resources exposed directly due to close integration between kernel layer and device drivers optimized explicitly for better performance across different scenarios encountered throughout deployment lifecycle stages ranging from prototyping all way until mass production runs depending upon end-user case studies being addressed effectively leveraging combined strengths brought forth collaboratively between these two powerful technologies integrated seamlessly together forming robust solutions capable enough tackling complex challenges faced today's rapidly evolving market demands head-on successfully overcoming obstacles standing tall amidst fierce competition present everywhere nowadays more than ever before seen previously anywhere else anytime soon!
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值