Skip to Content
PredictorSDK

Matching answers at once when new data has just arrived

A matching list request no longer waits while the newest snapshot is read in. It answers from the snapshot it already has, and the next request has the new one.

Fix

Matching publishes a new snapshot about every 12 seconds. The first request after each one used to wait while the API read it in. On the production machine that wait was about 0.6 seconds, when a request answered from memory takes about 30 milliseconds. A caller who asked less often than every 12 seconds or so met that wait on most requests.

Now GET /v1/matching-markets/sports answers at once from the snapshot the API already has, and reads the new one in the background. In our measurements the first request after a new snapshot dropped from about 90 milliseconds to about 3, and ten requests arriving together right after one dropped from about 120 to about 30 (on a laptop with the same data), which should bring the first request after a snapshot in line with any other.

One thing is slightly different. For the fraction of a second the new snapshot takes to read in, a response is built from the snapshot before it, so a game that matching only just added can be missing from that one response. The next request has it. snapshot.observed_at still dates exactly the data the response was built from, and a game first read after that time can be absent from a response, as it always could.

A request that arrives after a longer pause, about half a minute or more with no request, can still wait for the read as before, because by then every snapshot the API held has been replaced. A lookup by event id or source_id is not affected: it finds a game in the newest snapshot straight away. Only a lookup for settled events (include_settled=true) follows the same rule as the list.

No field, parameter or status code changed, so nothing in the SDKs needs updating.