madebyhiro / codem-transcode

Offline video transcoder written in node.js
Other
153 stars 68 forks source link

/jobs/:id is MUCH slower than /jobs #40

Closed guilhermednt closed 9 years ago

guilhermednt commented 9 years ago

When running 3 jobs on a server (using all slots), Transcoder becomes extremely slow when performing a GET /jobs/:id but the GET /jobs works just fine.

Since Scheduler depends on /jobs/:id, it also becomes utterly slow.

Any ideas on how to troubleshoot this?

tieleman commented 9 years ago

How many jobs are in your database, and which database are you using (sqlite, mysql?)?

/jobs simply returns the active jobs from memory, while /jobs/:id performs a trip to the database to retrieve that job. If there are a lot of jobs in your database that might be the reason (especially if you're on sqlite), or the machine is so CPU-bound that reading the database becomes slow. Try purging old finished jobs (there's an endpoint for that).

tieleman commented 9 years ago

Also, I just pushed a commit (9e752289b4e38655d04926f1ce10f0e86fc240e8) that returns a job from memory if it exists. There's no need to go to the database if the job is already in memory.

guilhermednt commented 9 years ago

OH, of course! I totally forgot about sqlite... I was using it to test before. Thanks a lot @tieleman!

tieleman commented 9 years ago

np, good luck!

guilhermednt commented 9 years ago

Just to let you know: I applied 9e75228 and it by itself already solved the problem. Sure, I still have to use a decent database, but now I'm able to procrastinate a bit more on that on focus on other things. hehe

Thanks again @tieleman!