One commonly recommended practice in Django (although applicable elsewhere) is to serve up your static media from a different server than the one running Django for dynamic pages.
This becomes a slight challenge when you have user-contributed media (like allowing users to upload photos).
Here are some possibilities I can think of:
- mount the media server from the Django server via NFS so write from Django directly to the media server
- have the Django server write locally but then subsequently move the files to the media server via rsync (or similar)
- like the previous case but to avoid 404s before the file has been moved, the relevant model has a flag for whether the file is ready or not and return an "in progress" message until the file is done (not sure how Django would know the file has successfully been moved, though, unless a Django-based worker process was doing it instead of just rsync)
- similar to the previous two cases but initially store the image on (and serve it from) the Django server until the flag says the URL to the media server can be used
- have Django running on the media server just for the purpose of receiving media POSTs (but no dynamic page generation)
- having some other WSGI (or similar) process running on the media server to receive media (and then communicate with the Django server on the backend)
I guess S3-based solutions add some extra issues but ideas 2, 3 and 4 would be applicable.
Anyone have experiences (good or bad) with any of these? Any possibilities I'm missing?
The original post was in the categories:
but I'm still in the process of migrating categories over.
The original post had 16 comments I'm in the process of migrating over.