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

PHP scales better than Java? Java is only suited for small to medium scale? That's absurd and you are completely wrong.

Java web servers are multithreaded. Java has JIT. Java has a Hotspot VM with JIT optimizations at runtime.

This is why companies like Google and Amazon run their stacks on Java. It scales. Facebook had to write their own fork of PHP due to performance issues.



>Java is only suited for small to medium scale?

Never said that. What I said was that in the small to medium scale Java was obviously more performant because of the persistent instance & multithreaded model. But beyond that it really is no longer true. The immutable "shared nothing" process forking model of PHP scales horizontally very easily.

>Java web servers are multithreaded

this really is a disadvantage when scalling. The default linux thread stack is 1024k for 64-bit VMs, can't find what's the minium if you tweak it enough. You can see how bad that scalles to thousands of concurrent requests.

And then there's containerization and microservices, where each instance needs a full JVM.

>This is why companies like Google and Amazon run their stacks on Java

You can make anything scale with Google or Amazon budgets.

Again, just listing some pros and cons of both approaches, both of which I think are not even the best.


You don't seem to understand the basics of how Java web containers work. The thread stack size is irrelevant in most cases. You're going to be using a thread pooled server anyway to handle requests. Conceptually this is no different than using a forked model. You just use a pool of threads instead of processes.

Are you telling me that you run a process pool of thousands of PHP instances on a single machine? I hope not.

Your notion that forked = better is outdated. Running processes has overhead, even with read only shared mem. Micro processes are the way to go, and are being embraced by newer languages. You get min mem and context switching overhead, along with the parallelization of running on multiple cores.

Even so, threads are still going to be lighter weight than forking new "heavy weight" (non micro) processes.

And this doesn't even get into the more efficient compilation. PHP has no JIT yet. There's overhead for type inference. Etc etc


>Your notion that forked = better is outdated.

You're beating a strawman here. Nowhere did I make the claim that it was better. I even said multithreading is more performant. The only claim I make is that immutable and shared nothing model of PHP servers makes horizontal scalling more straightforward.

>You're going to be using a thread pooled server anyway to handle requests

That doesn't take away the fact that n parallel requests will require n threads.

>And this doesn't even get into the more efficient compilation. PHP has no JIT yet. There's overhead for type inference. Etc etc

I don't make any claims here either. Of course Java is faster here. My point was specifically about which model of concurrency and paralellism is better for server IO.


>That doesn't take away the fact that n parallel requests will require n threads.

What's your point? In PHP's model, n requests will take n processes. There's no event loop in PHP.

The forked model has nothing to do with making scaling horizontally more straightforward. In either scenario, you'll end up running a different process on another machine once you exhaust your resources.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

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

Search: