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

reduce cloudfront cost (move collection processing to server-side) #871

Merged

Conversation

adriangohjw
Copy link
Contributor

@adriangohjw adriangohjw commented Nov 11, 2024

Problem

Cloudfront cost should not be as high based on our current traffic

A sizeable portion comes from serving huge collection layout

Solution

Breaking Changes

  • Yes - this PR contains breaking changes
    • Details ...
  • No - this PR is backwards compatible

Improvements:

move as much client-side rendering to server-side to be processed during build time. This reduces the need to

using moh-corp archived repo of just 200+ collection items, this reduces the HTML file from 1.28MB to 520kb (40% reduction). With larger site like actual moh-corp PROD, it should be much more significant.

And with current CF actual usage, quick napkin math says it can reduce by at least 20% (will be much more)

note - shifted stories from CollectionCard to Collection

@adriangohjw adriangohjw added the enhancement New feature or request label Nov 11, 2024
@adriangohjw adriangohjw self-assigned this Nov 11, 2024
@adriangohjw adriangohjw requested a review from a team as a code owner November 11, 2024 17:37
Copy link

vercel bot commented Nov 11, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
isomer-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 14, 2024 2:33am

@datadog-opengovsg
Copy link

datadog-opengovsg bot commented Nov 11, 2024

Datadog Report

Branch report: adriangohjw/reduce-cloudfront-cost-for-collection-layout
Commit report: e2c18fc
Test service: isomer-studio

✅ 0 Failed, 184 Passed, 34 Skipped, 38.8s Total Time
➡️ Test Sessions change in coverage: 1 no change

@adriangohjw
Copy link
Contributor Author

adriangohjw commented Nov 12, 2024

Using moh-corp PROD data for benchmarking

Before After Note
Uncompressed (S3) 10.7MB 3.9MB -64% reduction
Compressed (CF) 11.2MB 488kB -96% reduction
No idea why compressed is larger prior
Time taken to load 378ms 48ms -87% reduction

based on my calculation, should reduce our overall Cloudfront cost by 50% (a few hundred bucks a month)

Copy link
Contributor

@seaerchin seaerchin left a comment

Choose a reason for hiding this comment

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

i don't have an issue with this PR and i am ok to approve it, however i don't quite understand why this helps!

i thought we would precompute on the server side and this is done through removing site and getting the final output for imageSrc and imageTitle?

@adriangohjw
Copy link
Contributor Author

i thought we would precompute on the server side and this is done through removing site and getting the final output for imageSrc and imageTitle?

@seaerchin yup but previously I only prioritize that change for components that are more universal e.g. navbar. The change wasn't made for Collection since it was only a few page

…ngohjw/reduce-cloudfront-cost-for-collection-layout
@adriangohjw adriangohjw merged commit b5a6a4d into main Nov 15, 2024
20 checks passed
@adriangohjw adriangohjw deleted the adriangohjw/reduce-cloudfront-cost-for-collection-layout branch November 15, 2024 07:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants