One Postgres Setting That Helped Me Think About 4x Traffic
Oct 25, 2026
so you must have seen that Continue Watching button on almost every course platform , you close the video halfway , come back the next day , and it takes you straight to the exact second where you left.
to build that , we need to remember how much of the video each student has watched , and that progress has to live somewhere , which means the database.
The Simple Solution
the first thing that comes to mind is pretty simple.
add a progress column in the table
from the frontend , send a request every 10 seconds
update the student's progress on every request
and honestly this works , nothing wrong with it , for a small platform you will never even notice it.
Let's Do the Math
now imagine the platform grows and let say 20,000 students are watching videos at the same time.
that sounds like a scary number for the database , but when you actually do the math , 20,000 users sending one request every 10 seconds is around 2,000 writes per second , and for a database like Postgres that is not a big deal at all.
the real problem starts when traffic becomes 2x , 3x , 4x of that , because now the database starts slowing down and every query starts feeling it.
so to fix it properly , we first need to understand what Postgres is actually doing when we write something.
What Happens When Postgres Writes
when a write comes in , Postgres doesn't directly go and update the table files on disk , it first records the change in the WAL , the Write Ahead Log.
the change first goes into the WAL buffer in memory , which is very fast , but before Postgres tells us "ok your commit is done" , it waits for that WAL record to be flushed to the disk , because that is the guarantee that even if the server dies right after , our data can be recovered.
that waiting for the disk is the slow part.
memory is fast , disk is slow , and when you have thousands of commits per second , every single commit sitting and waiting for the disk flush adds up , and that is where your queries start slowing down.
this behaviour is called synchronous commit , and in Postgres it is on by default.
Turning Synchronous Commit Off
the good thing is , we can turn it off.
SET synchronous_commit = off;now Postgres writes the change into the WAL buffer and returns to us immediately , without waiting for the disk flush , and the flushing happens a moment later in the background.
so that time we were spending on every commit waiting for the disk is gone , and the same database can now handle that 2x , 3x , 4x traffic much more easily.
and you don't even have to turn it off for the whole database , you can turn it off only for the writes that can afford it , like our progress updates.
BEGIN;
SET LOCAL synchronous_commit = off;
UPDATE video_progress SET seconds_watched = 742 WHERE student_id = 1 AND video_id = 42;
COMMIT;so the payment and enrollment writes still stay fully safe , and only the progress writes take the fast path.
The Risk
but this is not free , there is a risk , and the risk is data loss.
the commit returned to us while the data was still sitting in memory , so if the database server crashes in that small window before the background flush , those last few commits never reached the disk , and they are just gone.
the database itself doesn't get corrupted , it comes back in a consistent state , you only lose the most recent commits.
When Is That Risk Acceptable
so the real question is not "is this setting good or bad" , the question is , can your use case afford to lose a little bit of recent data.
in our case , if a server crashes and a student loses 10 or 20 seconds of watch progress , nobody is getting hurt , they just scroll a few seconds forward , so for this feature turning off synchronous commit makes total sense.
but for things like payments , orders , or anything where losing even one write is a real problem , you keep it on , and look at other ways to handle the load.
the lesson for me was simple , most of the time we try to scale by adding more stuff , but sometimes it is just about knowing which guarantee your data actually needs.
not every write needs the same promise.