Django load balancing: How to share user media?
With two web servers serving the same Django application with the same underlying database, I could now balance all requests between the two servers.
Sessions are stored in the DB. Static media can be handled the same as if I used a content-delivery network (CDN).
But how do I handle user-uploaded media files that sit on a local filesystem of the webserver that receives the upload POST? Obviously, the second server will miss these files.
What is a reliable solution? NFS to some开发者_C百科 third server? Constantly running Unison or using a DVCS like Mercurial oder git?
Static media can be handled the same as if I used a content-delivery network (CDN).
There is your answer. Upload user media to a CDN. Checkout out django-storages for an S3 or Cloudfiles storage backend.
I personally use NFS to a third server, which then serves directly all the media when requested. This reduce the NFS usage to the upload phase, and the media server can be optimized for static assets.
精彩评论