php - Best strategy for doing real time, scalable audio processing? -


i building web application allows users upload audio files, music in particular. of time, expect duration of each song several minutes , file approximately 3-10mb in size. however, accept audio uploads 100mb, possibly allowing on hour of audio. using combination of ffmpeg, sox, , lame convert 7 possible formats mp3 , perform audio modifications including equalization, trimming, , fading. files stored , linked in database.

my current strategy handle entire process in 1 http file upload request using php on backend, in perform following functions:

  1. validation
  2. transcode audio multiple versions (using shell through php)
  3. store original , transcoded versions in temp directory
  4. upload audio files amazon s3 permanent storage
  5. commit id of each file database, linking them user

this works similar image processing system have set up. however, while images can complete whole process in few seconds, audio can take lot longer. @ most, audio take 5-10 minutes processed , stored.

my questions are:

  1. for audio processing, better fork off transcoding background process, writing state database, , pinging every few seconds update webpage vs. doing in 1 http request?

  2. with intention of scaling in future, advisable processing on single server instance, leaving frontend web instances free replicate / destroyed?

    • if yes, require cross-domain file uploading directly server? (anyone know if how youtube or big sites it?)

thanks!

if understand system correctly, best approach more this:

  • in web front-end, store audio , create "task" indicating audio needs processed.
  • run background task pulls tasks , processing. @ end of task, user can notified (if necessary) , database state can updated or whatever.

your tasks should written if fail partway through, can re-executed start without causing problems. can run multiple background tasks , web front-ends in architecture.

a way write tasks using message passing system amqp. there cheap services rabbitmq you. can, of course, build own on top of database, may require polling.

finally, might find faster , more efficient use service zencoder transcoding, because can parallelize work , handle more input formats, may not compatible processing.


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -