I wish to understand how Java (JSP) on Tomcat even compares to PHP on Apache when it comes to performance.
Two servers with similar hardware designs, one running Tomcat/Java (JSP) another Apache/PHP, both servers at their maximum with the number of connections they are able to handle at the same time. Would they be somewhat close or would one distance themself in the other one with a large margin? I essentially would like to determine if Tomcat/Java (JSP) will probably be a large performance hit basically change to it versus PHP. If anybody can provide an in depth answer on why the first is faster compared to other that might be amazing. Links are wonderful too, I had been not able to locate anything online remarkably.
Please no Java versus PHP wars, this really is about performance only, nothing related to the languages themselves.
Note: If there's every other concerns I ought to have for switching to Java from PHP please tell me. I Truly hate asking this because I am usually first person to express "enter in that which you like" however in my situation I want what is also great for the projects Sometimes for. I understand that you will find large sites designed in JSP, however it does not imply that they are better.
What's great for the projects you are focusing on would be to spend very little time as you possibly can to create them as developer time is way more costly than any perceived variations in performance. So stick to what you are acquainted with.
The response to your real question is: both are fast enough.
Such comparison is difficult since you finish up doing things in a different way in various languages. Java bytecode is most likely faster to interpret however again any decent PHP install uses as opcode cache largely killing such advantage in tangible terms.
Java also offers a far more complicated development model because Web processes are persistent. This may have a performance advantage but additionally can make problems like memory along with other resource leakage, which PHP does not generally have because things are produced and destroyed on each request (barring session information, memcache and so forth).
Also PHP extensions could be produced for just about any parts that you would like to accelerate.
$10,000 can purchase a great deal of hardware. It may purchase the hardware to operate SO. It does not buy much developer time.
I have got experience doing both Java and PHP development. I'll generally choose PHP for Web design due to:
- faster to check alterations in development (ie no build/deploy steps and Java hot-deploy has serious restrictions). Words cannot express how clearing it's to check changes by saving the file you are focusing on and clicking reload on the browser versus running an Ant/Maven build process
- far less issues of memory/resource leakage
- extensive library of functions to complete virtually anything you like
- cheaper to host (in the low finish).
I'll use Java for many things, like something that involves lots of background processing and threads, which are not PHP's strong points.
You'll observe that performance (or even the lack thereof) does not even rate like a reason behind or again.
Sorry in the event that does not answer your question, but such concerns over performance really are a pointless distraction.
The easiest method to answer performance questions is by using a benchmark. Implement some simple page both in PHP and Java after which benchmark them using ab (Apache Benchmark).
With that said, I suspect Java will outshine PHP due to the character from the 2 platforms. Java is put together to enhanced bytecode (once) after which construed with a virtual machine. When Tomcat runs, the JVM loads the classes needed for just about any given page and keeps them in memory so they are all set to go when an HTTP request hits the net server. Contrast by using PHP which reloads and re-translates the code on your own with every invocation by Apache. This really is assisted to some degree by op-code caching, but nonetheless not to the stage of the items occur in the JVM.