Logic flow for CDN, Web App and Processing servers
I'm building a website that allows user to upload and watch videos. Don't get down in the dumps - we haven't lost another man to another Youtube clone - the content is extremely narrow. And awesome. There are three servers :
CDN | Web App | Video Processor
The Web App server transfer user uploads to the CDN. The Video Processor server downloads uploaded videos from the CDN and processes them - spitting out multiple video types, thumbnails, and some meta data.
From here, the Video Processor server must do two things : (1) Upload the new data to the CDN (solved), and (2) Pu开发者_Go百科sh references to the CDN data in the Web App's database (problem).
PROBLEM : How should the Video Processor server get data about CDN files (video urls, titles, etc) to the Web App?
SOLUTION A : Save the processed video data in a txt file, upload to Web App server when finished, and set the Web App server to import the txt files into a database on regular intervals.
SOLUTION B : Video Processor POSTS data to Web App and Web App creates db entries. Credit to MM (I'll vote up when you post).
How good is Solution A? B? Do you have better?
Edit : CDN is Rackspace Cloud, Web App is on Django, Video Processor is an Ubuntu server box running some python scripts.
Wondering why the users upload the videos to the CDN at the start of the process but this is how I might approach it...
User uploads video and web app is notified e.g. by the video being uploaded to the web app or to the CDN as in the example above.
Web app exposes a list of videos to be converted via an API.
Video processor queries the API for the next video in the queue, it then retrieves it and starts the conversion process.
When the video has been converted, the video processor uploads it and uses the web app API to update the status, URLs and other meta data.
Generally I'd decouple the parts using APIs so you can replace them as necessary.
精彩评论