Java vs PHP Memory / CPU Consumption

javamemoryPHP

I work in a PHP based company. There is a project where we want to create a backend service. Senior members here are going for PHP, even though it is slower than Java. Their only point of contention, that Java is heavier than PHP in both memory and cpu load standpoint.

Jvm is more like a container environment, if u bring in more baggage it will consume that much, but service we are talking here will be of medium complexity. So chances are that it won't be much demanding (or will it?)

I understand this question leans heavily towards vagueness, however my point of ponder is, that is it always the same case? That java is more hardware demanding? I would just like to know opinions of all you experienced folks about how the actual scenario looks like.

Best Answer

If you're worried about speed, write the back-end in a compiled, fast-as-you-like language such a C or C++. There are plenty of webservice tooling to create simple C/C++ web services that you can consume from your PHP clients.

However, if you want to code it quickly and performance isn't so bad, then write it in PHP. You also have the benefit of already having the skills necessary to do this, so that's a double bonus.

Java isn't massively bloated compared to PHP, it might be a 'step up', but you'll have to learn all the niggles and tricks that you need with any new system, and I doubt the benefit will be worth it compared to just writing it in PHP straight away. In most cases, if you have the skills to do it in PHP already, that should be the first choice, choosing to do it in a different language away from your main area of expertise should be very carefully considered and only chosen if there is definite benefits over your primary system (which I don't think there will be in this case)

Related Topic