Page MenuHomePhabricator

Change the webp threshold based on access distribution
Closed, ResolvedPublic

Description

Currently based on upload_webp_hits_threshold hiera rule, we apply webp thumbnail instead if the file is popular. The popularity threshold is set to 100 requests per day. I would like to see if we can pick a threshold based on access of thumbnails. I've looked at all requests to cp3077 for a full day (the ttl of images which basically translates to the hits).

In total 13.8M distinct thumbnails were requested in 101M distinct requests but it is very long-tailed: the access distribution looks like this:

access_distribution.png (1,920×961 px, 38 KB)

i.e. picking 100 as threshold only impacts 0.43% of files (roughly 60K files) while still covering around 50% of requests. In fact, it is so long-tailed that looking at any data above 10% of files is waste of time. So I made it per mille maxed at 100‰ = 10%:

access_distro_per_mille.png (1,920×961 px, 46 KB)

Based on derivatives (looking for the "knee"), it looks like it'd be better to target 1% of files translating to 56% of requests. That means putting the threshold at 50 would achieve that.

Distinct URLsRequestsThreshold (requests per day per server)
0.1%42.6%361
0.2%46.0%189
0.3%48.2%133
0.4%49.8%105
0.5%51.1%89
0.6%52.2%78
0.7%53.2%69
0.8%54.1%62
0.9%54.9%57
1.0%55.7%52
1.1%56.4%49
1.2%57.0%45
1.3%57.6%43
1.4%58.2%40
1.5%58.7%38
1.6%59.2%36
1.7%59.7%35
1.8%60.2%33
1.9%60.6%32
2.0%61.0%31

Event Timeline

(Technically not code review but I want to make sure people are okay with the idea before making patches)

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

[operations/puppet@production] cache: Reduce webp threshold to 90

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

Change #1310105 merged by Ladsgroup:

[operations/puppet@production] cache: Reduce webp threshold to 90

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

Ladsgroup changed the task status from Open to Stalled.Aug 5 2026, 12:02 PM

I think we should wait until the patches for T427465: Move thumbnail caching from upload cluster to text are merged and deployed.

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

[operations/puppet@production] upload: Drop profile::cache::upload::upload_webp_hits_threshold

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

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

[operations/puppet@production] cache: Reduce the webp threshold to 80

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

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

[operations/puppet@production] varnish: Push webp on Safari except 14 and 15

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

Change #1327656 merged by Ladsgroup:

[operations/puppet@production] upload: Drop profile::cache::upload::upload_webp_hits_threshold

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

Change #1327657 merged by Ladsgroup:

[operations/puppet@production] cache: Reduce the webp threshold to 80

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

Change #1332678 merged by BCornwall:

[operations/puppet@production] varnish: Push webp on Safari except 14 and 15

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

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

[operations/puppet@production] cache: Reduce the webp threshold to 70

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

Change #1334001 merged by Ladsgroup:

[operations/puppet@production] cache: Reduce the webp threshold to 70

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

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

[operations/puppet@production] Reduce the webp threshold to 70

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

Change #1338760 merged by Ladsgroup:

[operations/puppet@production] Reduce the webp threshold to 60

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

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

[operations/puppet@production] cache: Reduce the webp threshold to 50

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

Change #1339641 merged by Ladsgroup:

[operations/puppet@production] cache: Reduce the webp threshold to 50

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

grafik.png (1,476×956 px, 112 KB)

vs. same time a month ago:

grafik.png (1,495×934 px, 119 KB)

And it will get much better after everything is fully migrated to thumb.wikimedia.org