|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #59605 RED as workaround for thundering herd problem
Submitted: 2011-02-03 08:24 UTC Modified: 2016-11-18 21:47 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: need4spam at bk dot ru Assigned:
Status: Wont fix Package: APC (PECL)
PHP Version: 5.3.5 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: need4spam at bk dot ru
New email:
PHP Version: OS:


 [2011-02-03 08:24 UTC] need4spam at bk dot ru
In our environment we have a problem with APC. It's 
described on wiki as thundering herd problem -

If we have some long queries that are cached in APC and 
5000+ users using website. When cache expires ~300 users 
produce same query to DB that stalls it for some time.

You can use RED ( ) to avoid 
this problem.

For example if TTL for cache record is almost ended (e.g. 
((creation_time+ttl)-current_time)/ttl < some_tunable) you 
can fail apc_fectch() for this record based on probabilistic 
function inverse proportional to ((creation_time+ttl)-

For now we workaround it using cronjobs or emulating RED in 
our php code, but with time it's getting more and more 


patch-apc_red.patch (last revision 2011-12-03 15:36 UTC by need4spam at bk dot ru)

Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-02-03 14:35 UTC] need4spam at bk dot ru
I've kinda messed up math in previous post, so there is patch 
to latest APC-svn with RED implementation. 

PS. drop_cf should not be hardcoded. Better be tunable via 
 [2011-02-22 03:44 UTC]
This is very interesting, I'll move it to post the 3.1.8 stable release.
 [2011-12-03 15:38 UTC] need4spam at bk dot ru
Slightly modified patch - removed floating point.
It's of cause only PoC, but it has pretty good results:
 [2016-11-18 21:47 UTC]
-Status: Open +Status: Wont fix
 [2016-11-18 21:47 UTC]
APC is no longer supported in favor of opcache that comes bundled with PHP, if you wish to use the user cache, then look at PECL/APCu.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Jul 25 16:01:28 2024 UTC