On CentOS, setting a libcurl timeout below 1000ms makes curl return CURLRESOLV_TIMEDOUT without sending any request — because SIGALARM-based DNS timeouts have only one-second resolution. Setting CURLOPT_NOSIGNAL bypasses it; building libcurl with c-ares avoids the tradeoff entirely.
with 0 CommentSlides from a talk I gave in Shanghai this past June, covering a year of Weibo work — changes to Yaf, plus new tools like Yar and Yac. The overall approach (speed up first, cut costs, clarify the architecture, SOA) more than halved Weibo's homepage response time while lowering overall costs.
with 0 Commentphp-valgrind is a small PHP extension that lets you toggle Callgrind profiling from inside a PHP script — using CALLGRIND_TOGGLE_COLLECT — so you can profile a specific code segment and see which underlying functions and syscalls it triggers.
with 0 CommentAPC's User Data Cache is bottlenecked by locks and performs like local memcached, so I built Yac: a shared-memory user data cache with lock-free reads (crc-validated), double hashing (MurmurHash) over chunked segments, and LRU eviction. In an ab test it ran ~7.7x faster than APC.
with 0 CommentWhy does this PDO bindParam loop insert 'weibo' for both columns? Because bindParam takes its second argument by reference, and the foreach $value variable keeps getting overwritten. Three ways to do it right: assign manually, use bindValue, or foreach by reference.
with 0 CommentA new mcrypt-based script responded very slowly under 20 concurrent requests while all server metrics looked normal. Cause: mcrypt_create_iv defaults to /dev/random, whose entropy pool is fed by system interrupts and can block when depleted. Fix: use MCRYPT_DEV_URANDOM (or rngd to refill the pool).
with 0 CommentYar is a lightweight PHP-extension RPC framework supporting msgpack/json/php packing protocols. Unlike xml-rpc or soap, its headline feature is concurrent calls: fire many requests at once with Yar_Concurrent_Client::call() + loop(), and a callback fires as soon as each returns — so you can process multiple data sources in parallel.
with 0 Comment