I think the title is clear.
Asked
Active
Viewed 1.8k times
15
-
21I think it would still be polite to phrase the question body properly. – deceze Oct 21 '10 at 02:42
-
1I recall reading something along the lines of: `IIS=NTS` & `Apache=TS`. – drudge Oct 21 '10 at 02:47
-
1@jnpcl It's usually the other way around. But in Apache case it really depends on the Apache MPM in use. Apache on Windows for instance can only use threads. – Alex Jasmin Oct 21 '10 at 03:04
-
2PHP has supported multi-threading for a very long time - but the PHP developers sensibly flagged up that they don't know which third party extensions (a large number of which come bundled with PHP) are thread-safe – symcbean Oct 21 '10 at 12:21
1 Answers
24
While you can't spawn threads from PHP code you can use PHP with a multi-threaded web server that handles concurrent requests on different threads. In this case the TS (thread-safe) version of PHP should be used.
The TS version of PHP keeps the state of each request in its own memory location. This is necessary because all requests in a multi-threaded server share the same address space.
The alternative is to use a multi-process (usually prefork) server. With such a server some state can be kept in global variables without affecting concurrent requests. That's how the NTS (non thread-safe) version of PHP is implemented.

Alex Jasmin
- 39,094
- 7
- 77
- 67
-
7Why don't they just use thread-safe all the time? Does non-thread-safe have any benefits? – Simon East Jul 18 '17 at 01:50