On Saturday, 21 November 2015 at 22:47:46 UTC, deadalnix wrote:
Could you elaborate a bit on this? What about the execution
model is so right?
PHP runs every request in complete isolation. All global/static
are in fact request local storage. This has many consequences,
namely:
- It scales. More machines, more requests.
- It makes memory management easier: everything is reference
counted, and if you leak because of cycles, it doesn't matter,
you trash it all at the end of the request.
- Because of builtin reference count, you can get efficient
COW containers. PHP array are weird, but they get that right.
- Because you have COW containers, you can shared them accross
request without fear of screwing everything up. Useful for
configurations or other data structures that doesn't change
often.
- Because you get fresh environment for each request, it is
much easier to debug when something goes wrong.
- If something goes bad for one request (out of memory, takes
too long to run, ...) you can trash it without any risk of
impacting the service at large.
- When a request corrupt its state for whatever reason, you
don't put the whole service in jeopardy. Log and trash it all.
And something like Erlang does all of the above at much better
performance and quality of implementation. Most importantly,
though, you completely ignore the performance overhead costs that
matter for most companies that are not Facebook. Reimplementing
main points from abovementioned list (primarily isolation and
request-local allocators) can be done with pretty much any decent
language and potentially save huge amount of money on server
costs.
Scaling implies not only being able to increase the load without
system redesign but also doing it efficiently - both in server
and maintenance costs. PHP is rather bad at both.