CDN routing logic should be:
- If HTTP POST => master DC.
- Reason: This will perform writes to the primary database which should be done locally.
- If cookie "UseDC=master" is present => master DC.
- Reason: The user has recently made writes (database, session). To ensure the user sees their own actions reflected, and to minimise chances of needing to do synchronous waits, the user is "stickied" to the primary DC for a few seconds until we're confident cross-dc DB and session replication has completed.
- This also ensures we don't need a multi-dc aware ChronologyProtector, per T254634.
- If URL param "cpPosIndex=" is present => master DC.
- Reason: The user has recently made writes (database, session) and is now being redirected to a cross-wiki domain. To ensure the user sees their own actions reflected, and to minimise chances of needing to do synchronous waits, the user is "stickied" to the primary DC for a few seconds until we're confident cross-dc DB and session replication has completed.
- This also ensures we don't need a multi-dc aware ChronologyProtector, per T254634.
- Requests that perform database writes over GET (like HTTP POST)
- GET index.php action=rollback => master DC (per T88044).
- Reason: This is a user action that for legacy reason cannot yet use form submissions.
- GET login.wikimedia.org Special:CentralAutoLogin => master DC.
- Reason: This auto-creates local accounts and cross-domain login sessions through a chain of redirects and hence can't use POST. In addition to sometimes performing db writes, it also needs access to the latest user sessions and ChronologyProtector, per T254634#6211514. Note that the Special:CentralAutoLogin url is never localised to make this easy.
- GET index.php action=rollback => master DC (per T88044).
- Cache/stash write optimisations => master DC
- GET/POST api.php action=centralauthtoken or centralauthtoken=, or an Authorization header which starts with CentralAuthToken (T267270)
- Reason: Foreign API tokens need to be set and then immediately consumed. Latency will probably be reduced by routing these requests at the CDN layer rather using mcrouter to do cross-DC memcached requests.
- GET/POST api.php action=centralauthtoken or centralauthtoken=, or an Authorization header which starts with CentralAuthToken (T267270)
- Anything else, e.g. HTTP GET/HEAD/OPTION => local DC.
- HTTP POST with Promise-Non-Write-API-Action: true header => local DC (exception to rule 1).
- Reason: These are AJAX POST requests that only fetch data. They use POST due to the limited payload size that GET requests allow.
See also: