On Nov 12, 1:19 am, Jouni Kallunki <
jou...@gmail.com> wrote:
> Hi Jeff,
>
> Many thanks on your prompt answer. This clears the issue for me. I was
> suspecting something like this, apparently I should read more about
> the apache.
> I guess that the functions and libraries loaded at the start time, as
> defined in the httpd.conf are shared by all the R run-times? So this
> would then be the place to load all general functions.
Yes, sort of. Here's hopefully a better explanation of apache:
When apache starts, it designates a parent process which then creates
a collection of child processes. Each process, including the parent,
goes through an initialization phase by parsing the config files and
executing the directives found within. Thus once you execute
'apachectl start' or '/etc/init.d/apache start' and it returns, apache
is ready to accept and server request.
At this point, all of your R instances living within each apache
process has initialized. But of course you know that none of them have
a shared environment. Each has it's own global environment, so
stuffing data into one doesn't mean it's going to migrate to the
others. This is the behavior you've encountered.
Here's the wrinkle. A child process will die off after it has served
so many requests, and it's the parent's job to start a new child
process. And that child process of course goes through the same
initialization phase, parsing the config files and executing the
directives. Completely new process with no previous state from the
dead child.
So, it's important to have in your head an idea of apache processes
coming and going and you never know which one's they are; that's the
parent's job. And it's your job as the programmer to solve the problem
of saving important data to an appropriate place outside of apache and
having a mechanism to access that data concurrently with other
requests.
Of course this is a well known problem, and other web programming
systems like PHP, ruby on rails, django, and so forth have solved
these with a myriad of solutions. It's just that I haven't found a
really good solution yet for rapache, and I'm sort of hoping the
community of R developers who write web applications with rapache will
grow and arrive at an agreeable solution.
Jeff