> I have this situation..
>
> - We need to serve static files(images), lots of them, probably 100s
> of them per second.
>
> Our website is in Django and we need to support something like this:
>
> 1. a URL like /xyz.jpg should open an image.
> 2. image should be accesibe via this path only because we associate
> some data while an image is served, viz number of hits, bandwidth
> consumed, hits per second etc.
I'm not sure this is even a task for Django. If your primary concern is performance, try doing this directly in Apache or another web server via rewrite rules and use the access logs to do the accounting. Apache is good at access statistics.
If your primary concern is statistics, there is no way you can get exact figures. There may be any number of caching mechanisms between you and the client that you don't control so GET requests may never reach your server. Anyway, at this level there's no such thing as a "cdn version" because you are supposedly in control of the web server that does the mapping from a GET request to a file on the filesystem.
Erik
Google for X-SendFile
Cheers
Tom
My set up:
* apache2 on Ubuntu 10.04
* mod_wsgi 3.3, compiled with python 2.6.5 (the system python)
(but Ubuntu's mod_wsgi package was apparently not the problem)
* django installed in a virtualenv with python 2.6.5 also
* 2 django apps, one running on ':80' virtual host and one on
':8000' virtual host, each with a separate wsgi script (of course)
* apache server config (apache.conf) has WSGIPythonHome directive:
'WSGIPythonHome [path to virtualenv directory]'
* virtualenv directory has python interpreter in its bin dir and
python packages installed in its lib dir, including all django
libs
* I have verified that AuthenticationMiddleware can be imported
successfully from the command line within the virtualenv using
the virtualenv's python intepreter
* both django apps live within the virtualenv directory,
each in its own "project" directory there
* both apps are configured in apache with WSGIDaemonProcess directive
The error I continue to get is:
"ImproperlyConfigured at /
"The Django remote user auth middleware requires the
authentication middleware to be installed. Edit your
MIDDLEWARE_CLASSES setting to insert
'django.contrib.auth.middleware.AuthenticationMiddleware' before
the RemoteUserMiddleware class."
The relevant sections of the settings.py files for the apps are:
--------------
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.RemoteUserMiddleware',
)
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.RemoteUserBackend',
)
---------------
Ultimately I'll be using Active Directory (Kerberos) auth, but for
purposes of testing the REMOTE_USER stuff I've configured Basic
Authentication, and it is working (I authenticate successfully
before seeing that error message).
One thing that puzzles me is that in spite of a WSGIPythonHome
directive that points to the virtualenv, the error message lists
the "Python Executable" as "/usr/bin/python". The "Python Path"
shown in the error message seems correct: it includes the
virtualenv's site-packages directory, which is where django is
installed (there is no system-level django installed, Ubuntu's or
otherwise), and as I say I tested that the middleware classes
that the error message complains about can be imported using the
virtualenv's python interpreter on the command line.
Any suggestions welcome! (I can send the whole error page if it
would help, but I'll need to launder it a little.)
TIA!
Steve
Steve
See below for more details on my configuration ...
Steve
Steve
I posted the traceback I'm getting -- http://dpaste.com/293813/
I'm still completely mystified. The traceback directs me to:
"Edit your MIDDLEWARE_CLASSES setting to insert
'django.contrib.auth.middleware.AuthenticationMiddleware'
before the RemoteUserMiddleware class." But looking further
up in the traceback, it sees that d.c.a.m.AuthenticationMiddleware
*is* there, and it's true -- I already have it in my
MIDDLEWARE_CLASSES setting before the RemoteUserMiddleware class,
so how could mod_wsgi possibly not be finding it?