I’m using a private bucket to host m3u8 videos which I then serve on demand by signing all the “.ts” segments using the Google Cloud Storage Signurl client for Golang. Testing on my computer worked, it took about 3 seconds to upload the m3u8 file and then sign each segment and then serve it back to the end user.
The problem came when I deployed everything to Google Cloud Run, the entire process above is taking 15 seconds to complete. I realized that the service account that is automatically used to authenticate to Google Cloud cloud services was the problem (Well, actually the problem must be the way it works and not the service account). I had to manually specify a “GOOGLE_APPLICATION_CREDENTIALS” and the problem was solved, it went from 15 seconds to 2 seconds to complete the task. So, I still don’t know why this is actually causing the delay and I want to know if this is the best way to fix this.
opts := &storage.SignedURLOptions{
Method: "GET",
Scheme: storage.SigningSchemeV2,
Expires: time.Now().Add(5 * time.Hour),
PrivateKey: []byte("-----BEGIN PRIVATE KEY-----n..."),
GoogleAccessID: "[email protected]",
}
url, err := r.VidSrc01.SignedURL(objectName, opts)
if err != nil {
return "", err
}
3