---
title: "Discussion on \"Building a Flash Sale Engine That Cannot Oversell: Distributed Locking and Optimistic Concurrency in NestJS\" | Hashnode"
description: "Discussion on \"Building a Flash Sale Engine That Cannot Oversell: Distributed Locking and Optimistic Concurrency in NestJS\". How I used Redis distributed locking, atomic stock decrements, and TypeORM optimistic locking to guarantee zero overselling under thousands of simultaneous purchase requests, and the race condition I had to fix to get there."
url: "https://hashnode.com/posts/building-a-flash-sale-engine-that-cannot-oversell-distributed-locking-and-optimistic-concurrency-in-nestjs/6a39300484365b2a901c1cdd"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Building a Flash Sale Engine That Cannot Oversell: Distributed Locking and Optimistic Concurrency in NestJS](https://peacemelodi.hashnode.dev/building-a-flash-sale-engine-that-cannot-oversell-distributed-locking-and-optimistic-concurrency-in-nestjs?utm_source=hashnode&utm_medium=feed)

How I used Redis distributed locking, atomic stock decrements, and TypeORM optimistic locking to guarantee zero overselling under thousands of simultaneous purchase requests, and the race condition I had to fix to get there.

Jun 22 · 5 min read · peacemelodi.hashnode.dev  
Read the article

-   [#nestjs](https://hashnode.com/tag/nestjs)
-   [#typescript](https://hashnode.com/tag/typescript)
-   [#redis](https://hashnode.com/tag/redis)
-   [#postgresql](https://hashnode.com/tag/postgresql)
-   [#backend-development](https://hashnode.com/tag/backend-development)
-   [#system-design](https://hashnode.com/tag/system-design)
-   [#distributed-systems](https://hashnode.com/tag/distributed-systems)
-   [#concurrency](https://hashnode.com/tag/concurrency)
-   [#docker](https://hashnode.com/tag/docker)
-   [#nodejs](https://hashnode.com/tag/nodejs)

## Written by

[Peace Melodi](https://hashnode.com/@peacemelodi)

@peacemelodi · Lagos, Nigeria

  
[View profile](https://hashnode.com/@peacemelodi)

Backend Software Engineer. NestJS · Node.js · TypeScript · PostgreSQL

Backend Software Engineer with a deep focus on server side architecture, security and scalable system engineering. I build with NestJS, Node.js, TypeScript and PostgreSQL and I write about the engineering decisions that separate systems that work from systems that last.

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
