I just found a use-case for the sleep( rand(1000) ) function :-)
If the rand function produces uniform random numbers, then with enough samples the signal comes out ontop the noise.
If it is non-uniform, then with enough samples you can determine the non uniformity, and you are at square 1 again.
Use proper security instead of obscurity.
And it's not a thing anyone has a legitimate interest in submitting more than that per second.
I.e. the padding to add is (5 - duration_of_operation) with duration of operation being far lower than 5 s.
What would be a proper first step to harden API for timing attacks?
An easy mitigation would be to just drop the card number into a queue and process asynchronously without waiting and returning to the user.