Coffee module results in an extra uncacheable AJAX request on every page

Created on 11 December 2024, 5 months ago

Problem/Motivation

Found via πŸ“Œ Add performance testing Active and some profiling.

Coffee module gets the menu structure from an AJAX callback, this AJAX callback is uncacheable, so it builds the menu tree every time. There doesn't appear to be much/any object caching happening either, so the callback takes 100ms in PHP apart from any network overhead.

Steps to reproduce

Install Drupal CMS, log in, visit a page, look at xhr requests in the network tab.

Proposed resolution

Remove coffee from the the drupal_cms_admin_ui recipe until πŸ“Œ Local Storage for Coffee Needs review is committed and in a stable release of Coffee.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ“Œ Task
Status

Active

Component

Base Recipe

Created by

πŸ‡¬πŸ‡§United Kingdom catch

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @catch
  • πŸ‡¬πŸ‡§United Kingdom catch

    For the record, the coffee AJAX request takes 100ms and 96k function calls and 107 database queries when looking in xhprof, this is compared to 96ms and 74k function calls and 73 database queries for the page itself.

  • πŸ‡¬πŸ‡§United Kingdom catch
  • πŸ‡ΊπŸ‡ΈUnited States phenaproxima Massachusetts
  • πŸ‡¦πŸ‡ΊAustralia pameeela

    No tag forthcoming, so we probably need to make a call on whether to pull this out.

  • πŸ‡ΊπŸ‡ΈUnited States phenaproxima Massachusetts

    IMHO we should not. This only affects logged-in users with access to Coffee (in most sites that's probably only a few users), and @ckrina felt that the value outweighs the performance drag.

    It's a product decision, so your word is law, but I would keep it. I don't think 100 extra milliseconds and a hundred extra database queries are going to matter to our target audience.

  • πŸ‡¬πŸ‡§United Kingdom catch

    I don't think 100 extra milliseconds and a hundred extra database queries are going to matter to our target audience.

    Just because the target users for Drupal CMS are not trying to scale sites to millions of site visits per month or millions of nodes, doesn't mean they don't need their sites to be snappy and cheap to host.

    Drupal CMS users are likely to want to host on relatively cheap hosting, which in some cases bill by traffic rather than resources, they're also likely to do a lot more admin on their production environment, given they may not have a local environment at all.

    I'm not massively familiar with all the hosting options out there but one I do know which charges by traffic is Pantheon.

    Pantheon hosting tiers are based on 'pages served' which includes any response originating from the CMS.
    https://docs.pantheon.io/guides/account-mgmt/traffic#pages-served

    The 'xtra-small' plan allows 125k pages per month.

    Someone building/adding content on production could easily be hitting ~200 pages per day (four hours/day, 50 pages/hour) while their site is in active development or they're adding content.

    If coffee is installed in its current state, this will double to 400 'pages served' according to Pantheon's usage policies due the extra AJAX request on every page they visit.

    400*30 = 12,000 or 10% of their monthly usage limit. You only need to go over by a couple of thousand to get bumped up to the next tier.

    It could also be an issue for demo hosting providers, where effectively 100% of the traffic is going to be admin users (because they're trying out the demo, unless they log out/use incognito to see what pages are like for anon).

  • πŸ‡¦πŸ‡ΉAustria nebel54 Vienna

    As a quick update from the coffee side: I just released a new version 2.0.1 that includes https://www.drupal.org/project/coffee/issues/3494208 πŸ“Œ Get coffee data only when the search box is opened Active which should solve the issue for now, as the AJAX request is only fired when needed.

  • πŸ‡¦πŸ‡ΊAustralia pameeela

    @nebel54 amazing, thank you so much!!

  • πŸ‡¦πŸ‡ΊAustralia pameeela

    So I think we can close this one.

Production build 0.71.5 2024