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

Enforce static file look up for ProductionS3Storage backend #907

Merged
merged 3 commits into from
May 12, 2021

Conversation

OmarIthawi
Copy link

@OmarIthawi OmarIthawi commented May 8, 2021

RED-1961.

  • Honeycomb tracing to debug staticfiles slow lookup.
  • Disable CACHES['staticfiles']['KEY_PREFIX'] = EDX_PLATFORM_REVISION by upstream which assumes we're deploying via git tags. We don't, we deploy from main and the upstream override keeps the cache stale and invalid.
  • Cache ProductionS3Storage.url look up results manually.

Tests

@@ -32,7 +33,8 @@

<%def name='url(file, raw=False)'><%
try:
url = staticfiles_storage.url(file)
with beeline.tracer(name='static_content.html.url'):
Copy link
Author

Choose a reason for hiding this comment

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

Debugging static files lookup.

@@ -149,6 +150,7 @@ def marketing_link_context_processor(request):
)


@beeline.traced(name='common.djangoapps.edxmako.shortcuts.render_to_string')
def render_to_string(template_name, dictionary, namespace='main', request=None):
Copy link
Author

Choose a reason for hiding this comment

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

Debugs rendering templates, which includes all/most calls to static files lookups.

@coveralls
Copy link

coveralls commented May 8, 2021

Coverage Status

Coverage decreased (-0.02%) to 40.185% when pulling 9e1e8d0 on omar/honeycomb-staticfiles into 9d51a64 on main.

@OmarIthawi OmarIthawi changed the title Honeycomb tracing for staticfiles Enforce static file look up for ProductionS3Storage backend May 11, 2021
this mostly to debug slowness in static files look up as reported in
RED-1961.
settings.CACHES['staticfiles'] wasn't getting hit when
ProductionS3Storage is used in HTTP request context.

This change enforces cache by overriding the ProductionS3Storage.url
method.
Copy link

@thraxil thraxil left a comment

Choose a reason for hiding this comment

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

I'm in favor of getting this out quickly to unblock Juniper.

Longer term, we probably want to consider some things:

  • instead of adding our stuff directly to openedx.core.storage.ProductionS3Storage, we probably ought to make our own storage class that just subclasses it to override url() and add the explicit caching, then use AppsemblerProductionS3Storage in our config.
  • having honeycomb tracing on every call to url() is useful at the moment for debugging/verifying this fix, but is probably more verbose than we're going to want to dial it down later.
  • instead of commenting out the setting of the key prefix here and putting a random value in the config in Increase edxapp staticfiles cache timeout to 30 days to improve performance configuration#361 maybe we could instead set EDX_PLATFORM_REVISION to a git hash or cloud build revision id during the deploy (with something like an ansible --extra-vars=EDX_PLATFORM_REVISION=$REVISION_ID in the deploy script. That would achieve the same effect of making sure that the cache is cleared on each deploy.

@OmarIthawi OmarIthawi merged commit f1c43e6 into main May 12, 2021
@OmarIthawi OmarIthawi deleted the omar/honeycomb-staticfiles branch May 12, 2021 09:17
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.

4 participants