Java Servlet vs PHP

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply

A better platform?

Poll ended at Tue Jan 20, 2009 3:36 am

Java Servlet
0
No votes
JSP
0
No votes
PHP
1
100%
 
Total votes: 1

biswajyoti
Forum Newbie
Posts: 3
Joined: Fri Jul 04, 2008 4:04 am

Java Servlet vs PHP

Post 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?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Java Servlet vs PHP

Post 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.
(#10850)
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: Java Servlet vs PHP

Post 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.
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Re: Java Servlet vs PHP

Post 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.
biswajyoti
Forum Newbie
Posts: 3
Joined: Fri Jul 04, 2008 4:04 am

Re: Java Servlet vs PHP

Post 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.
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: Java Servlet vs PHP

Post 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.
biswajyoti
Forum Newbie
Posts: 3
Joined: Fri Jul 04, 2008 4:04 am

Re: Java Servlet vs PHP

Post by biswajyoti »

Ok got it.. point taken..... will the matter change if we use a ordinary PCs as servers like not realtime Servers?
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: Java Servlet vs PHP

Post 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.
Post Reply