Just a follow-up to yesterday's meeting on session support. We were
pretty sure Python global data is local to the apache child process
hosting the interpreter and will not be available to other request
handlers. Stephen also suggested utilizing memcached. FYI both of these
are validated in mod_wsgi documentation, which I've copied below. Also Adam has made a suggestion of using sqlite backed by a file in /dev/shm.

------------------------------------------------------------------------

Application Global Variables

Because the Python sub interpreter which hosts a WSGI application is
retained in memory between requests, any global data is effectively
persistent and can be used to carry state forward from one request to
the next. On UNIX systems however, Apache will normally use multiple
processes to handle requests and each such process will have its own
global data.

This means that although global data can be used, it can only be used to
cache data which can be safely reused within the context of that single
process. You cannot use global data as a means of holding information
that must be visible to any request handler no matter which process it
runs in.

If data must be visible to all request handlers across all Apache
processes, then it will be necessary to store the data in the filesystem
directly, or using a database. Alternatively, shared memory can be
employed by using a package such as memcached.

Because your WSGI application can be spread across multiple process, one
must also be very careful in respect of local caching mechanisms
employed by database connector objects. If such an adapter is quite
agressive in its caching, it is possible that a specific process may end
up with an out of date view of data from a database where one of the
other processes has since changed the data. The result may be that
requests handled in different processes may give different results.

The problems described above can be alleviated to a degree by using
daemon mode of mod_wsgi and restricting to one the number of daemon
processes in the process group. This will ensure that all requests are
serviced by the same process. If the data is only held in memory, it
would however obviously be lost when Apache is restarted or the daemon
process is restarted due to a maximum number of requests being reached.

--
John Dennis <jden...@redhat.com>

Looking to carve out IT costs?
www.redhat.com/carveoutcosts/

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to