snickers / snickers

:chocolate_bar: An open source alternative to the video cloud encoding services.
http://snickers.video
Apache License 2.0
533 stars 76 forks source link

Request throttling #135

Open NickMoores opened 8 years ago

NickMoores commented 8 years ago

Hey there,

Nice work!

Unless I've missed it, I couldn't see anything that attempts to throttle requests - is there any intention to implement anything simliar? We use FFMPEG behind a web service that generates thumbnails from MP4 videos, but we find that it doesn't take too many instances of FFMPEG running concurrently to quickly overwhelm a server's resources!

Thanks, Nick

flavioribeiro commented 8 years ago

Hey @NickMoores! So, @fsouza had a really great idea to detach the API from the core/ffmpeg itself. He was planning to add a queue on Mongo so we could have unlimited workers on different instances grabbing the jobs from the queue and running the actual encode job. @fsouza, do you have anything else to add?

fsouza commented 8 years ago

Yes, that would make scaling easier. That's how the workflow would work:

It's possible to have as many workers as possible, or even don't have workers running at all, and some smart architecture that wakes workers up when there are jobs to be processed.

We could use MongoDB with monsterqueue (https://github.com/tsuru/monsterqueue), this way we wouldn't need another dependency. We can also make this extensible, in case users want to use some other technology for the queue (enabling serverless deployments with AWS's SQS + Lambda, for example).