Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Coming from a Java background into a startup that was built using PHP, it's been my experience that PHP is difficult to scale. This is for two reasons:

1) PHP isn't long-lived. Every time a request comes in Apache launches the PHP processor/interpreter and runs through the entire script. This means you don't get a heap that you can use to cache things[0], you don't get the benefit of JIT compilation, and you don't get the benefit of pre-compilation[1].

2) PHP development always seems to be tied tightly to a database. At some point an extremely high-traffic app will need to scale beyond what a DB (even a sharded DB) can support. To do this you have to think in terms of asynchronous processing, out-of-process updates, aggressive caching, and more.

The second point isn't really an issue of PHP, but more an issue of the PHP ecosystem - however, it affects the way I perceive the language itself.

Places that use PHP for high traffic sites seem to use it to build the presentation layer, which seems to work for them, but the majority of the work is being done by back-ends written in some other language.

[0] Yes, you can use memcache, but it still means, at the very least, a cross-process hop and most likely a cross-network hop.

[1] Compiling to bytecode (for Java) is still better than no compilation. Also, you only take the hit of starting the JVM once, not on every request.



PHP doesn't scale? Facebook has > 200 million users. It's written in PHP.


The parent clearly talks about how PHP is used mostly for the presentation layer of that class of applications.


Install an opcode cache and you get the pre-compilation for free. Check out APC, x-cache, etc.

http://en.wikipedia.org/wiki/PHP_accelerator




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: