PHP as thttpd module against CGI in terms of memory usage

I plan to use php in the embedded environment. Our current web server is thttpd. I am considering two options: whether to run it as cgi or as an SAPI module. I know cgi has a security advantage. But if we use php as cgi, then the php instance must be loaded into memory for each request.

I tried to compile it as an SAPI module for thttpd, and I noticed that the memory usage of thttpd, in particular rss, does not increase as the number of requests increases.

Can someone explain how thttpd loads php? Does it boot only once and remain in memory as long as thttpd is running? If so, we can consider this as an alternative to cgi.

Does it perform multithreading, that is, if there are several HTTP requests at the same time? or is it processing the request one at a time?

Is there any good documentation discussing the behavior of php as a thttpd module?

+3
source share
1 answer

I have no experience with thttpd, but here are a few pointers:

  • The PHP engine is thread safe, but some extensions are not, so people usually shy away from using it in a multi-threaded environment and prefer to use the single-processor method with a single request
  • , - (, Apache mod_ *) , , PHP - , ( , include/require) . , - APC,
  • FastCGI, - CGI- - , CGI (PHP ) . (.. ).
+1

Source: https://habr.com/ru/post/1698640/


All Articles