成长值: 336 签到天数: 4737 天 [LV.Master]伴坛终老
|
发表于 2024/4/9 02:54
|
显示全部楼层
|阅读模式
|Google Chrome 123.0.0.0 |Windows 10
NexusPHP pt站tracker服务器性能优化,改动announce.php代码加入随机间隔汇报
问题现象,有些用户挂了几千个种子,会在1秒内高达几千的并发连接数请求到达服务器中,导致服务器定期时间出现异常高cpu消耗,如图所示
本代码修复了这个问题,加入差分技术实现为每一个种子的间隔时间错开峰值,不在出现服务器异常CPU高峰值
源代码
- $real_annnounce_interval = $announce_interval;
- if ($anninterthreeage && ($anninterthree > $announce_wait) && (TIMENOW - $torrent['ts']) >= ($anninterthreeage * 86400))
- $real_annnounce_interval = $anninterthree;
- elseif ($annintertwoage && ($annintertwo > $announce_wait) && (TIMENOW - $torrent['ts']) >= ($annintertwoage * 86400))
- $real_annnounce_interval = $annintertwo;
复制代码
新代码
- // https://bbs.itzmx.com/thread-106752-1-1.html
- $OT_CLIENT_REQUEST_INTERVAL = $announce_interval;
- $OT_CLIENT_REQUEST_INTERVAL2 = $annintertwo;
- $OT_CLIENT_REQUEST_INTERVAL3 = $anninterthree;
- $OT_CLIENT_REQUEST_VARIATION = 60 * 6; // random 6 minute
- $announce_interval_random = $OT_CLIENT_REQUEST_INTERVAL - $OT_CLIENT_REQUEST_VARIATION / 2 + mt_rand(0, $OT_CLIENT_REQUEST_VARIATION);
- $announce_interval_random2 = $OT_CLIENT_REQUEST_INTERVAL2 - $OT_CLIENT_REQUEST_VARIATION / 2 + mt_rand(0, $OT_CLIENT_REQUEST_VARIATION);
- $announce_interval_random3 = $OT_CLIENT_REQUEST_INTERVAL3 - $OT_CLIENT_REQUEST_VARIATION / 2 + mt_rand(0, $OT_CLIENT_REQUEST_VARIATION);
- $real_annnounce_interval = $announce_interval_random;
- if ($anninterthreeage && ($anninterthree > $announce_wait) && (TIMENOW - $torrent['ts']) >= ($anninterthreeage * 86400))
- $real_annnounce_interval = $announce_interval_random3;
- elseif ($annintertwoage && ($annintertwo > $announce_wait) && (TIMENOW - $torrent['ts']) >= ($annintertwoage * 86400))
- $real_annnounce_interval = $announce_interval_random2;
复制代码
修复后的代码下载:
announce.7z
(4.41 KB, 下载次数: 2)
|
|