2

I've built a Ruby on Rails application which at its core involves users and videos.

There are a few users with admin rights who have the ability to upload videos (rougly 5 minutes each, HD). The rest of the users on the site are only allowed to watch the videos; they themselves do not have the ability to upload. I expect that around 20 videos will be uploaded per week. No more than 2 or 3 thousand users (all in North America) will be watching the videos.

I have two S3 Buckets, let's call them Bucket X and Bucket Y. I've built in Carrierwave to upload the videos to S3 Bucket X, and AWS Elastic Transcoder to take the video from Bucket X, transcode it to Mp4, and place it in Bucket Y.

The resulting video files in Bucket Y are exactly how I want them: web optimized, compressed MP4 format. If necessary, I could serve the videos straight from their url in Bucket Y.

At the same time, however, I am using the AWS Cloudfront CDN to quickly deliver assets and user-uploaded profile pictures to each user.

For a site like mine, where roughly 20 videos of 5 minutes in length are uploaded per week, does it make sense to use Cloudfront?

I have come across articles like this and that, which suggest Cloudfront is appropriate for serving videos. I also have come across others, like this stack overflow answer by Wayne Koorts which suggest Cloudfront is mostly only advantageous in delivering smaller files and may be costly.

Considering that only around 20 videos will be uploaded per week, and the rest are get requests, I am not concerned with the price of using Cloudfront. But, is Cloudfront even worth using in this situation? Will it actually speed up loading times, if we are talking about 5 minute-long videos?

Any help is appreciated. Thank you very much in advance.

Community
  • 1
  • 1
Parker
  • 493
  • 1
  • 4
  • 14
  • 1
    Your application is it serves worldwide or limited to certain geography or country? – Piyush Patil Aug 18 '16 at 14:05
  • It is only USA. However I thought Cloudfront has multiple locations within USA, which would make a difference, right? As opposed to a single S3 Bucket. – Parker Aug 18 '16 at 15:07
  • 2
    Yes @Parker CloudFront has several locations in the US and yes, it generally makes more sense to use CloudFront with S3 than not to use it, even if you don't expect a lot of traffic or a lot of cache hits... almost a no-brainer, in fact. If it works with S3, it will work with CloudFront+S3, with the one caveat that CloudFront has a download file size limit of 20 GB while S3 supports files up to 5 TB. Uncached content will generally still download faster through CloudFront because of the optimized network between CloudFront edges and S3 unless the browser is geographically close to the bucket. – Michael - sqlbot Aug 18 '16 at 22:27

3 Answers3

3

This is just too broad, but as you stated that initially your videos will be served only for users in North America, there's no reason to use CloudFront yet. Wait until you have the need to serve to different geographical locations to include it in your architecture.

Remember AWS says that CloudFront main feature is "Distribute content with low latency and high data transfer rates by serving requests using a network of edge locations around the world."

imTachu
  • 3,759
  • 4
  • 29
  • 56
  • Sorry I was trying to avoid being too broad. My question basically comes down to whether or not Cloudfront is worth it for serving up 5 minute-long videos. – Parker Aug 18 '16 at 15:10
  • Does is matter that Cloudfront has multiple edge-locations within North America? The Cloudfront product details page says that there 21 edge locations in North America. I am just trying to figure out if this is helpful for delivering videos as opposed to delivering them from an S3 bucket in a single location (mine is us-east-1). – Parker Aug 18 '16 at 15:11
  • 1
    CloudFront is absolutely worth to serve your 5 minute videos **IF** you are experiencing very low speed to serve your users. You want to use CloudFront to deliver content to end users with lower latency. My advice: Wait until your business really need it, otherwise you are incurring in some unnecessary optimization costs. :) – imTachu Aug 18 '16 at 15:52
  • Excellent advice. Thank you. – Parker Aug 18 '16 at 16:47
  • 1
    My pleasure. Anytime :) – imTachu Aug 18 '16 at 16:59
  • 2
    Notice that, with CloudFront "Price Class 100" (which is basically US+Canada+Europe), which seems to perfectly fit your target audience, you are likely to see both a reduced latency (and, therefore, an increased max theoretical throughput!) as well as reduced cost: the Data Transfer cost for S3 (out to the internet) is $0.09/GB after the first 1GB and up to 10TB; for CloudFront, on the other hand, it's $0.085/GB, so there's about a 6% savings there. The requests costs on CloudFront are a little bit more expensive than S3, but since you have larger videos, you are more likely to spend [...] – Bruno Reis Aug 19 '16 at 01:08
  • 1
    [...] more on Data Transfer than on number of requests (for tiny files, the reasoning would be different). If you think the additional complexity isn't that big, I would definitely use CF! – Bruno Reis Aug 19 '16 at 01:10
  • Never saw your comments until now, Bruno. Thank you so much for this information. This was very helpful!!!! – Parker Aug 29 '16 at 16:22
2

By entering the appropriate numbers in the AWS Monthly Calculator you can get a rough idea of how much the CloudFront vs S3 will cost. Remember that you will probably store the videos in S3 anyway, it is likely that the "Data Transfer Out" from each service respectively that matters most.

matsev
  • 32,104
  • 16
  • 121
  • 156
  • Thanks for the tip, I will check that out. I'm not too concerned with the cost. Do you have any clue how much faster the videos will load from Cloudfront as opposed to straight from S3? Would they even load faster at all considering these are 5 minute-long videos we are talking about, not images and stylesheets? – Parker Aug 18 '16 at 15:13
  • 1
    @Parker Sorry, I do not have any figures. I guess it is the load time from the request until the first frame is visible that matters if it is a streaming application, for the remaining part 5 minutes will be 5 minutes. More to the point, it is likely that the bandwidth of your users that will set the limit. I suggest that you do a PoC (there are some good suggestions in the links that you provided) to see what works best. – matsev Aug 18 '16 at 18:23
1

If cost is not an issue for you then using Cloud Front will be beneficial even if your app is just limited to USA. And definitely the video will load more faster if you are using Cloud Front as compared to directly from S3. As Cloud Front caches the video to the edge locations it improves the load speed of the video.

Piyush Patil
  • 14,512
  • 6
  • 35
  • 54