|
Posted by Jerry Stuckle on 05/15/06 17:16
tony@tony.com wrote:
> In article <NOSdnYkKFc-0_PXZnZ2dnUVZ_vWdnZ2d@comcast.com>,
> jstucklex@attglobal.net says...
>
>
>>Hmmm, as much as I like PHP, I might suggest it is not the right approach for
>>this operation. PHP doesn't support threads, but you can fork a new process (on
>> Unix) as Chris indicated.
>>
>
>
> This is interesting. I'm working on a project that will need to connect
> to 2 different servers and to speed things up (being ssl) I was hoping to
> be able to do this simultaneously.
>
> I need my web visitor to hit a button and be able to enter information
> on another server while at the same time my system is looking up data
> in a database on a third server.
>
> Would this be the sort of thing possible with PHP (my server uses apache2
> with CGI) or would it have to use threads?
>
> tony
Hi, Tony,
Hmmm, now you're changing things a bit. You have a web visitor to work with it,
and using SSL in addition. This makes things a lot more complicated in C or C++
- especially the SSL end unless you're already familiar with the SSL
functions. And working with a web user is a lot different than just stand-alone
command line options.
You probably could still spawn a C/C++ program to do the database work (as long
as it isn't using SSL), but I'm not sure it's worth the extra effort and
complications.
Since you're working with remote databases, threads are probably going to
increase your throughput. But the real question is how long does it take to do
the work on the remote server? You're going to be constrained by the slowest
operation, of course. If both operations take 10 seconds, you'll save about 10
seconds by doing them concurrently. But if one takes 19 seconds and the other
only takes 1 second, your savings will be 1 second - despite the 20 second total
in both cases.
To do it, you'd have to spawn another process to do the work and wait for it to
respond. This part isn't hard. And even passing the necessary values isn't too
bad. Getting the returned data isn't too bad - there are several ways to do it
but you'll have to parse the results somehow.
The real problem comes in handling errors. For instance, what if one database
(or the path to it) is down? Or data which is supposed to be there isn't found?
Or any of dozens of other things which can (and do) go wrong?
If you're doing it all sequentially in PHP this becomes much easier to handle.
But when spawning the external process you've added another layer of complication.
Just some things to think about.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Navigation:
[Reply to this message]
|