I've got the following code and the semaphore wouldn't lock it as expected.
(I'm aware of apc_inc. This is not what I'm looking for.)
$semkey = sem_get(123);
sem_acquire($semkey);
$count = apc_fetch('count111');
if(!$count) $count = 0;
$count++;
apc_store('count111', $count);
sem_release($semkey);
followed by
ab -n 4000 -c 200 http://localhost/test.php
0 requests failed.
but after that an apc_fetch('count111')
shows only ~ 1200 hits
nginx on ubuntu 12.04 (64bit), php 5.3.16~dotdeb, php-fpm
The problem was, apparently, with the APC itself, not with the semaphore.
Updating to PHP 5.4.8-1~dotdeb.0 has solved the problem for both nginx and built-in server test runs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With