15

I think the title is clear.

yoyo
  • 1,113
  • 2
  • 17
  • 25
  • 21
    I think it would still be polite to phrase the question body properly. – deceze Oct 21 '10 at 02:42
  • 1
    I 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
  • 2
    PHP 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 Answers1

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