CloudFront Uploads via POST and PUT
aws.typepad.com
aws.typepad.com
Second, your users can now benefit from accelerated content uploads. After you enable the additional HTTP methods for your application's distribution, PUT and POST operations will be sent to the origin (e.g. Amazon S3) via the CloudFront edge location, improving efficiency, reducing latency, and allowing the application to benefit from the monitored, persistent connections that CloudFront maintains from the edge locations to the origin servers.
So you get to save on having to configure and serve multiple domain names (which isn't all that hard), but you have to add logic to your server side code and user exposed uploading UX to check and display to the user if content is finished being uploaded by the user to cloudfront and by cloudfront to the origin/backing store before using/processing/displaying it.
I wonder if this will be improved as well? I personally wouldn't want to accept user data without SSL.
> Pricing for Custom SSL Certificates is simple. We charge a fixed monthly fee of $600 for each custom SSL certificate you associate with your CloudFront distributions, pro-rated by the hour. For example, if you had your custom SSL certificate associated with at least one CloudFront distribution for just 24 hours (i.e. 1 day) in the month of June, your total charge for using the custom SSL certificate feature in June will be (1 day / 30 days) * $600 = $20. Detailed pricing information for the Custom SSL Certificate feature is available on the CloudFront Pricing Page.
Was a no brainer to setup and honestly I never even think about it. We just update the S3 bucket for the site and CloudFront picks up the changes. Support for these new HTTP methods makes CloudFront a lot more interesting for a dynamic app.
Regarding SSL, the $600 per month seems like a lot for SSL but I think (pure speculation) it's because of the individual IPs needed for each endpoint. SSL ports can't be shared with other hosts[1]. Since CloudFront has endpoints at multiple edge locations, they would need multiple IPs per SSL cert. Add CPU cost for SSL processing too and I guess that's where the $600 comes from.
[1]: Well technically they can using SNI[2] but some older browsers don't support it (mainly IE on XP).
I'm curious if the edge receives the full POST/PUT first and then does a complete PUT/POST to the origin, or does it forward as it's receiving.
//make yourself a file dd if=/dev/zero of=1m count=1 bs=1m
//post directly to origin
time curl -F "file=@1m" -X POST "http://up4.pinkbike.com/upload/t.php" -w %{speed_upload}Bytes/s
array(3) { ["HTTP_USER_AGENT"]=> string(81) "curl/7.19.7 (universal-apple-darwin10.0) libcurl/7.19.7 OpenSSL/0.9.8y zlib/1.2.3" ["REQUEST_METHOD"]=> string(4) "POST" ["CONTENT_LENGTH"]=> string(7) "1048770" } 230177.000Bytes/s real 0m4.560s user 0m0.004s sys 0m0.010s
//post via Cloudfront to same origin
time curl -F "file=@1m" -X POST "http://dhima35gjf4ct.cloudfront.net/upload/t.php" -w %{speed_upload}Bytes/s
array(3) { ["HTTP_USER_AGENT"]=> string(17) "Amazon CloudFront" ["REQUEST_METHOD"]=> string(4) "POST" ["CONTENT_LENGTH"]=> string(7) "1048770" } 227055.000Bytes/s real 0m4.623s user 0m0.005s sys 0m0.011s
So upload time is not much different from my location. The origin is in San Jose, and in my case I'm in Vancouver BC, and going through the Seattle cloudfront edge. Would be interesting to see what you get from other locations ( I'm occasionally getting "ERROR: The request could not be satisfied" with cloudfront post )
Combine that with a custom SSL certificate at all the edge nodes ($600/month) and this is a pretty compelling dynamic CDN offering.
Can't wait to try it out for our API.
I see your point about a better connection between S3 and CF, but it's a hypothesis, and the docs don't confirm it. My experience with CF is that the first fetch (for GETs) tends to be "slow"; I don't have enough numbers to check whether is as slow as S3 (whose speed is highly variant over time) or not. But I have always thought that the speed of S3 was impacted by "I/O" (virtual I/O) time, not network or bandwidth. EC2 servers which are in the same region are able to sustain much higher transfer rates.
The upload to the edge CF server could be ACK'd faster and at this point the user still has a copy and so does the edge server. If meanwhile he sends somebody a link to this photo, if they are nearby, they'll hit the same edge server and get it faster not slower.
If on the other hand they are far away they'll hit a different edge server that would have to grab it in turn from S3 but that would have happened anyway, no? As far as I understand it.
Also a trick that helps propagate things to CF edges faster just occurred to me: S3 can be setup to POST somewhere after every write. So maybe..
iPhone <----> Closest CloudFront Edge Server <-----> S3 ----> Central service (App Engine? :P ) ---> Cloudfront Edge{1,2,3..} <---> S3.
But that might be a tad overkill, heh. (Also I'm not sure how you can trick CF to direct to a specific edge without using proxies)