[nycphp-talk] PHP server app
Joel De Gan
joel at tagword.com
Sun Apr 4 14:55:00 EDT 2004
> Ok what you saying is to use a forking server.
> Can you say why specificaly why non-forking server is bad ?
> Is it because the thread support is not as good ?
Hey,
A forked server is preferred because of the nature of them and ways to
have built-in limits. Sure you have to figure out who is the session
leader and child/parent relationships, etc but that setup work is worth
it. Using shared memory each instantiation of the program can have
mutual access to data and if it fails/dies it has no effect on the
others. So I guess the answer is encapsulation and that is why they are
used in high-end/high user apps like Apache and MySQL. Threading
requires more work to set up than forking, and in my opinion forking is
more intuitive for the programmer, so therefore is the better option.
***rant below, feel free to ignore***
PHP handles a most if not all of it's own memory clean-up, and for
logging I suggest using register_shutdown_function() and have your main
logging and cleanup code there.
A long time ago, I used to program in ASP and they had a function called
option_explicit which if used, makes you declare variables or would spit
out errors. I always felt it made you a better programmer as you kind of
need to think ahead a bit and once you do that, cleanup is easier as you
can look at your declaratives and you know what to empty.
In PHP functions like empty
http://us3.php.net/manual/en/function.unset.php
Serve this.
I also suggest setting error_reporting to E_ALL if you are concerned
with looking at your code for memory leaks and finding out just how
loose your programming style is.
At my work, a lot of the newer PHP guys had never worked with any lower
level languages and it amazes me that they are missing a lot of the
foundation knowledge for how/why things are a certain way. They have no
knowledge of certain base functions and only sketchy data structures
understanding. But then this is always the way these things go.. (back
in my day: snow both ways uphill etc. or the programmer equiv of PDP,
punch cards and assembly on green-line paper).
Anyway, I digress.
/rant
On Sun, 2004-04-04 at 12:53, felix zaslavskiy wrote:
> >>
> >> There is nothing that techincaly stops php being used that way.
> >> There is sockets api's extensions. I dont know which is most stable
> >> though.
> >>
> >> Memory leaks may be a problem. You can certainly do it but be prepared
> >> to
> >> restart the thing daily.
> >
> > The main issue with people having to restart is that they are not
> > utilizing posix functions.
> > http://us3.php.net/manual/en/ref.posix.php and are trying to run an app in
> > linear mode vs forked mode
> > (such as how apache and mysql run).
> > Anyway, PHP works just fine for a server apps, it not the "preferred"
> > choice for most, but for me, I like it.
> > -Joel De Gan
>
> Ok what you saying is to use a forking server.
> Can you say why specificaly why non-forking server is bad ?
> Is it because the thread support is not as good ?
--
joeldg - developer, Intercosmos media group.
http://lucifer.intercosmos.net
More information about the talk
mailing list