Page MenuHomePhabricator

Retrieve metric "% of API calls that are cached"
Closed, ResolvedPublic

Description

Definition:

  • We want to find out and be able to monitor the percentage of the API calls that are retrieved directly from the disk cache i.e. the hit ratio. This will then reveal the percentage of them that are retrieved from the HDD.

Purpose:

  • Set a baseline of the current state
  • Detect irregularities in the cache and in the use we do of it e.g. are we using the cache cleverly? should we change our caching strategy? has a newly released fetaure had an impact in this metric?
  • In the case that the change of trend can easily lead back to a new release the looking for the root cause will be made easier e.g. the scope will be reduced
  • Plus it will give our Product team some more data of the usage of the API that may be relevant for their short, mid and long term strategy and planning.

Notes:

  • this metric may already be in hadoop

AC:

  • retrieve metric
  • the metric is to be seen on the dashboard

Event Timeline

The cache hit ratio for API requests can be queried together with those for the entity pages (T274414) and the WDQS requests (T274415) by defining three separate "categories" like this:

SELECT
 COUNT(*) as count,
 CASE WHEN is_pageview = 1 THEN 'entity_page'
 ELSE
  CASE WHEN uri_path LIKE '/w/api.php%' THEN 'api'
  ELSE CASE WHEN uri_host = 'query.wikidata.org' AND uri_path LIKE '%/sparql' THEN 'wdqs'
       ELSE 'other'
       END
  END
 END AS request_category,
 CASE WHEN cache_status IN ('pass','miss') THEN 0 ELSE 1 END AS is_cached
FROM
  wmf.webrequest
WHERE
  uri_host IN ('www.wikidata.org', 'query.wikidata.org')
  AND (is_pageview = TRUE OR uri_path LIKE '/w/api.php%' OR uri_path LIKE '%/sparql')
  AND year = 2021
  AND month = 5
  AND day = 6
  AND hour = 8
GROUP BY
 (CASE WHEN is_pageview = 1 THEN 'entity_page'
 ELSE
  CASE WHEN uri_path LIKE '/w/api.php%' THEN 'api'
  ELSE CASE WHEN uri_host = 'query.wikidata.org' AND uri_path LIKE '%/sparql' THEN 'wdqs'
       ELSE 'other'
       END
  END
 END),
  (CASE WHEN cache_status IN ('pass','miss') THEN 0 ELSE 1 END)
ORDER BY request_category, is_cached
LIMIT 25;

Change 686066 had a related patch set uploaded (by Ladsgroup; author: Ladsgroup):

[analytics/refinery/source@master] Add scala job for reliability metrics of Wikidata

https://gerrit.wikimedia.org/r/686066

Change 686383 had a related patch set uploaded (by Ladsgroup; author: Ladsgroup):

[analytics/refinery@master] oozie: Add oozie job for gather wikidata reliability metrics

https://gerrit.wikimedia.org/r/686383

Change 686066 merged by jenkins-bot:

[analytics/refinery/source@master] Add scala job for reliability metrics of Wikidata

https://gerrit.wikimedia.org/r/686066

Change 686383 merged by Mforns:

[analytics/refinery@master] oozie: Add oozie job for gather wikidata reliability metrics

https://gerrit.wikimedia.org/r/686383