php usleep同时请求

I've been playing around with the ApacheBench (ab) command line utility but I'm not sure if it's the right tool for what I'm trying to do.

I was running 10 concurrent and 10 requests doing an INSERT into a MySQL table and looking at round(microtime(1) * 10000) to see if I was getting the same values.

I would like to know if using delayed execution usleep() is enough to prevent two simultaneous requests getting the same value on the same box, or is time_sleep_until better.

I know I could set more entropy with uniqid().

So I'm just wondering if using delayed execution will be enough to prevent two exact time stamps.

So you want to know if round(microtime(1) * 10000) can give duplicate values? Well of course it can, I don't think you need to test for this.

uniqid is also not guaranteed to be unique, even with more entropy.

If uniqueness is really important you could always use MySQL with a UNIQUE index to enforce uniqueness.