public class RequestThrottler extends Object
| Modifier and Type | Field and Description |
|---|---|
static int | _highLoadCpuPctHigh-load CPU threshold (percent) @since 0.9.70+ |
static int | _highLoadLagMsHigh-load job lag threshold (ms) @since 0.9.70+ |
static int | _highLoadSysLoadPctHigh-load system load threshold (percent, normalized by cores) @since 0.9.70+ |
static int | _moderateLoadCpuPctModerate-load CPU threshold (percent) @since 0.9.70+ |
static int | _moderateLoadLagMsModerate-load job lag threshold (ms) @since 0.9.70+ |
static int | _moderateLoadSysLoadPctModerate-load system load threshold (percent, normalized by cores) @since 0.9.70+ |
static int | _reqBurst1sThresholdBurst threshold for 1-second sliding window (requests per second). |
static int | _reqLoadWeightLoad weight: how much load inflates effective ratio (0-300%, default 100%). |
static int | _reqMaxLimitMaximum request limit per peer. |
static int | _reqMinLimitMinimum request limit per peer. |
static int | _reqPercentLimitRequest limit as percentage of participating tunnel count. |
static int | _reqRejectSteepnessRejection steepness: 100=linear ramp, 200=quadratic. |
static int | _reqRejectThresholdRejection threshold: start rejecting at count/limit ratio this high (30-100, default 70%). |
static long | _sustainedModerateLoadMsDuration (ms) moderate load must persist before disconnecting low-share peers @since 0.9.70+ |
(package private) static boolean | DEFAULT_SHOULD_DISCONNECT |
(package private) static boolean | DEFAULT_SHOULD_THROTTLE |
(package private) static String | PROP_SHOULD_DISCONNECT |
(package private) static String | PROP_SHOULD_THROTTLE |
| Constructor and Description |
|---|
RequestThrottler(RouterContext ctx)Creates a new RequestThrottler bound to the given router context. |
| Modifier and Type | Method and Description |
|---|---|
(package private) static long | burstBanDurationMs(int offenses)Ban length for a repeated burst offense: zero for the first
BURST_BAN_OFFENSES - 1 offenses (throttle-only), then five
minutes growing by five minutes per further offense, capped at
thirty minutes. |
(package private) static int | burstThreshold(int configuredThreshold,
int limit)Effective single-second burst threshold for a peer: the configured
floor, raised so peers whose limit permits heavy traffic are not
banned for bursts that limit allows (one tenth of the 90-second
request limit as a per-second ceiling). |
static int | getHighLoadCpuPct()The high-load CPU threshold percentage. |
static int | getHighLoadLagMs()The high-load job lag threshold in milliseconds. |
static int | getHighLoadSysLoadPct()The high-load system load threshold percentage (normalized by cores). |
static int | getModerateLoadCpuPct()The moderate-load CPU threshold percentage. |
static int | getModerateLoadLagMs()The moderate-load job lag threshold in milliseconds. |
static int | getModerateLoadSysLoadPct()The moderate-load system load threshold percentage (normalized by cores). |
static int | getRequestBurst1sThreshold()The burst threshold for 1-second sliding window. |
static int | getRequestLoadWeight()The load weight (how much load inflates effective ratio, 0-300%). |
static int | getRequestMaxLimit()The maximum request limit per peer. |
static int | getRequestMinLimit()The minimum request limit per peer. |
static int | getRequestPctLimit()The request limit as percentage of participating tunnel count. |
static int | getRequestRejectSteepness()The rejection steepness (100=linear ramp, 200=quadratic). |
static int | getRequestRejectThreshold()The rejection threshold (30-100, default 70%). |
static long | getSustainedModerateLoadMs()The duration (ms) moderate load must persist before disconnecting low-share peers. |
(package private) static float | luEnforcementProbability(float loadScore)Probability of enforcing the LU prev-hop ban at a given load score:
zero when idle, linear up to full enforcement at 50% load and beyond,
so unloaded routers carry LU traffic while loaded ones shed it. |
static void | setHighLoadCpuPct(int val)The high-load CPU threshold percentage. |
static void | setHighLoadLagMs(int val)The high-load job lag threshold in milliseconds. |
static void | setHighLoadSysLoadPct(int val)The high-load system load threshold percentage. |
static void | setModerateLoadCpuPct(int val)The moderate-load CPU threshold percentage. |
static void | setModerateLoadLagMs(int val)The moderate-load job lag threshold in milliseconds. |
static void | setModerateLoadSysLoadPct(int val)The moderate-load system load threshold percentage. |
static void | setRequestBurst1sThreshold(int val)The burst threshold for 1-second sliding window. |
static void | setRequestLoadWeight(int val)The load weight percentage. |
static void | setRequestMaxLimit(int val)The maximum request limit per peer. |
static void | setRequestMinLimit(int val)The minimum request limit per peer. |
static void | setRequestPctLimit(int val)The request limit as percentage of participating tunnel count. |
static void | setRequestRejectSteepness(int val)The rejection steepness (100=linear, 500=max curve). |
static void | setRequestRejectThreshold(int val)The rejection threshold percentage. |
static void | setSustainedModerateLoadMs(long val)The duration (ms) moderate load must persist before disconnecting low-share peers. |
(package private) boolean | shouldThrottle(Hash h)Checks if the given router's tunnel requests should be throttled. |
public static volatile int _highLoadCpuPct
public static volatile int _highLoadLagMs
public static volatile int _highLoadSysLoadPct
public static volatile int _moderateLoadCpuPct
public static volatile int _moderateLoadLagMs
public static volatile int _moderateLoadSysLoadPct
public static volatile int _reqBurst1sThreshold
public static volatile int _reqLoadWeight
public static volatile int _reqMaxLimit
public static volatile int _reqMinLimit
public static volatile int _reqPercentLimit
public static volatile int _reqRejectSteepness
public static volatile int _reqRejectThreshold
public static volatile long _sustainedModerateLoadMs
static final boolean DEFAULT_SHOULD_DISCONNECT
static final boolean DEFAULT_SHOULD_THROTTLE
static final String PROP_SHOULD_DISCONNECT
static final String PROP_SHOULD_THROTTLE
RequestThrottler(RouterContext ctx)
ctx - the router contextstatic long burstBanDurationMs(int offenses)
BURST_BAN_OFFENSES - 1 offenses (throttle-only), then five
minutes growing by five minutes per further offense, capped at
thirty minutes.offenses - the consecutive offense count, 1-basedstatic int burstThreshold(int configuredThreshold,
int limit)configuredThreshold - the i2p.tunnel.requestThrottle.burst1sThreshold valuelimit - the peer's request limit for the current windowpublic static int getHighLoadCpuPct()
public static int getHighLoadLagMs()
public static int getHighLoadSysLoadPct()
public static int getModerateLoadCpuPct()
public static int getModerateLoadLagMs()
public static int getModerateLoadSysLoadPct()
public static int getRequestBurst1sThreshold()
public static int getRequestLoadWeight()
public static int getRequestMaxLimit()
public static int getRequestMinLimit()
public static int getRequestPctLimit()
public static int getRequestRejectSteepness()
public static int getRequestRejectThreshold()
public static long getSustainedModerateLoadMs()
static float luEnforcementProbability(float loadScore)
loadScore - the 0.0-1.0 load score from
ParticipatingThrottler.calculateLoadScore(net.i2p.router.RouterContext)public static void setHighLoadCpuPct(int val)
val - the CPU percentage (clamped to 50-100)public static void setHighLoadLagMs(int val)
val - the high-load lag threshold (clamped to 200-5000)public static void setHighLoadSysLoadPct(int val)
val - the system load percentage (clamped to 50-100)public static void setModerateLoadCpuPct(int val)
val - the CPU percentage (clamped to 40-100)public static void setModerateLoadLagMs(int val)
val - the moderate-load lag threshold (clamped to 100-3000)public static void setModerateLoadSysLoadPct(int val)
val - the system load percentage (clamped to 30-100)public static void setRequestBurst1sThreshold(int val)
val - the burst threshold (clamped to 1-100)public static void setRequestLoadWeight(int val)
val - the load weight (clamped to 0-300)public static void setRequestMaxLimit(int val)
val - the maximum limit (clamped to 10-1000)public static void setRequestMinLimit(int val)
val - the minimum limit (clamped to 1-100)public static void setRequestPctLimit(int val)
val - the percentage limit (clamped to 1-100)public static void setRequestRejectSteepness(int val)
val - the steepness value (clamped to 100-500)public static void setRequestRejectThreshold(int val)
val - the rejection threshold (clamped to 30-100)public static void setSustainedModerateLoadMs(long val)
val - the sustained moderate load duration (clamped to 10-300s)boolean shouldThrottle(Hash h)
h - the router's hash