impress/config/initializers
Matt Dunn-Rankin 3ae8a265b2
Use Fastly to cache our PNG assets from S3
We've been serving images directly from `impress-asset-images.s3.amazonaws.com` for a long time. While they serve with long-lasting HTTP cache headers, and the app requests them with the `updated_at` timestamp in the query string; each GET request still executes a full S3 ReadObject operation to get the latest version.

In the past, this was only relevant to users on Image Mode, not Flash Mode. But now that everyone's on Image Mode, this matters a lot more!

Now, we've configured a Fastly host at `impress-asset-images.openneo.net`, to sit in front of our S3 bucket. This should dramatically reduce the GET requests to S3 itself, as our cache warms up and gains copies of the most common asset PNGs.

That said, I'm not sure how much actual cost impact this change will have. Our AWS console isn't configured to differentiate cost by bucket yet—I've started this process, but it might take a few days to propagate. All I know is that our current costs are $35/mo data transfer + $20/mo storage, and that outfit images are responsible for most of the storage cost. I hypothesize that `impress-asset-images` is responsible for most of the reads and data transfers, but I'm not sure!

In the future, I think we'll be able to bring our AWS costs to near-zero, by:
- Obsolete `impress-asset-images`, by using the official Neopets PNGs instead, after the HTML5 conversion completes.
- Obsolete `impress-outfit-images`, by using a Node endpoint to generate the images, fronted by a CDN cache. (Transfer the actual data to a long-term storage backup, and replace the S3 objects with redirects, so that old S3 URLs will still work.)

I hope this will be a big slice of the costs though! 🤞

(Note: I'll be deploying this on a bit of a delay, because I want to see the DNS propagate across the globe before flipping to a new domain!)
2021-05-12 22:50:05 -07:00
..
airbrake.rb phew. rails 3.2.12, including some asset pipeline. still buggy. 2013-03-05 20:08:57 -06:00
asset_hosts.rb Use Fastly to cache our PNG assets from S3 2021-05-12 22:50:05 -07:00
attack.rb pet rate limit is now 3/30sec 2013-07-02 20:50:34 -07:00
aws_s3.rb improve app infrastructure to make a dev environment easier to reproduce 2015-07-16 17:44:52 -04:00
backtrace_silencers.rb rails 3 2010-05-14 18:12:31 -04:00
bullet.rb now that we're on rails 3.2, mount resque at /resque - just for 2013-03-05 21:09:08 -06:00
camo.rb camo the emotes on the campaign show page 2015-08-05 19:41:42 -04:00
carrierwave.rb oooops, carrierwave wants s3 config in prod, too 2015-07-17 18:26:43 -04:00
devise.rb devise implemented, but not remembering 2011-01-26 13:40:15 -05:00
flex.rb oops: set flex config.hangers_enabled before the line that checks for its presence 2013-06-11 11:22:17 -07:00
flex_metrics.rb have new relic trace flex methods 2013-01-31 18:39:51 -06:00
inflections.rb rails 3 2010-05-14 18:12:31 -04:00
locale_meta.rb latest i18n gem cares is stricter about locales, so configure better. this works, right? :x 2015-07-16 18:59:45 -04:00
mime_types.rb rails 3 2010-05-14 18:12:31 -04:00
neopia.rb the dev version of neopia has a hostname now :D 2015-07-16 22:37:32 -04:00
openneo_auth.rb improve app infrastructure to make a dev environment easier to reproduce 2015-07-16 17:44:52 -04:00
pledgie.rb rewrite donors copy a bit 2011-07-02 13:23:38 -04:00
resque.rb resque will reconnect to database after each job to avoid Gone Away errors 2013-03-05 15:14:29 -06:00
resque_retry.rb use resque-retry to reschedule failed jobs 2011-06-21 11:22:45 -04:00
rspec_generator.rb rspec:install 2010-05-14 18:17:10 -04:00
secret_token.rb move some deploy stuff from files into env 2015-07-17 17:47:58 -04:00
session_store.rb rails 3.1 upgrade - still buggy 2013-03-05 15:10:25 -06:00
stripe.rb improve app infrastructure to make a dev environment easier to reproduce 2015-07-16 17:44:52 -04:00
wrap_parameters.rb rails 3.1 upgrade - still buggy 2013-03-05 15:10:25 -06:00