PROBLEM: Current sorl-thumbnail infrastructure prevents us from having multiple Django application servers.
sorl-thumbnail (Current)
Stock sorl-thumbnail generates new thumbs and writes to app server
Thumbnails and database are specific to app server
Cannot load-balance.
High Performance Django (easy-thumbnails)
p.47
Once you start adding app servers... NFS or GlusterFS or Ceph
For most sites... Amazon S3 or Rackspace Cloud Files are easier.
Once file uploads moved off the local disk, manipulating them
(e.g. thumbnailing) becomes painfully slow because network.
Our approach: Common operations predefined and done upfront.
For thumbnails, define all common sizes in the Django settings.
On upload, Celery tasks to pre-generate and upload in the background.
As a failsafe, generate thumbnails on-the-fly from a template tag.
Ensures users will never see broken thumbnails in the event of
request happening before the queued task completes.
PROBLEM: Current sorl-thumbnail infrastructure prevents us from having multiple Django application servers.
sorl-thumbnail (Current)
Stock sorl-thumbnail generates new thumbs and writes to app server Thumbnails and database are specific to app server Cannot load-balance.
High Performance Django (easy-thumbnails)
p.47 Once you start adding app servers... NFS or GlusterFS or Ceph For most sites... Amazon S3 or Rackspace Cloud Files are easier. Once file uploads moved off the local disk, manipulating them (e.g. thumbnailing) becomes painfully slow because network. Our approach: Common operations predefined and done upfront. For thumbnails, define all common sizes in the Django settings. On upload, Celery tasks to pre-generate and upload in the background. As a failsafe, generate thumbnails on-the-fly from a template tag. Ensures users will never see broken thumbnails in the event of request happening before the queued task completes.
https://easy-thumbnails.readthedocs.io/en/latest/usage/#thumbnail-aliases NOTES
Pregenerate thumbs
Continue using sorl-thumbnails Only option is use NFS to share /var/www/ddrpublic/media/cache Works as long as NGS works
Pregeneration
Publish files to kiki ddrpubcopy ROLE SRCDIR DESTDIR --rsync=USER@HOST:DESTDIR --mkthumbs
REST API POST
Pregeneration ddrmkthumbs --config=/etc/ddr/thumbnails.cfg /var/www/media/COLLECTIONID` thumbnails.cfg installed by Ansible on kiki, ddrpublic app servers use aliases format from easy-thumbnails, etc { "sm":"50x50", "med":"100x100 option1 option2", "lg":"250x250 option1" } settings.py THUMBNAIL_ALIASES = { 'all': { 'sm': {'size':50x50'}, 'med': {'size':'100x100', 'option1':VALUE, 'option2':VALUE}, 'lg': {'size':'250x250', 'option1':VALUE}, }, } Creates subdirectories and files are absent /var/www/media/COLLECTIONID/OBJECTID-a.jpg /var/www/media/COLLECTIONID/sm/OBJECTID-a-50x50.jpg /var/www/media/COLLECTIONID/med/OBJECTID-a-100x100.jpg /var/www/media/COLLECTIONID/lg/OBJECTID-a-250x250.jpg [cleans up anything that doesn't match pattern in thumbnails.cfg?]