For Programmers: Free Programming Magazines  


Home > Archive > PHP Programming > December 2007 > Force PHP CLI to stay in RAM?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Force PHP CLI to stay in RAM?
Gilles Ganault

2007-12-24, 10:07 pm

Hello

I have a couple of command-line PHP scripts that are often called, and
I was wondering if it were possible to have the PHP interpreter remain
in RAM instead of being removed after the scipts end?

Thank you.
petersprc

2007-12-25, 4:02 am

Hi,

You can certainly do this. The script can sit in a loop waiting for an
indication to continue such as a socket connection, a file on disk
being modified, a posix signal, an update in a database, a timer, etc.

On Dec 24, 10:00 pm, Gilles Ganault <nos...@nospam.com> wrote:
> Hello
>
> I have a couple of command-line PHP scripts that are often called, and
> I was wondering if it were possible to have the PHP interpreter remain
> in RAM instead of being removed after the scipts end?
>
> Thank you.


Iván Sánchez Ortega

2007-12-25, 7:02 pm

Gilles Ganault wrote:

> I have a couple of command-line PHP scripts that are often called, and
> I was wondering if it were possible to have the PHP interpreter remain
> in RAM instead of being removed after the scipts end?


If the script is called often enough, they *will* stay in memory. It's
something called "the operating system automatically caches the most
recently used files".

You are trying to do premature optimization. Don't.

--
----------------------------------
Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-

Las deudas son como los niños; cuanto más pequeñas, más ruido hacen.
Gilles Ganault

2007-12-25, 10:02 pm

On Tue, 25 Dec 2007 21:21:26 +0100, Iván Sánchez Ortega
<ivansanchez-alg@rroba-escomposlinux.-.punto.-.org> wrote:
>If the script is called often enough, they *will* stay in memory. It's
>something called "the operating system automatically caches the most
>recently used files".


OK, I'll just let Linux handle this, and come back if it's too slow
;-) I wanted to have your opinion because the scripts are used with a
PBX, so that timing is important.
Iván Sánchez Ortega

2007-12-26, 8:00 am

Gilles Ganault wrote:

> I wanted to have your opinion because the scripts are used with a
> PBX, so that timing is important.


Then, keep the scripts short and use efficient algorithms. Knowing the
difference between O(n^2) and O(n*log(n)) is much more important than
keeping the script in memory.


That said, if you *really* need a real-time response on a mission-critical
environment, drop PHP altogether and switch to rtlinux, lighthttpd and a
custom C CGI.

--
----------------------------------
Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-

MSN:i_eat_s_p_a_m_for_breakfast@hotmail.com
Jabber:ivansanchez@jabber.org ; ivansanchez@kdetalk.net
The Natural Philosopher

2007-12-26, 8:00 am

� wrote:
> Gilles Ganault wrote:
>
>
> Then, keep the scripts short and use efficient algorithms. Knowing the
> difference between O(n^2) and O(n*log(n)) is much more important than
> keeping the script in memory.
>
>
> That said, if you *really* need a real-time response on a mission-critical
> environment, drop PHP altogether and switch to rtlinux, lighthttpd and a
> custom C CGI.
>

:-)

he's right you know.

But real time usually just mens 'good enough' - only in real mans stuff
does it mean 'guaranteed to always be good enough'

i.e. you do NOT want your missile to decide to go memory garbage
collecting 5 ms after launch.. ;-)and self destruct when it misses a
watchdog timer..



Gilles Ganault

2007-12-26, 7:02 pm

On Wed, 26 Dec 2007 12:09:08 +0000, The Natural Philosopher <a@b.c>
wrote:
>But real time usually just mens 'good enough' - only in real mans stuff
>does it mean 'guaranteed to always be good enough'


OK, I'll see how PHP does and see if timing is an issue. Thanks.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2010 codecomments.com