0

We're hosting software installers (~60Mb) on S3 and serve them through CloudFront. We noticed that files non-being downloaded frequently get wiped from the CF cache and thus download slower than usual. I suspect that other CDN providers have the same behavior for infrequently accessed files.

I'm thinking about creating 4 servers instead of S3+CF: 2 in US, 1 in Europe, 1 in Australia. These servers should cover most of our customers.

The question is how to configure them to be convenient, virtually maintenance-free. With S3+CF I spend zero time configuring servers - they just work. I'm searching for similar solutions.

I though about renting 4 dropslets from DigitalOcean and use Cloudways to configure them. Then I will configure DNS provider to direct customers to the nearest server. This will cost me 17*4=$68, almost the same we currently pay for CloudFront traffic. However, I don't like CloudWays and their support. Sometimes things simply don't work and they change servers manually, so it's not that easy as it should be.

Is there any other options?

  • 60MB is pretty tiny. 60Mb is even smaller, less than 10MB. It should download quite quickly from most places in the world. The install time for Windows is probably much higher than the download time. I suspect this could be a case of premature optimization. Exactly what problem are you having? Are downloads from a specific country slow, causing you to lose customers? Are customers complaining? – Tim Apr 21 '17 at 20:55
  • 1
    You can try setting the default TTL on your CloudFront distribution behavior to the maximum value. If it's rarely downloaded it may still be evicted. You can also read this for more info. – Tim Apr 21 '17 at 20:58
  • @Tim Thank you for the reply. Saying 60Mb I meant 60 megabytes. It's about a half minute download for a lot of people. Expires header is correctly set and file is being kept while it's used. However, if we perform A/B test and we have two files with smaller download numbers, files get evicted from the edge servers. – Ivan Nikitin Apr 21 '17 at 21:06
  • 60MB taking 30 seconds is around 16Mb (megabits). That's not a bad download rate if there's any latency involved. I'm New Zealand, and because of latency downloads using a single TCP connection don't go a lot over that, but of course via a CDN is faster. I still wonder if this is really a problem that needs solving. If it is, and a CDN evicts your files, then yes moving them closer to the user could help. – Tim Apr 21 '17 at 21:16
  • Hm, with that small files seldomly downloaded I would just publish them to S3 geo-replicated buckets and not use CF at all. – eckes Apr 22 '17 at 18:27
1

Overview

Unfortunately you can't control CloudFront (CF) eviction - they may evict objects at any time. However, CF connects to S3 using the AWS internal network, not the internet, so fetching the object should be faster than the user fetching from S3 directly. This still may not meet your needs.

Tweak Current Setup

However, you should check your CF configuration. In your existing setup you should create a behavior that passes through no cookies or headers, that way all users who request the setup get the same object. If you're passing through cookies and headers CF may have 1000 versions of the same install cached, so is evicting them regularly.

You should of course have looked at the caching headers the origin is sending to CF. If it's not sending any define the TTL in CF.

Another Option

If you can't get the current setup work, instead of hosting servers you can create S3 buckets in each AWS region. You can't automatically direct users to the closest bucket, but you can use geolocation and generate a link to the bucket you think is closest to the user.

CF can be configured to add the header "Cloudfront-Viewer-Country" to requests. You can use behaviors to add those headers to only very specific requests, which you should, otherwise your cache hit rate will decrease. This is because caching is per header, so each different country that hits the CF node would have their own item in the cache. This in turn reduces hit rate.

Your application / web server could receive this header, decide which S3 region/bucket to use, and generate the link to the bucket closest to the user.

Premature Optimization

Because this is such a small download, I wonder if this who question is a case of premature optimization. 60MB should download pretty quick anywhere in the world that has a decent internet connection. If their last mile connection is poor then it does't much matter where it's being downloaded from.

You haven't actually given us a problem, such as "downloads for users in this country are slow", you've just described the technology which could be causing a problem.

0

We noticed that files non-being downloaded frequently get wiped from the CF cache and thus download slower than usual.

Have you set the Expires header properly on your origin? You should be able to set that far into the future, which will instruct Cloudfront to not expire the objects as often.

The question is how to configure them to be convenient, virtually maintenance-free.

You might as well start looking for wood elves in the forest. :)

Honestly, running servers requires maintenance. If you neglect that maintenance, things get hacked, your server gets used in botnets, your data gets leaked, and you have a bad day (or month) while you're recovering.

However, I don't like CloudWays and their support.

Then't don't use them.

If you really think that self-hosting is the way to go, then enlist the help of a sysadmin that can keep watch on things and keep things patched and healthy. Note: this doesn't require much time, maybe a handful of hours per month. Doing so may even be cheaper than paying for a solution like Cloudways, and will be more flexible.

  • Thank you for the reply. Yes, we have Expires header set. If people download file frequently (from the same node), it's being kept. Otherwise CloudFront wipes it out from the node servers. I'm searching for other non-CDN solutions that require as little maintenance. I don't want to hire a system administrator. – Ivan Nikitin Apr 21 '17 at 21:05
  • Well, you're in a hard spot then. You say you need a non-CDN solution, but anything that's non-CDN solution will require either maintenance from you, or from someone you hire. – EEAA Apr 21 '17 at 21:08
  • "which will instruct Cloudfront to not expire the objects as often." Strictly speaking, not exactly. Expires and Cache-Control and/or the configurable min/max/default timers (if enabled) will only tell CloudFront how long it may to keep an object in an edge or regional cache... not how long it should (or must). Objects not frequently requested can still be evicted earlier. But, you're quite right, if the values aren't set or set reasonably. – Michael - sqlbot Apr 22 '17 at 4:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.