1

I have zero experience building website with Java. Recently I need to develop complex web application.

Currently I'm converting PHP apps to get it works in PHP 5.4. With modern website requirement, PHP application needs better frameworking from start. Use Zend framework or Drupal 7 looks good move.

But Zend or Drupal 7 comes with a price. 300MB VPS seems not relevant anymore for an average PHP website. In this case, Resource usage rate is very important to me.

Because lots of complex web application is built with Java web framework, I just wonder how high is Java resource usage (memory & CPU) compared with PHP 5.4?

I hope it will be same or even better, so that I have more choice.

4

2 回答 2

3

This should provide some info about resource and cpu usage of both languages

enter image description here

Basically, based in that series of test (and until this date) Java memory consumption is in average bigger than PHP, but execution time tends to be faster

于 2012-06-12T02:44:01.360 回答
3

Overall memory usage will depend much more upon what frameworks you use and how well you code your application than whether you write it in PHP or Java. The baseline memory cost of both is small enough that you can ignore it on modern machines, so it is the application that matters.

In terms of CPU usage, Java will ultimately perform much better since it is JIT-compiled to native code and has an efficient statically typed in-memory object representation (This benchmark shows Java as over 25x than PHP on a set of benchmark programs)

Having said that, either would be probably be fine for most normal web applications. My advice would be:

  • Given you are familiar with PHP you may want to stick with it simply because the learning curve of picking up a new language and associated frameworks is significant.
  • If you are serious about developing a robust, high performance enterprise-grade application then it would certainly be worth learning and using Java. But you have to be sure that you are prepared to face a big learning curve.

Some interesting links:

于 2012-06-12T02:55:33.870 回答