Django: how to serve user-submitted images & thumbnails from separate, multiple servers?

柔情痞子 提交于 2019-12-03 07:56:39

问题


For my Django site, I'd like to:

  1. Accept images submitted by users
  2. Generate thumbnails from those images
  3. Put both the original images and the thumbnails onto separate, multiple servers that are dedicated to serving images

I need multiple, separate servers to serve the images/thumbnails to ensure I have enough IO performance.

What is the best way to build a distributed image serving system like this? Any open source software that would help?

Thanks.


回答1:


This sounds like a job for distributed task queues. My personal favorite is Beanstalkd b/c it is so lightweight and easy to use.

Server: https://github.com/kr/beanstalkd
Client Library: https://github.com/PeterScott/beanstalkc
Django Helper: https://github.com/jonasvp/django-beanstalkd

The way it would work is like this:
1. File gets uploaded and stored locally
2. Job gets created by upload view and put into a beanstalk tube
3. Beanstalk workers are watching the tubes for work, they grab the new job
4. The worker could create the thumbnails and distribute it to as many servers as you need

The beauty is that you can have as many workers feeding off the tube as is required. So if you ever get behind, simply fire up more workers. The workers can be on the same machine or on many separate machines, and it will all work fine.



来源:https://stackoverflow.com/questions/5615654/django-how-to-serve-user-submitted-images-thumbnails-from-separate-multiple

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!