Re: php cli question
| From: | J Ravi Menon | Date: | Wed, 15 Sep 2010 02:19:40 +0000 |
| Subject: | Re: php cli question | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-308080@lists.php.net to get a copy of this message | ||
On Tue, Sep 14, 2010 at 1:15 PM, Per Jessen <per@computer.org> wrote:
> J Ravi Menon wrote:
>
>> On Tue, Sep 14, 2010 at 12:43 AM, Per Jessen <per@computer.org> wrote:
>>> J Ravi Menon wrote:
>>>
>>>> Few questions:
>>>>
>>>> 1) Does opcode cache really matter in such cli-based daemons? As
>>>> 'SomeClass' is instantiated at every loop, I am assuming it is only
>>>> compiled once as it has already been 'seen'.
>>>
>>> Yup.
>>
>> Just to clarify, you mean we don't need the op-code cache here right?
>
> That is correct.
>
>>>> 2) What about garbage collection? In a standard apache-mod-php
>>>> setup, we rely on the end of a request-cycle to free up resources -
>>>> close file descriptiors, free up memory etc..
>>>> I am assuming in the aforesaid standalone daemon case, we would
>>>> have to do this manually?
>>>
>>> Yes.
>>
>> So 'unset($some_big_array)' or 'unset($some_big_object)' etc.. is the
>> right way to go for non-resource based items? i.e. it needs to be
>> explicitly done?
>
> It's not quite like C - if you reassign something, the previous contents
> are automagically freed. I use unset() if I know it could be a while
> (hours) before it'll likely be reassigned, but it won't be used in the
> meantime.
>
Thanks Per for clarifying this for me. Now on my follow up question:
[Note: I think it is related to the issues discussed above hence
keeping it on this thread but if I am violating any guidelines here,
do let me know]
One reason the aforesaid questions got triggered was that in our
company right now, there is a big discussion on moving away from
apache+mod_php solution to nginx+fast-cgi based model for handling all
php-based services. The move seems to be more based some anecdotal
observations and possibly not based on a typical php-based app (i.e.
the php script involved was trivial one acting as some proxy to
another backend service).
I have written fast-cgi servers in the past in C++, and I am aware how
the apahce<---->fast-cgi-servers work (in unix socket setups). All
our php apps are written with apache+mod_php in mind (no explicit
resource mgmt ), so this was a concern to me.
If the same scripts now need to run 'forever' as a fastcgi server, are
we forced to do such manual resource mgmt? Or are there solutions here
that work just as in mod_php?
This reminded me of the cli daemons that I had written earlier where
such manual cleanups were done, and hence my doubts on this
nginx+fast-cgi approach.
thx,
Ravi
>
>
> --
> Per Jessen, Zürich (14.6°C)
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>