Optimization Detective should be further hardened to account for high traffic sites

Open
#1,655 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
php
Domain
api, backend, database

Research direction

Start with the discussion in issue 1496 and the changes in pull request 1641, then trace the Optimization Detective REST API path that stores URL Metrics and the related WP Cron cache-clearing behavior. Done requires an agreed and implemented approach for preventing or managing concurrent URL Metrics database writes at high traffic volumes.

Written by the indexing model from the issue text.

Description

[Plugin] Optimization Detective [Type] Enhancement

Originally discussed in https://github.com/WordPress/performance/issues/1496#issuecomment-2471868739:

  • Do we add an endpoint for getting the which URL Metrics are needed. The problem is that the endpoint cache wouldn't be reliably flushed. But if it were reliably flushed:
  • Check what happens when there is a race condition between two requests to store a URL Metric from two application servers connected to the same database when there wasn't a od_url_metrics post that already existed.
  • Do we need a lock or throttling mechanism?
  • When a persistent object cache is available, perhaps the POST request would only write to the object cache and then WP Cron would read from the object cache to actually create the URL Metrics posts.

Already addressed as part of https://github.com/WordPress/performance/pull/1641:

To deal with the page cache stampede problem, we can schedule the clearing of the cache for a URL periodically via WP Cron.

So the page cache stampede problem is addressed, but what is not addressed is what to do with a stampede of database writes for potentially thousands (or millions) of visitors attempting to submit URL Metrics for storage via the REST API.

Dominant language
PHP
Stars
461
Forks
165
Avg merge
11h 12m
Merged PRs (30d)
28

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from WordPress/performance

All issues in WordPress/performance

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.