Start here. This is the direct spoken answer to practice first.
Why this question matters
Uncontrolled time and randomness create intermittent failures around boundaries and make a failed scenario difficult to reproduce.
I treat time, randomness, and id generation as inputs. In .NET I can inject TimeProvider, a narrow random source, or an id factory, then use deterministic implementations in tests. The production implementation still uses the real clock, cryptographically appropriate randomness where required, and normal identifier generation.