Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Prod is not using a CDN #3590

Closed
ianb opened this issue Oct 3, 2017 · 11 comments
Closed

Prod is not using a CDN #3590

ianb opened this issue Oct 3, 2017 · 11 comments
Assignees
Labels
perf Performance-related

Comments

@ianb
Copy link
Contributor

ianb commented Oct 3, 2017

I did a new perf test (while looking at #3202) and notice that the static resources are not coming off our CDN.

Looking through the code, it seems to be based pretty directly on $CDN in the environment. If that is empty, then there won't be any prefix, and it will load the resources locally. @relud says that we're setting $SITE_CDN and $CONTENT_CDN, which sounds right – there should be two CDN paths. We'll need to look up the changes to figure out what happened here.

@ghost ghost added this to the Launch 58 milestone Oct 5, 2017
@chenba
Copy link
Collaborator

chenba commented Oct 11, 2017

It looks like the cdn config was using $CDN since the beginning:

@johngruen johngruen modified the milestones: Bucket ☕️, Backlog Oct 31, 2017
@ghost ghost removed this from the Backlog milestone Oct 31, 2017
@ghost ghost added the perf Performance-related label Oct 31, 2017
@ghost
Copy link

ghost commented Oct 31, 2017

@relud says the CDN already exists, we just need to use it.

screenshotscdn.firefox.com
screenshotscdn.firefoxusercontent.com

Is this issue saying to unset SITE_CDN and CONTENT_CDN and just set CDN? or ...?

@relud
Copy link
Member

relud commented Oct 31, 2017

I think it's the other way around, the config needs to convert CDN to add two separate options, SITE_CDN and CONTENT_CDN, but in order to do that we need to identify where CDN is being used, and make sure things are moved to using the site or content cdn as appropriate.

@ianb
Copy link
Contributor Author

ianb commented Oct 31, 2017

To clarify, we need to change our code to use SITE_CDN and CONTENT_CDN

@ghost ghost added this to the Sprint 2 (59-1) 🚌 milestone Nov 1, 2017
@chenba chenba self-assigned this Nov 30, 2017
@chenba
Copy link
Collaborator

chenba commented Nov 30, 2017

Where should CONTENT_CDN be used?

@jaredhirsch
Copy link
Member

We have the separate firefoxusercontent.com domain for stuff users upload, so that'd be the origin server for the CONTENT_CDN. If you look at commit 52e255a, you can see how the existing CDN code fits together. Does this help?

@chenba
Copy link
Collaborator

chenba commented Nov 30, 2017

The images are served from screenshots.firefoxusercontent.com on prod. We would achieve the same effect by setting CDN=https://screenshotscdn.firefox.com and CONTENT_ORIGIN=screenshotscdn.firefoxusercontent.com correct? (I'm not opposed to the change; just trying to understand this better.)

As for the webpagetest.org test results, we won't get that check mark for using a CDN because the moz cdn is not on this list: https://github.com/WPO-Foundation/webpagetest/blob/master/agent/wpthook/cdn.h

@jaredhirsch
Copy link
Member

I think the origin server would be screenshots.firefoxusercontent.com, and the cdn would be screenshotscdn.ffuc.com. Ditto for SITE_CDN.

@relud
Copy link
Member

relud commented Nov 30, 2017

so these are the settings now:

CONTENT_CDN=https://screenshotscdn.firefoxusercontent.com
CONTENT_ORIGIN=https://screenshots.firefoxusercontent.com
SITE_CDN=https://screenshotscdn.firefox.com
SITE_ORIGIN=https://screenshots.firefox.com

but I think @chenba is right, if we just set CONTENT_ORIGIN to CONTENT_CDN then we would reference all content via the content cdn, which is what we want, as long as we aren't storing the value of CONTENT_ORIGIN in the database location for shots.

@chenba
Copy link
Collaborator

chenba commented Nov 30, 2017

Sorry to be the bearer of bad news, @relud, but the image URLs are written into the db. That has at least two effects.

Since the shots expire by default, the number of images not using the content CDN will drop over time.

The CSP header is dynamically built, so once we do a post-patch server release with CONTENT_CDN, we cannot roll back. If we roll back or change the CONTENT_CDN, the images saved with the original CONTENT_CDN will be blocked by CSP.

@relud
Copy link
Member

relud commented Nov 30, 2017

I know we do, but we should stop. I have nginx rewriting legacy content origins to the current one, to avoid bugs like you describe

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
perf Performance-related
Projects
None yet
Development

No branches or pull requests

5 participants