---
title: "Ziwei Yao (@vitayao) | Hashnode"
description: "Manager at Tokatlas. Read the latest articles by Ziwei Yao on Hashnode."
url: "https://hashnode.com/@vitayao"
---

@vitayao

# Ziwei Yao

@vitayao · Joined October 2026

Manager at Tokatlas

## Comments

[If reconciliation can be retried, I’d also run it twice for the same request and check that the reservation settles only once. That would cover duplicate settlement as well as the retry race.](https://hashnode.com/posts/rate-limiting-algorithms-how-to-protect-your-api-without-annoying-your-users-hdp4e/6adf13f827c3f1dc1e9bccfc/comment/6adf1d55d3e0a4968c437d8d#reply-6ae060d47651a675141b4b00)

Reply · Article · Oct 27 · [Rate Limiting Algorithms: How to Protect Your API Without Annoying Your Users](https://hashnode.com/posts/rate-limiting-algorithms-how-to-protect-your-api-without-annoying-your-users-hdp4e/6adf13f827c3f1dc1e9bccfc)

[A latch in the test could make the pause reproducible instead of depending on sleep timing. That would be a nice companion to the revised example.](https://hashnode.com/posts/system-design-drill-day-8-distributed-locks-with-redis-and-fencing-tokens/6adec4d52d0de51d89be8ab0/comment/6adf1e02559b843e076534ac#reply-6ae060781b2db2d2f9307032)

Reply · Article · Oct 27 · [System Design Drill Day 8: Distributed Locks with Redis and Fencing Tokens](https://hashnode.com/posts/system-design-drill-day-8-distributed-locks-with-redis-and-fencing-tokens/6adec4d52d0de51d89be8ab0)

[Thanks! The accounting edge case I'd keep explicit is 'client disconnected, provider outcome unknown'. Releasing that reservation immediately could let a retry spend the same budget twice. I'd reconcile it from the provider's final usage or send the unknown outcome for review, rather than treating a browser disconnect as proof that no work was billed.](https://hashnode.com/posts/rate-limiting-algorithms-how-to-protect-your-api-without-annoying-your-users-hdp4e/6adf13f827c3f1dc1e9bccfc/comment/6adf1d55d3e0a4968c437d8d#reply-6ae00d20b9edb22e528783cb)

Reply · Article · Oct 27 · 1 · [Rate Limiting Algorithms: How to Protect Your API Without Annoying Your Users](https://hashnode.com/posts/rate-limiting-algorithms-how-to-protect-your-api-without-annoying-your-users-hdp4e/6adf13f827c3f1dc1e9bccfc)

[Thanks for checking that. I'd have the regression test assert that the stale holder's write is rejected after the newer holder has written, not just that stock stays non-negative. Those are separate guarantees, and the stock constraint could otherwise make the test pass while fencing is still broken.](https://hashnode.com/posts/system-design-drill-day-8-distributed-locks-with-redis-and-fencing-tokens/6adec4d52d0de51d89be8ab0/comment/6adf1e02559b843e076534ac#reply-6ae00cc51e22047b4cea9126)

Reply · Article · Oct 27 · [System Design Drill Day 8: Distributed Locks with Redis and Fencing Tokens](https://hashnode.com/posts/system-design-drill-day-8-distributed-locks-with-redis-and-fencing-tokens/6adec4d52d0de51d89be8ab0)

[Should lease acquisition and fencing-token allocation be atomic? With SET NX followed by a separate INCR, A could acquire, pause before INCR, and lose its lease. B acquires, gets token 1 and writes. A resumes, gets token 2, and its stale write passes fence\_token < :token. The stock check still prevents overselling, but does this break the stale-holder guarantee? I’d test a pause between those Redis commands.](https://hashnode.com/posts/system-design-drill-day-8-distributed-locks-with-redis-and-fencing-tokens/6adec4d52d0de51d89be8ab0/comment/6adf1e02559b843e076534ac)

Comment · Article · Oct 26 · [System Design Drill Day 8: Distributed Locks with Redis and Fencing Tokens](https://hashnode.com/posts/system-design-drill-day-8-distributed-locks-with-redis-and-fencing-tokens/6adec4d52d0de51d89be8ab0)

[One extra layer I’d add for long-running LLM requests is an in-flight concurrency limit. A token bucket caps arrivals, but if calls become much slower, the number running at once can still grow while the arrival rate stays within budget. For usage that isn’t known up front, reserving an upper bound and reconciling with actual usage also needs its own accounting. I’d test a slowdown and a client disconnect separately: the client going away doesn’t necessarily mean the provider stopped doing work.](https://hashnode.com/posts/rate-limiting-algorithms-how-to-protect-your-api-without-annoying-your-users-hdp4e/6adf13f827c3f1dc1e9bccfc/comment/6adf1d55d3e0a4968c437d8d)

Comment · Article · Oct 26 · 1 · [Rate Limiting Algorithms: How to Protect Your API Without Annoying Your Users](https://hashnode.com/posts/rate-limiting-algorithms-how-to-protect-your-api-without-annoying-your-users-hdp4e/6adf13f827c3f1dc1e9bccfc)
