Back to Blog

Weekly Commit #017

November 20, 20263 min read
... views
WeeklyCommitDistributed SystemsCybersecuritySoftware EngineeringIST

This week, things I learned in lectures ended up in a design review at work. It felt like the double schedule paying off.

From the classroom to a design review

The design was for a batch-processing feature: large batches of jobs, with several worker instances pulling items from a shared queue. I left two comments, and both came straight from my courses.

Two illustrations side by side: mice and elephants, and a Chubby distributed lock service diagram for leases and sequencers

Mice and elephants, from Performance Evaluation. Batches were processed in strict creation order, so a 10-item batch started right after a 2000-item one would wait for all of it. In networking these are mice and elephants: short flows stuck behind long ones. Giving the mice absolute priority isn't the answer, because a steady stream of them could starve the elephant. Interleaving is. Each round takes a few items from every active batch, so the mouse finishes in about a minute instead of over an hour, and the elephant barely notices. Total work stays the same. What changes is who waits.

Leases and sequencers, from Google's Chubby. A worker owns an item for 15 minutes, and after that another worker can take it, in case the first one crashed. But the database can't tell a crashed worker from a slow one, so a slow job could be paid for twice and a late failure could overwrite a success. My idea was to do what Chubby does. Workers renew their lease while they're busy, like Chubby's KeepAlives. And since renewal alone isn't enough (a worker can freeze, miss its renewal and still write late), every claim also gets a token, Chubby's sequencer, checked inside the same UPDATE that writes the result. If the token changed, nothing is written.

My takeaway: renewal makes the problem rare, only the token makes it harmless. And theory I'd studied in class turned out to be the clearest way to explain a real problem.

Smaller things this week

  • Network and Computer Security: our project moved from the business flow to the system architecture of an eSports platform. Drawing the flow first made the trust boundaries obvious.
  • Software Security: two labs, two lessons. First, don't trust the client: a try limit kept in a cookie, and an admin check on an unsigned base64 cookie. Second, mind the gap between check and use (TOCTOU): a symlink swapped between access() and open(), and a page read after login set the username but before it rejected the password. The second lesson is the claim token problem again.

Eight weeks in. One commit at a time. See you next week.

#WeeklyCommit #DistributedSystems #Cybersecurity #SoftwareEngineering #IST

Follow along here or on LinkedIn where I'll be sharing each new commit.