What is happening here, I have laravel code :
class HomeController extends Controller
{
public function index()
{
$this->test();
}
public function index2()
{
$this->test();
}
private function test(){
$milliseconds = round(microtime(true) * 1000);
\DB::transaction(function (){
$order = Order::find(1)->lockForUpdate()->first();
$order->update(['session_id' => str_random(40)]);
sleep(2);
});
$milliseconds2 = round(microtime(true) * 1000);
echo 'milliseconds=' . ($milliseconds2 - $milliseconds) . ' ms';
}
}
when I run index route in two tabs in browser results is:
first tab : milliseconds=2068 ms
second tab : milliseconds=2065 ms
although one request takes about 2 seconds, another 4 seconds
when I run index route in one tab, index2 in second tab result is something like:
first tab : milliseconds=2082 ms
second tab : milliseconds=4117 ms
also one request takes about 2 seconds, another 4 seconds. This is very strange, what is going on here ?!??
via fico7489