Page MenuHomewrite.as

Update post view counts in batches
Open, LowPublic

Description

Overview

Every time a post is loaded, we update that post's view_count in the database.

Background

This happens in a goroutine, ensuring post rendering is still fast. But it can cause additional load on the database and block future requests on engines where it matters (like SQLite).

Implementation

Instead of doing view_count = view_count + 1 every time we serve a post, we should temporarily keep track of additional views in memory, and then write that data to the database after a short interval (e.g. 5 seconds).

Event Timeline

matt created this task.Dec 3 2018, 4:16 PM
matt created this object with visibility "Public (No Login Required)".
matt created this object with edit policy "All Users".
matt triaged this task as Low priority.