* Increase sendProcessingTime some more, add a property to configure.

Configure with 'router.defaultProcessingTimeThrottle'.
This commit is contained in:
mathiasdm
2009-05-27 13:26:51 +00:00
parent 8fef5d9a06
commit fd598dea5b
3 changed files with 19 additions and 41 deletions

View File

@ -1,3 +1,7 @@
2009-05-27 Mathiasdm
* Increase sendProcessingTime some more, add a property to configure.
Configure with 'router.defaultProcessingTimeThrottle'.
2009-05-27 Mathiasdm
* Increased sendProcessingTime limits and added testSuccessTime
to avoid unwanted throttling

View File

@ -10,6 +10,11 @@
<name>i2p_router</name>
<properties/>
<folders>
<source-folder>
<label>i2p_router</label>
<location>.</location>
<encoding>UTF-8</encoding>
</source-folder>
<source-folder>
<label>src</label>
<type>java</type>
@ -22,11 +27,6 @@
<location>test</location>
<encoding>UTF-8</encoding>
</source-folder>
<source-folder>
<label>i2p_router</label>
<location>.</location>
<encoding>UTF-8</encoding>
</source-folder>
</folders>
<ide-actions>
<action name="build">
@ -73,6 +73,7 @@
<ide-action name="test"/>
</context-menu>
</view>
<subprojects/>
</general-data>
<java-data xmlns="http://www.netbeans.org/ns/freeform-project-java/2">
<compilation-unit>

View File

@ -33,6 +33,8 @@ class RouterThrottleImpl implements RouterThrottle {
private static final String PROP_MAX_TUNNELS = "router.maxParticipatingTunnels";
private static final int DEFAULT_MAX_TUNNELS = 2000;
private static final String PROP_DEFAULT_KBPS_THROTTLE = "router.defaultKBpsThrottle";
private static final String PROP_MAX_PROCESSINGTIME = "router.defaultProcessingTimeThrottle";
private static final int DEFAULT_MAX_PROCESSINGTIME = 1500;
/** tunnel acceptance */
public static final int TUNNEL_ACCEPT = 0;
@ -96,33 +98,17 @@ class RouterThrottleImpl implements RouterThrottle {
return TunnelHistory.TUNNEL_REJECT_BANDWIDTH;
long lag = _context.jobQueue().getMaxLag();
// reject here if lag too high???
// reject here if lag too high???
RateStat rs = _context.statManager().getRate("transport.sendProcessingTime");
Rate r = null;
if (rs != null)
r = rs.getRate(60*1000);
double processTime = (r != null ? r.getAverageValue() : 0);
if (processTime > 5000) {
if (_log.shouldLog(Log.DEBUG))
_log.debug("Refusing tunnel request with the job lag of " + lag
+ "since the 1 minute message processing time is too slow (" + processTime + ")");
_context.statManager().addRateData("router.throttleTunnelProcessingTime1m", (long)processTime, (long)processTime);
setTunnelStatus("Rejecting tunnels: High message delay");
return TunnelHistory.TUNNEL_REJECT_TRANSIENT_OVERLOAD;
}
//Reject tunnels if the time to process messages and send them is too large. Too much time implies congestion.
Rate r2 = _context.statManager().getRate("tunnel.testSuccessTime").getRate(60*1000);
if(r != null && r2 != null) {
if(r != null) {
double totalSendProcessingTimeEvents = r.getCurrentEventCount() + r.getLastEventCount();
double avgSendProcessingTime = 0;
double currentSendProcessingTime = 0;
double lastSendProcessingTime = 0;
double totalTestSuccessTimeEvents = r2.getCurrentEventCount() + r2.getLastEventCount();
double avgTestSuccessTime = 0;
double currentTestSuccessTime = 0;
double lastTestSuccessTime = 0;
//Calculate times
if(r.getCurrentEventCount() > 0) {
@ -141,25 +127,12 @@ class RouterThrottleImpl implements RouterThrottle {
}
}
if(r2.getCurrentEventCount() > 0) {
currentTestSuccessTime = r2.getCurrentTotalValue()/r.getCurrentEventCount();
}
if(r2.getLastEventCount() > 0) {
lastTestSuccessTime = r2.getLastTotalValue()/r2.getLastEventCount();
}
if(totalTestSuccessTimeEvents > 0) {
avgTestSuccessTime = (r2.getCurrentTotalValue() + r.getLastTotalValue())/totalTestSuccessTimeEvents;
}
else {
avgTestSuccessTime = r2.getAverageValue();
if(_log.shouldLog(Log.WARN)) {
_log.warn("No events occurred. Using 1 minute average to look at message delay.");
}
}
int maxProcessingTime = _context.getProperty(PROP_MAX_PROCESSINGTIME, DEFAULT_MAX_PROCESSINGTIME);
//Set throttling if necessary
if((avgSendProcessingTime > 800 || currentSendProcessingTime > 1000 || lastSendProcessingTime > 1000)
&& (currentTestSuccessTime > 3000 || lastTestSuccessTime > 3000)) {
if((avgSendProcessingTime > maxProcessingTime*0.9
|| currentSendProcessingTime > maxProcessingTime
|| lastSendProcessingTime > maxProcessingTime)) {
if(_log.shouldLog(Log.WARN)) {
_log.warn("Refusing tunnel request due to sendProcessingTime of " + avgSendProcessingTime
+ " ms over the last two minutes, which is too much.");