mikemccllstr / dominionstats

The code behind councilroom.com.
http://councilroom.com
11 stars 3 forks source link

Precalculate more stats for "player vs other player record" page to improve its performance #26

Open mikemccllstr opened 12 years ago

mikemccllstr commented 12 years ago

From Rob's post in councilroom-dev:

I suspect because a few of the pages are coded very poorly and traverse a whole users set of games to compute stats (popular buys per player, the player page, and the player vs other player record page all do this). When a a similarly poorly coded search engine comes around (these pages are blocked by robots.txt, but some search engines don't honor it), it just keeps putting too many requests on those uber slow pages and councilroom eventually runs out of memory and dies. The decision to do a scan of all the players games came when players had a few hundred game max, but now that there are crazy people with 10k games, and so the design is horribly broken. If someone pre-computed those pages, I am pretty sure a 486 could serve councilroom fine.

Not sure what is required to be precalculated in advance, but it is distinctly slow for users with large game counts.

rrenaud commented 11 years ago

I'd recommend revamping that page. Get rid of the link to every game the player has ever played. That just doesn't scale well. Instead just have the records against each opponent with the opponent's name. Clicking on the opp's name can bring up a game search page where it shows games that had both players.

You might want to have an new collection with a compound key containing the player's name and the opponent's name. It would the record against that opponent (possibly in a beefed up RecordSummary class made to support the ListSlotPrimitiveConversion interface). This means you'd store record twice, once for player X vs player Y, and a second time in the other order for player Y vs player X, so all the records for any given player will be adjacent in the collection, which should mean your scan will by primary player will be fast.