Page 1 of 1

Java Servlet vs PHP

Posted: Fri Jul 04, 2008 4:36 am
by biswajyoti
We have to build an online automatic system for evaluating c,c++,java programs for an online programming contest. We feel that the system will be faster if we use a servlet based system rather than a PHP based system though our team is more comfortable with PHP. The database in any case will be MySQL. We feel that a servlet based system can help us pool our database connections and will open up multiple threads rather than processes as in PHP. The system will involve a presentation layer for accepting the files and update the database. When the files get uploaded a system is triggered by RMI to check the files and inserts the scores in the database. A script can periodically update the ranks and create a static page with the ranks. A similar system is also possible in PHP. But which is more favourable platform? servlet or php? Is it possible that with one connections in one class I can handle all the db queries in servlet? Is this advisible? How can we optimize the system for speed more?

Re: Java Servlet vs PHP

Posted: Fri Jul 04, 2008 4:55 am
by Christopher
Sounds like two different systems. A web front-end that allows uploading files and reads data from the database. The second is a back-end system that operates on the uploaded files and writes data to the database. Since you have experience with PHP then it would be good for the front-end. For the back-end you could use Java or C++ or Python ... whatever you are comfortable with, would be best.

Re: Java Servlet vs PHP

Posted: Fri Jul 04, 2008 5:52 am
by onion2k
Speed is never going to be an issue on a website for a programming contest. You don't even need to consider it. Write it in whatever you're most comfortable writing code in.

Re: Java Servlet vs PHP

Posted: Fri Jul 04, 2008 6:16 am
by Maugrim_The_Reaper
What Onion2k said with added exclamation marks:

!!!!!!!!!!!!!!!!!!

Unless there's a specific problem, one of the choices in particular is adept as solving, just go with whichever feels comfortable to work in.

Re: Java Servlet vs PHP

Posted: Fri Jul 04, 2008 6:43 am
by biswajyoti
I know. We are more comfortable in PHP and take advantage of the system calls. The development time will also be less. But people are of the view that Java with RMI will be a better option esp. in terms of speed as with java we can have one connection with one instance per application server thus one db connection. This may enable us to keep 2,3 application servers with 1 db server. While php opens up atleast one connection per user. Reducing the no of db connections definitely must have some advantages.... This is the main cause of confusion. Plus java servlets are multi threaded while php starts up a new process as such. This might affect things.

Re: Java Servlet vs PHP

Posted: Fri Jul 04, 2008 6:50 am
by onion2k
Stop worrying about the speed. It is not an issue for a site catering to such a tiny audience. There's no way you'll be getting much more than 1 page view every few seconds ... any language will cope with that no problem even if your code is terrible.

To give you an example, one of my sites gets 20,000 page views a day approximately ... it's all PHP and MySQL without no connection pooling whatsoever. It's on a server that serves half a dozen websites.

PHP is fast. You don't need to worry until your site is really popular.

Re: Java Servlet vs PHP

Posted: Fri Jul 04, 2008 7:42 am
by biswajyoti
Ok got it.. point taken..... will the matter change if we use a ordinary PCs as servers like not realtime Servers?

Re: Java Servlet vs PHP

Posted: Fri Jul 04, 2008 8:14 am
by onion2k
Depends on the specification of the PC really. On paper at least most desktop PCs are actually higher spec than servers. My laptop is much faster than the server I mentioned earlier in the thread. If you're that bothered about it why not write some code to benchmark either language and see which will cope better?

To be honest though, I'd be much more worried about reliability than speed if you're using PCs ... desktop PCs are much more likely to fail, and much less likely to have redundancy built in, so a hardware failure will knock out your site. With a server you can set it up so a backup will automatically take over and you'll never be offline.