Reputation: 827
I got 3 buckets: 1 main bucket main.ms.com 2 others west.ms.com and eu.ms.com
the replication is enabled like this :
bucket main.ms.com -> eu.ms.com -> west.ms.com
how can I do for an http request to pickup the good bucket : for example : bucket main.ms.com/mypicture.jpg should should use : - eu.ms.com/mypicture.jpg if I am in europe - west.ms.com/mypicture.jpg if I am in west coast .
thanks
Upvotes: 0
Views: 80
Reputation: 179074
There's not a straightforward mechanism to do this from your desired starting point (bucket replication), if you don't already have application/web servers in those regions with geolocation/latency-based routing in place, sending requests to them.
If you did have that, the solution would seem obvious -- each server should proxy requests to the nearest bucket, or provide links that address the appropriate bucket since its audience should be in the same region.
But the canonical solution here would not involve bucket replication... it would be to use a single bucket, along with the AWS CloudFront CDN, which does geo-routing of requests to the nearest endpoint edge location, fetches the object from the bucket and caches popular items at each edge location that has seen a request for it (without any storage charges) until the object expires or is evicted to make room for more popular objects (at which point, the edge location would fetch it again from S3 the next time it was requested via that edge location). This would be used in front of a single bucket.
There is not a way to transparently do this with replicated buckets, because when a bucket is accessed directly, the Host:
header sent by the browser needs to match the bucket name, exactly. Since the replicated buckets necessarily have different names, a latency-based routing solution (such as Route 53 can provide) can't be used to send requests to the nearest bucket without some kind of intermediate servers or services involved.
Upvotes: 1