C.F. Scheidecker Antunes wrote:
> Hello all,
>
> I need to have a web application to call an external app that needs to
> execute on the background. (It is an *NIX server)
[...]
> My question is this:
>
> Is it better to write the external app in PHP or Java?

Assuming that you (or the developer(s) if not you) are just as
familiar/comfortable developing in Java as they are PHP, I would think the
most important factor would be code reuse.  Is there now or will there ever
be a need to share business logic between this external application and the
web interface itself?  If the answer is yes, or it's even possible that the
answer MAY be yes, I would highly suggest that you code both the web
interface and the external application in the same language, so you can
reference any business logic classes/functions created for one in the other.

A while back I developed a program that consisted of a traditional web
interface and a standalone command line script that gathered data from my
database, formatted it, and emailed it to subscribers based on their
pre-selected criteria.  I used PHP for the web application but at the time I
decided that Perl was better suited for the command line script than PHP
was.  *BIG* mistake.  I ended up recoding a lot of already-developed
business logic for the command line script.  Now maintenance on this program
is a nightmare.  Anytime anything significant changes in the business logic
I have to basically implement the change twice.  You may want to keep this
in mind, since it will be difficult if not impossible to share logic/code
between a PHP web app and an external Java program.

> If I write in PHP then I have to have a way to make the PHP not bound
> to time limitations as the operation might take a while.

That's easily accomplished.  You can create a separate php-cli.ini file for
the standalone PHP binary and configure different limits for
max_execution_time and memory_limit.

> Which one would put a higher load to the processor, a PHP app or a
> Java one?
> Which one will take longer?

I'll leave these questions to someone else, as I have almost no Java
experience...

> Also, there might be more than 20 of these threads running on the
> server at the same time, hence my concern on which language the app
> should be writen.

Since these processes can be launched by the end user at will (from the
sound of your description), you may have a lot more than just 20 of them
running.  It's very difficult to predict how end users will (ab)use your
program.  Some people like to click refresh a lot, for example. :)
Depending on how many people have access to your application, you may want
to put a mechanism into place to impose a hard limit on the number of these
processes that can be active at any time, or you may open your server up to
an increased possibility of DoS attack.  Just a thought...

HTH

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to