Page MenuHomePhabricator

Search dashboard, suspicious fulltext api usage
Closed, ResolvedPublic3 Estimated Story Points

Description

Since we deployed the new report updater the fulltext API usage has increased from 8M to 150M I don't think this is true, this means that we perform more fulltext requests than prefix+opensearch.

Event Timeline

debt subscribed.

This is a screen shot of what we'll take a look at - in Feb 2017:

Screen Shot 2017-03-21 at 5.20.30 PM.png (1,116×556 px, 63 KB)

debt triaged this task as Medium priority.Mar 21 2017, 11:21 PM
mpopov set the point value for this task to 3.
mpopov moved this task from Backlog to In progress on the Discovery-Analysis (Current work) board.
mpopov subscribed.

Taking a look…

Everything is counted correctly by this script which uses the patched search request definition. Unfortunately we were used the pre-patch version until 2017-01-01 that undercounted API calls because it was not counting the 100M+ generator calls. I'm sorry that I didn't switch to using the latest refinery JARs sooner.

As for the sudden jump between Feb 3rd and Feb 5th, there's not much we can do to explain "why" suddenly we're getting 50-90 million more generator-based full-text search API calls on a daily basis than we did before.

Screen Shot 2017-03-22 at 7.54.03 PM.png (1,826×488 px, 92 KB)

Hive query for data:

ADD JAR hdfs:///wmf/refinery/current/artifacts/refinery-hive.jar;
CREATE TEMPORARY FUNCTION search_classify AS 'org.wikimedia.analytics.refinery.hive.SearchClassifierUDF';

SELECT
    TO_DATE(ts) AS `date`,
    search_classify(uri_path, uri_query) AS api,
    IF(PARSE_URL(CONCAT('http://', uri_host, uri_path, uri_query), 'QUERY', 'generator') IS NOT NULL, 'TRUE', 'FALSE') AS `uses generator`,
    IF(PARSE_URL(CONCAT('http://', uri_host, uri_path, uri_query), 'QUERY', 'list') IS NOT NULL, 'TRUE', 'FALSE') AS `uses list`,
    COUNT(1) AS requests
FROM wmf.webrequest
WHERE
    webrequest_source = 'text'
    AND (
        year = 2016
        OR (year = 2017 AND month = 1 AND day = 1)
        OR (year = 2017 AND month = 1 AND day = 22)
        OR (year = 2017 AND month = 2 AND day = 3)
        OR (year = 2017 AND month = 2 AND day = 5)
        OR (year = 2017 AND month = 2 AND day = 19)
    )
    AND NOT is_pageview
    AND http_status = '200'
    AND ts IS NOT NULL
    AND search_classify(uri_path, uri_query) IN('language', 'cirrus', 'prefix', 'geo', 'open')
GROUP BY
    TO_DATE(ts),
    search_classify(uri_path, uri_query),
    IF(PARSE_URL(CONCAT('http://', uri_host, uri_path, uri_query), 'QUERY', 'generator') IS NOT NULL, 'TRUE', 'FALSE'),
    IF(PARSE_URL(CONCAT('http://', uri_host, uri_path, uri_query), 'QUERY', 'list') IS NOT NULL, 'TRUE', 'FALSE');

R code for plot:

library(tidyverse)
api_usage <- read_csv("~/Downloads/query-hive-408.csv")
api_usage %>%
  dplyr::filter(api != "language") %>%
  mutate(date = format(date, "%m/%d"),
         call = case_when(
           .$`uses generator` & !.$`uses list` ~ "that just use generator",
           .$`uses generator` & .$`uses list` ~ "that use both",
           !.$`uses generator` & .$`uses list` ~ "that just use list",
           !.$`uses generator` & !.$`uses list` ~ "that use neither"
         )) %>%
  group_by(date, api, call) %>%
  summarize(requests = sum(requests)) %>%
  ggplot(aes(x = factor(date), y = requests, color = call)) +
  geom_linerange(aes(ymin = 0, ymax = requests),
                 position = position_dodge(width = 1)) +
  geom_text(aes(label = polloi::compress(requests, 1), vjust = "bottom"),
            position = position_dodge(width = 1)) +
  facet_wrap(~ api, nrow = 1, scales = "free_y") +
  scale_color_brewer(palette = "Set1") +
  labs(x = "Date", y = "Requests", color = "API calls",
       title = "Search API usage on certain days in January and February",
       subtitle = "Using the patched UDF (https://gerrit.wikimedia.org/r/#/c/315503/)") +
  theme_minimal(base_family = "Open Sans", base_size = 12) +
  theme(legend.position = "bottom",
        axis.text.y = element_blank(),
        axis.ticks.y = element_blank(),
        axis.line.y = element_blank(),
        panel.grid.major.y = element_blank(),
        panel.grid.minor.y = element_blank(),
        strip.background = element_rect(fill = "gray10"),
        strip.text = element_text(color = "white", size = 12))

@mpopov thanks for the investigation!
I remember this patch and I'm really surprised that it had such impact...
I'll continue to investigate on my side because I cannot reconcile these numbers with the dashboard we use for server monitoring (grafana).
Would you mind keeping this task open for a little while?
Thanks!

debt moved this task from Done to Needs review on the Discovery-Analysis (Current work) board.

Thanks, @mpopov!

I've moved this ticket to 'needs review' on the board and assigned it to @dcausse for now to continue his investigation. @dcausse let us know if there is anything else we can do! :)

debt changed the task status from Open to Stalled.Mar 28 2017, 8:03 PM

Moving to stalled - we're waiting for some free time to come to @dcausse to investigate further. :)

I wonder if the differences we have between this dashboard and our server monitor can be caused by morelike api queries being cached by varnish.
I'll try to run your same queries extracting cache_status to see if it's closer to the numbers I have in grafana.

Certainly related to T154681 (patch deployed Feb 3: https://gerrit.wikimedia.org/r/#/c/335686/)
I think we can say thanks to varnish! :)