Under Construction

The Blog

Insights, tutorials, and stories from the world of software development.

Join my community?Contact to join
Backend
Nov 2, 2026

Polling and WebSocket what’s the difference?

This article explains the difference between polling and WebSocket using a multiplayer lobby example. With polling, the client checks the server at fixed intervals, so a Ready change may not appear until the next request, and shorter intervals increase request traffic even when nothing changes. Polling works well for data that changes slowly, such as leaderboards, and can be built with normal HTTP APIs. WebSocket keeps an open two-way connection, letting the server push updates to clients immediately, which removes the wait for the next polling cycle. It is a better fit for real-time features like chat, Ready status, and players joining or leaving a room. The article also notes that WebSocket apps must manage reconnects carefully, including refreshing room state after a disconnect and using backoff to avoid repeated retries during server problems.

Minh Khoa
16 min
104
42
Backend
Oct 30, 2026

How are lazy loading and preloading different?

This article explains the difference between lazy loading and preloading using a game Shop screen with many item images. Lazy loading waits until the player opens the Shop before loading its assets, which reduces upfront work but can make the first open slower. Preloading loads the assets earlier, such as during a tutorial summary screen, so the Shop can appear faster if the data is ready in time, though it uses memory, bandwidth, and processing sooner. The article also compares both approaches in a table, shows how they can be combined on one screen, and suggests measuring the time from clicking Shop to being able to interact, along with memory usage before the Shop opens.

Minh Khoa
12 min
74
34
Backend
Oct 26, 2026

Race condition in the game backend when two requests use the same balance

This article explains a backend game race condition where two nearly simultaneous purchase requests can both pass a balance check and grant two items while only one deduction is effectively recorded, causing a lost update. It shows why sequential testing can miss the bug, why await alone does not prevent it, and why the protection must happen at the shared data store. The article recommends using a conditional UPDATE in PostgreSQL Read Committed so the balance check and deduction happen as one atomic database action, then granting the item only if the update succeeds. It also covers handling inventory write failures with transaction rollback, using idempotency keys to safely retry a request after a timeout or lost response, and testing concurrent requests across separate database connections and multiple backend instances.

Minh Khoa
20 min
88
42
Unity
Oct 23, 2026

What’s the difference between Resources and Local Addressables if both are loaded by code?

This article compares Unity Resources and Local Addressables when both are loaded by code, using a ShopPopup prefab as the example. It explains where assets are stored in the build, how async loading works, the startup cost of each system, and how memory is released when the shop closes. It also contrasts Resources.UnloadUnusedAssets and Resources.UnloadAsset with Addressables reference counting and release behavior, then recommends Resources for small, simple content and Local Addressables for larger projects that need tighter bundle and dependency management.

Minh Khoa
19 min
74
16
Backend
Oct 19, 2026

How are throttling and debouncing different?

This article explains the difference between throttling and debouncing in a game UI context. Throttling limits how often a function runs while input is still changing, such as updating a multiplayer color slider every 200 ms so other players still see live feedback. Debouncing waits until the input stops changing before running, such as searching inventory 300 ms after the player stops typing. It compares both methods on the same event timeline, shows when each fires, notes the importance of handling the final slider value with trailing behavior, and recommends Throttle for continuous updates and Debounce for actions that should run only after data stabilizes.

Minh Khoa
10 min
105
20
Security
Oct 16, 2026

Google Authenticator: why does it still produce the correct code without a network?

This article explains why Google Authenticator can still generate valid six-digit codes without an internet connection. It shows how a QR setup code gives the app a shared secret key, how TOTP uses the device clock and HMAC to create time-based one-time passwords, and how the server independently recalculates the same code to verify it. It also covers common reasons for failed codes, such as clock drift or expired entries, and warns that the secret key in the setup QR must be kept private because offline code generation does not protect against phishing or other attacks.

Minh Khoa
10 min
73
32
Previous
Page 1 of 11
Next