Khan / khan-api

Documentation for (and examples of) using the Khan Academy API
http://www.khanacademy.org
377 stars 75 forks source link

Slow fastly response #80

Closed kdadmin closed 9 years ago

kdadmin commented 9 years ago

I mentioned in an another post the slow reponses when downloading/streaming videos since the change to fastly.

https://github.com/Khan/khan-api/issues/79

I know little about what is going on, but I have observed the timing out occures on the first request for a video, then subsequent requests for that video are very fast. It's as if fastly is caching something on the first request - and taking its time to do so - after which it performs nicely.

Sometimes a response is immediate, as if it has been cached already by another user.

Requests that timed out for me in just the last half hour were for videos from the Partner Content/California Academy Of Sciences.

Suggestions welcome.

Edit: Perhaps something to do with Stream-on-Miss? https://docs.fastly.com/guides/caching/what-support-does-fastly-have-for-large-files

Edit 1/7/15: A few links with 60+ second responses if not cached - 503 Backend Read Error in iE: http://fastly.kastatic.org/KA-youtube-converted/dsvLLKQCxeA.mp4/dsvLLKQCxeA.mp4 http://fastly.kastatic.org/KA-youtube-converted/Oc8sWN_jNF4.mp4/Oc8sWN_jNF4.mp4

S3 origin: http://s3.amazonaws.com/KA-youtube-converted/dsvLLKQCxeA.mp4/dsvLLKQCxeA.mp4 http://s3.amazonaws.com/KA-youtube-converted/Oc8sWN_jNF4.mp4/Oc8sWN_jNF4.mp4

https://docs.fastly.com/guides/backend-servers/503-error-explanations

Thanks Gary

csilvers commented 9 years ago

Hi Gary, I believe I've made the suggested fastly changes. I apologize for the delay in getting to this.

Can you try some fastly urls and see if they are more responsive for you now?

kdadmin commented 9 years ago

Here in Los Angeles, 60 + second resposnses for both: VI Hart "Doodling in Math:Dragon Scales" VI Hart "Doodling in Math:Dragon Dungeons"

Gary

csilvers commented 9 years ago

It turns out I had a configuration error that I fixed yesterday afternoon. It looks like you tried before the error was fixed. Do you mind trying again?

kdadmin commented 9 years ago

The connections appear fast, very nice!, but there may be some sort of delay actually streaming the data in some cases - that is the video does not play.

No time today, but I'll have time Friday to look at it more.

kdadmin commented 9 years ago

All videos tested connected instantly.

No delays when downloading a batch of videos.

On 2 large videos, streaming playback did not occur for 30 seconds, but on the second request playback began immediately. Note my slow connection (3.2 Mbps) is not fast enough to properly stream big videos, so that may be the culprit. I'm testing with VLC and LAV Filters players.

So I vote to call it fixed.

Thanks much, nice job, Gary

csilvers commented 9 years ago

Great, glad to hear!

kdadmin commented 9 years ago

I'm going to re-open this.

In the previous two posts, I mentioned a delay receiving the stream for some videos.

This happens when the video is not cached and the request is being handled via stream-on-miss - once cached (60+ seconds later) there is no delay.

Using a capture program, I see a TCP reset after about a second, then a 20 second delay before streaming is resumed.

Good examples are under the New an Noteworthy topic: Apollonius Seated Boxer, and Bernini, Ecstasy of Saint Terresa

Their URLs are: http://fastly.kastatic.org/KA-youtube-converted/RKcJvjP9zgY.mp4/RKcJvjP9zgY.mp4 http://fastly.kastatic.org/KA-youtube-converted/FvsSPJoJB3k.mp4/FvsSPJoJB3k.mp4

I would think this happens with your IPhone and Win8 app video players also?

This does not happen when streaming directly from S3 using VLC or my app's FFMPEG player. http://s3.amazonaws.com/KA-youtube-converted/RKcJvjP9zgY.mp4/RKcJvjP9zgY.mp4 http://s3.amazonaws.com/KA-youtube-converted/FvsSPJoJB3k.mp4/FvsSPJoJB3k.mp4

Perhaps there is a configuration setting that could cause this?

Thanks, Gary

benjaminjkraft commented 8 years ago

Apologies for the very delayed reply to this ticket. At this point it looks like these URLs are working fine -- they're responding quite quickly for me. Let us know if you still see any issues.

kdadmin commented 8 years ago

It's instantly if cached, about 4 seconds otherwise. Been that way since July or so.