Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove ImageKit #1164

Merged
merged 1 commit into from
Oct 30, 2023
Merged

Remove ImageKit #1164

merged 1 commit into from
Oct 30, 2023

Conversation

phinze
Copy link
Contributor

@phinze phinze commented Oct 24, 2023

What it does

This changes the app to only rely on ActiveStorage and removes the third party dependency on ImageKit.

Why it is important

Modern versions of Rails should be perfectly capable of serving thumbnails directly out of S3 without the help of a 3rd party service.

Resolves #1150

Implementation notes

  • This turns ActiveStorage variant tracking on which removes the need for extra checks in S3 for variants. There's no need for an additional DB migration to turn this on as we already have the tables from the Rails 6.1 upgrade.
  • Since this change is messing with a dependency I'd recommend immediately testing image views, uploads, and editing after we deploy, which should let us revert if anything seems off.

This changes the app to only rely on ActiveStorage and removes the third
party dependency on ImageKit.

Modern versions of Rails should be perfectly capable of serving
thumbnails directly out of S3 without the help of a 3rd party service.
@phinze phinze requested a review from jim October 28, 2023 00:08
Copy link
Member

@jim jim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. I'll merge this later this weekend and make sure that things are working OK in production.

@phinze
Copy link
Contributor Author

phinze commented Oct 28, 2023

Cool will leave it to you then. Feel free to give me a ping when you do and I'm happy to help test 🥼

@jim jim merged commit a2b8178 into main Oct 30, 2023
5 checks passed
@jim jim deleted the remove-imagekit branch October 30, 2023 01:56
@phinze
Copy link
Contributor Author

phinze commented Oct 30, 2023

Via Slack from @jim:

I deployed the imagekit change, and while it seemed to work OK generally (images showed up, they could be uploaded and rotated in the admin without issue), the memory use of the app went up by like 50%. Presumably this is caused by the thumbnails being generated the first time they're viewed.

My research on this led me to a couple of findings:

Given that both a vips switch and a Rails upgrade are nontrivial next steps, and given that ImageKit was not actively harming anything, I'm proposing we revert this change for now to give us a chance to follow through with Rails upgrades and we revisit with an implementation of Named Variants w/ preprocessing once we're at 7.1.

phinze added a commit that referenced this pull request Oct 30, 2023
@phinze phinze mentioned this pull request Oct 30, 2023
jim pushed a commit that referenced this pull request Oct 31, 2023
phinze added a commit that referenced this pull request May 9, 2024
# What it does

Configures ActiveStorage to use vips instead of imagemagick as its
underlying image processor. Vips should use a lot less memory than
imagemagick. See
#1164 (comment)
for more information and background.

# Why it is important

Currently an esoteric user traffic pattern has triggered ImageKit's
throttling so images are broken on the site.

# Implementation notes

* My plan is to merge this, test it on staging, deploy it to production,
and then remove IMAGEKIT_URL to see if the site works okay enough
without any fancy variant preprocessing. The images will be a little
slow on first load but I think this is better than no images! If it's
super slow we can also run a loop in a rails console to manually
preprocess all the existing items.
* I'm not removing the IMAGEKIT_URL conditional yet which means we'll be
able to quickly revert by restoring the environment variable.
* My research suggests we can rely on the version of vips that comes
preinstalled on Heroku rather than installing it ourselves. See
Newlywords/heroku-buildpack-vips#36 for
discussion. (There are some security implications of not being on the
latest version, but we only have trusted users uploading images so I
think we can afford to choose the simpler deployment option of using the
existing package.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove need for image proxy
2 participants