setup for an application with a common huge read-only memory block shared among childs.

0 views
Skip to first unread message

Valery

unread,
Dec 25, 2009, 7:24:43 AM12/25/09
to modwsgi
Hi Graham & all,

Q: is mod_wsgi good for the application with a huge read-only data
singleton?

Details:

in my application there is a huge data object (~50% RAM).
The copies of such object will kill the system.
I'd like all child processes and/or threads to share this object.

Any hints, recommendations?

thanks,
regards,
Valery

Valery

unread,
Dec 25, 2009, 12:46:43 PM12/25/09
to modwsgi
OK,

I've found a document that explained me a lot a couple of years ago:
http://code.google.com/p/modwsgi/wiki/ProcessesAndThreading
:)

I guess, as for my question, winnt-like MPM should be used.
That is, single child process with multiple threads accessing the
global object.

Hm, but perhaps this will lead to a common GIL within such a single
process. Right?
And still it is not clear how to pass this object to child's
threads...

I guess, it should be passed somehow via app instance:
app = django.core.handlers.wsgi.WSGIHandler()
app.my_process_wide_read_only_array = ...

But how to access then this app instance from within Django's views?..

Thanks,
regards
Valery

Valery Khamenya

unread,
Dec 25, 2009, 1:29:57 PM12/25/09
to modwsgi
ОК, got it :)

one could do:

import my_app.module_with_huge_global_var

in the script that creates wsgi application instance.

In view functions, just import my_app.module_with_huge_global_var
again and the scope becomes available.

best regards
--
Valery A.Khamenya

Graham Dumpleton

unread,
Dec 26, 2009, 4:50:21 AM12/26/09
to mod...@googlegroups.com
2009/12/26 Valery <kham...@gmail.com>:

> OK,
>
> I've found a document that explained me a lot a couple of years ago:
> http://code.google.com/p/modwsgi/wiki/ProcessesAndThreading
> :)
>
> I guess, as for my question, winnt-like MPM should be used.
> That is, single child process with multiple threads accessing the
> global object.

Pretty well. The only other thing to do is to run code that depends on
that in single back end process and have web application communicate
with it using something like XML-RPC or Pyro.

> Hm, but perhaps this will lead to a common GIL within such a single
> process. Right?
> And still it is not clear how to pass this object to child's
> threads...
>
> I guess, it should be passed somehow via app instance:
> app = django.core.handlers.wsgi.WSGIHandler()
> app.my_process_wide_read_only_array = ...
>
> But how to access then this app instance from within Django's views?..

As normal global variable access as you already answered yourself in followup.

Graham

Reply all
Reply to author
Forward
0 new messages