Design an online auction
hard 90 minDesign the classes of an auction with maximum bids, a secret reserve, steps and a soft close.
Watch lesson5:05
Where it shows up
The same pattern appears across everyday software.
eBay: automatic bidding
Bidders enter the highest price they would pay, and the site bids for them in increments, only up to that limit. The help page explains why somebody can be outbid at once.
Solidity: simple open auction
The documentation's contract has a highest bid, a fixed end and an `ended` flag. Beaten bidders withdraw their money themselves, because calling foreign code while deciding is a risk.
Solidity: blind auction
The next example on the same page: bidders first send a fingerprint of their bid and reveal it later. Commit and reveal.
OpenRTB
The interface of the advertising industry. A bid request says the auction type, first price or second price plus, a floor, and `tmax`, the time that bidders have in milliseconds.
US Treasury auctions
Non-competitive bids are accepted first. Then competitive ones from the lowest rate up, until the whole amount is given. Many units, one sale.
PostgreSQL: row locks
`SELECT ... FOR UPDATE` on the lot's row makes bids for it serial in a database: the monitor of this page, held by a transaction.
Redis: transactions with WATCH
A key is watched, read and changed; if somebody else changed it in between, the transaction is not executed. Compare and set for a standing that lives in Redis.
Kubernetes leases
Lease objects are used for leader election: one holder, a time, renewals. The same idea that gives a lot one owner among machines.