SShortSingh.
Back to feed

How a Unique DB Constraint Prevents Double-Selling Seats at Scale

0
·4 views

A software engineer who built booking systems for events hosting up to 20,000 spectators has shared the architecture behind reliable seat reservation at high concurrency. The core problem is the 'lost update' — two users passing an availability check simultaneously, both being assigned the same seat. The solution separates clicking from selling: a click creates a short-lived hold stored in Redis via an atomic Lua script, while only a completed checkout writes to the database. Redis handles the high-churn, expiring holds without polluting the primary database, but the true guarantee is a PostgreSQL UNIQUE constraint on the event and seat combination. A reference implementation with a 200-concurrent-request stress test has been published on GitHub to demonstrate the approach.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

Developer Launches Free Browser-Based Image Resizer With No Server Uploads

A developer has launched resize-photo.com, a free tool that resizes images entirely within the user's browser without uploading files to any server. The project was built over a few days and is designed to address common needs around resizing images before uploading them to platforms with file size or resolution limits. Because all processing happens locally, users retain full privacy over their image data. The creator cited a personal interest in cybersecurity as a key motivation for avoiding third-party server reliance. Basic SEO optimization has also been applied to improve the site's search engine visibility over time.

0
ProgrammingDEV Community ·

Developer Shifts 50% of AI Workload to Local LLMs by Splitting Tasks by Role

Uehara, a solo developer at EarthLink Network Co., Ltd., reported on July 30, 2026 that local LLMs handled 50.3% of execution volume across his AI development pipeline, with cloud models accounting for 48.2%. Rather than selecting the most powerful model for all tasks, he divided work by role — routing lightweight classification jobs to smaller local models and heavier tasks to the cloud. Testing revealed that a 14B model matched a 72B model in classification accuracy and code generation pass rates, while the larger model ran five to six times slower. A memory miscalculation when co-hosting both models caused a four-and-a-half-minute stall, which was resolved by shortening the classifier's context window. Critically, high-risk operations involving databases, authentication, billing, and production systems are always routed back to human approval regardless of model output.

0
ProgrammingDEV Community ·

Static FHIR Sandboxes Hide Critical Flaws in Healthcare Integration Testing

Healthcare software developers rely on FHIR sandboxes like Open Epic to test integrations, but these environments contain frozen, static patient data that never changes over time. Because timestamps and records remain perpetually unchanged, delta-sync queries — which check for updates since a last poll — always return empty results, giving developers a false sense that their code works correctly. This means the first real test of incremental data handling often happens in a live production environment against actual patient health information. The problem extends beyond Epic's sandbox; other platforms like Redox also restrict development environments in ways that prevent realistic end-to-end workflow testing. The core issue is not poor data quality but the complete absence of simulated time and change, which masks potentially expensive integration failures before deployment.

0
ProgrammingDEV Community ·

Developer Builds Claude Code Plugin That Tests Understanding Before Allowing Code Commits

A developer has created an open-source plugin for Claude Code that requires users to pass a quiz about their code before the AI assists with implementation. The tool, called 'quiz-me-skill', is designed to combat the growing trend of developers blindly accepting AI-generated code without fully understanding it. The plugin is MIT-licensed and can be installed in two commands via the Claude Code plugin marketplace. It was built by GitHub user schwann2402 and is publicly available on GitHub.