Changeset 10


Ignore:
Timestamp:
07/28/10 07:36:28 (14 years ago)
Author:
bowman
Message:

Made it possible to specify max-cache-wait as a percentage of max-cw-wait (makes more sense when using multiple profiles with different max-cw-wait limits).

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/README.Optimization.txt

    r1 r10  
    1616any other optimizations are insignificant. Even if both proxies are connected to the exact same set of cards, the
    1717second chance it offers to clients (regardless of what the issue was) has a _major_ impact on the perceived stability.
     18This is of course assuming clients with failover functionality similar to mgcamd, that maintain all configured connections
     19(with keep-alives) and will perform a seamless switch to the next applicable connection in case of trouble.
    1820
    1921NOTE: Most of the tips here are based on ca-systems where the possible delay between the ecm appearing in the TS and
     
    4749
    48502. Cardserver behaviour (most of the proxy examples assume newcs, but mpcs/oscam or rqcs have also been used).
    49 -----------------------------------------------------------------------------------------------
     51--------------------------------------------------------------------------------------------------------------
    5052
    5153- Ensure that the server does not have any unnecessary limitations imposed on the account used by the proxy.
     
    133135at least you know where the cutoff point is. Values <4 have not been tested with the proxy, but may still work.
    134136NOTE: To get accurate values with test-delay, use a service that is cached (that other clients are currently watching).
    135 Also, make sure the client ecm timeout is increased to a level where it will not interfere before the test (>9 secs).
     137Also, make sure the client ecm timeout is increased to a level where it will not interfere before the test (>9 secs).
     138That means you cannot use clients such as CCcam where the newcamd timeout is locked to 4 seconds and cannot be changed.
    136139
    137140<connection-manager> / <congestion-limit>
     
    144147
    145148<cache-handler> / <cache-config> / <max-cache-wait>
    146 You want to keep this at a level that is as high as possible, but still allows room for one retry before the
    147 max-cw-wait is reached. I.e. if max-cw-wait is 9, and the average response time for your profiles is around 2 secs,
    148 set the max-cache-wait to 6 or 7 secs.
     149If card capacity is a problem, you want to keep this at a level that is as high as possible but still allows room for
     150one retry before the max-cw-wait is reached.
     151I.e. if max-cw-wait is 9, and the average response time for your profiles is around 2 secs, set the max-cache-wait to 6
     152or 7 secs.
    149153This should result in a behaviour where a timeout in the cache means the client can still receive a reply before
    150154reaching its own timeout. Use the transaction flags to determine whether this is actually the case (see below).
     
    154158do so (or did but it got lost in transit). It is normal to see more cache timeouts in a proxy setup that uses the
    155159clustered cache.
     160
     161For most situations, you want a max-cache-wait that is just slightly above the worst case processing time (if its
     1622500 ms, you might set 3000 ms as the cache wait). This ensures that you only get cache timeouts when actual problems
     163occur, not because normal processing is taking longer than usual (due to peak load or network latency).
     164As of 0.9.0, it is possible to configure max-cache-wait with a percentage string, e.g "50%". This allows for different
     165wait times depending on the max-cw-wait in effect for the profile. If you have multiple profiles with significantly
     166different max-cw-wait times then you should definately use a percentage setting.
    156167
    157168
  • trunk/changelog.txt

    r1 r10  
    1414- Fixed: Initial web startup is now delayed until after there is a usermanager available.
    1515- Fixed: CCcam.channelinfo parsing errors (some of them).
     16- Changed: Now possible to configure max-cache-wait both as a fixed time value (as before) and as a percentage of
     17  the max-cw-wait for the request. I.e if set to the string "50%", requests for a profile with 9000 ms max-cw-wait would
     18  end up with a max-cache-wait of 4500 ms, while requests for another profile with 650 ms would get 325 ms.
    1619- Changed: Adding manual can-decode/cannot-decode services to a connector will now also update any previously
    1720  automapped data to prevent conflicting/overlapping information (so no need to clear maps after manual changes).
  • trunk/config/proxy-reference.html

    r1 r10  
    474474<a name="ca-profiles/profile/max-cw-wait">
    475475<div class='indent'>ca-profiles/profile/max-cw-wait</div><br />
    476 This defines the maximum wait time (in seconds) for anything trying to get a CW reply from this profile, before aborting with a timeout (flag T). Under normal circumstances this should be set to the maximum time a client can wait for CW reply without experiencing a freeze (or 1 second above that). Applies to all CWS connectors in this profile, if set here it overrides the global setting in connection-manager.<br />
     476This defines the maximum wait time (in seconds) for anything trying to get a CW reply from this profile, before aborting with a timeout (flag T). Under normal circumstances this should be set to the maximum time a client can wait for CW reply without experiencing a freeze. Applies to all CWS connectors in this profile, if set here it overrides the global setting in connection-manager.<br />
     477<strong>NOTE: </strong> When using multi-context connectors (e.g csp-connector or chameleon-connector) the max-cw-wait in effect is the global value, not the per profile one.<br />
    477478To determine a reasonable value for max-cw-wait, it is possible to use the test-delay feature in the LoggingPlugin. This can insert an artificial delay into the processing of requests for a specific test-user (source ip address). Increase the delay gradually until freezes occur for the test-user and note the total ecm time in the client logs when this happens, this is your max-cw-wait. Make sure the client ecm timeout is set high enough not to interfere with the result.<br />
    478479See <strong>README.Optimization.txt</strong> for more details.<br />
     
    775776<div class='indent'>connection-manager/max-cw-wait</div><br />
    776777If a CWS connection is congested or not responding, this defines the maximum wait time (in seconds, default: 9) for anything trying to get a CW reply, before aborting with a timeout (flag T). Under normal circumstances this should be set to the maximum time a client can wait for CW reply without experiencing a freeze (or 1 second above that). This is the default for all CWS connectors in all profiles.<br />
     778<strong>NOTE: </strong> When using multi-context connectors (e.g csp-connector or chameleon-connector) the max-cw-wait in effect is always this global value, not the per profile one.<br />
    777779To determine a reasonable value for max-cw-wait, it is possible to use the test-delay feature in the LoggingPlugin. This can insert an artificial delay into the processing of requests for a specific test-user (source ip address). Increase the delay gradually until freezes occur for the test-user and note the total ecm time in the client logs when this happens, this is your max-cw-wait. Make sure the client ecm timeout is set high enough not to interfere with the result.<br />
    778780See <strong>README.Optimization.txt</strong> for more details.<br />
     
    12461248<div class='indent'>cache-handler/cache-config/max-cache-wait</div><br />
    12471249The maximum time (in seconds) that a client can be kept waiting in the cache for a pending request.<br />
     1250<strong>NOTE: </strong> As of 0.9.0, this can also be configured with a percentage string, e.g "50%" to indicate a max-cache-wait of 50% of the max-cw-wait for the request. This makes more sense when using profiles with radically different max-cw-waits in the same proxy (e.g some with 9 seconds and others with 650 ms).<br />
    12481251See <strong>README.Optimization.txt</strong> for more details.<br />
    12491252<br />
  • trunk/src/com/bowman/cardserv/CardServProxy.java

    r1 r10  
    176176    logger.info("-= CardServProxy " + APP_VERSION + " initialized =-");
    177177    logger.fine("CA-Profiles: ");
    178     for(Iterator iter = config.getProfiles().values().iterator(); iter.hasNext(); )
    179       logger.fine("  - " + iter.next());
     178    CaProfile cp;
     179    for(Iterator iter = config.getProfiles().values().iterator(); iter.hasNext(); ) {
     180      cp = (CaProfile)iter.next();
     181      long wait = config.getCacheHandler().getMaxCacheWait(config.getConnManager().getMaxCwWait(cp));
     182      logger.fine("  - " + cp + ((cp != CaProfile.MULTIPLE)?" (cache wait: " + wait + ")":""));
     183    }
    180184    logger.fine("Connectors: ");
    181185    for(Iterator iter = config.getConnManager().getConnectors().values().iterator(); iter.hasNext(); )
     
    525529  private CamdNetMessage checkCache(int successFactor, CamdNetMessage msg, ProxySession session, boolean peek) {
    526530    CamdNetMessage cached;
     531    CaProfile profile = config.getProfile(msg.getProfileName());
    527532    if(!peek) {
    528533      if(msg.getServiceId() == 0 && connManager.getDelayNoSid() > 0) try {
     
    533538        return null;
    534539      }
    535       cached = cacheHandler.processRequest(successFactor, msg, session.getProfile().isCacheOnly());
     540      cached = cacheHandler.processRequest(successFactor, msg, session.getProfile().isCacheOnly(), connManager.getMaxCwWait(profile));
    536541    } else {
    537542      cached = cacheHandler.peekReply(msg);
     
    549554    } else {
    550555      if(msg.isTimeOut()) {
    551         if(msg.getCacheTime() >= cacheHandler.getMaxCacheWait()) session.setFlag(msg, 'O');
     556        if(msg.getCacheTime() >= cacheHandler.getMaxCacheWait(connManager.getMaxCwWait(profile))) session.setFlag(msg, 'O');
    552557        else session.setFlag(msg, 'Q');
    553558      }
  • trunk/src/com/bowman/cardserv/ClusteredCache.java

    r1 r10  
    322322
    323323
    324   public CamdNetMessage processRequest(int successFactor, CamdNetMessage request, boolean alwaysWait) {
     324  public CamdNetMessage processRequest(int successFactor, CamdNetMessage request, boolean alwaysWait, long maxCwWait) {
    325325
    326326    /*
     
    351351    }
    352352
    353     return super.processRequest(successFactor, request, alwaysWait); // call the default processing
     353    return super.processRequest(successFactor, request, alwaysWait, maxCwWait); // call the default processing
    354354  }
    355355
  • trunk/src/com/bowman/cardserv/DefaultCache.java

    r1 r10  
    2020
    2121  private long maxAge;
    22   private long maxWait;
     22  private long maxCacheWait;
     23  private int maxWaitPercent;
    2324
    2425  private int timeouts, instantHits, waitHits, remoteHits;
     
    3031  public void configUpdated(ProxyXmlConfig xml) throws ConfigException {
    3132    maxAge = xml.getTimeValue("cw-max-age", "s");
    32     maxWait = xml.getTimeValue("max-cache-wait", "s");
    33   }
    34 
    35   public long getMaxCacheWait() {
    36     return maxWait;
     33    String maxWaitStr = xml.getStringValue("max-cache-wait");
     34    if(maxWaitStr.endsWith("%")) {
     35      maxCacheWait = -1;
     36      maxWaitStr = maxWaitStr.substring(0, maxWaitStr.length() - 1);
     37      maxWaitPercent = Integer.parseInt(maxWaitStr);
     38      if(maxWaitPercent < 1 || maxWaitPercent > 100)
     39        throw new ConfigException(xml.getFullName(), "max-cache-wait", "Must be a time value or 1-100%");
     40    } else {
     41      maxWaitPercent = -1;
     42      maxCacheWait = xml.getTimeValue("max-cache-wait", "s");
     43    }
     44  }
     45
     46  public long getMaxCacheWait(long maxCwWait) {
     47    if(maxCacheWait == -1) return (long)((maxWaitPercent / 100.0) * maxCwWait);
     48    else return Math.min(maxCwWait, maxCacheWait);
    3749  }
    3850
     
    4355  }
    4456
    45   public CamdNetMessage processRequest(int successFactor, CamdNetMessage request, boolean alwaysWait) {
     57  public CamdNetMessage processRequest(int successFactor, CamdNetMessage request, boolean alwaysWait, long maxCwWait) {
    4658    long start = System.currentTimeMillis();
     59    long maxWait = getMaxCacheWait(maxCwWait);
    4760
    4861    synchronized(this) {
  • trunk/src/com/bowman/cardserv/interfaces/CacheHandler.java

    r1 r10  
    1414
    1515  void start();
    16   CamdNetMessage processRequest(int successFactor, CamdNetMessage request, boolean alwaysWait);
     16  CamdNetMessage processRequest(int successFactor, CamdNetMessage request, boolean alwaysWait, long maxCwWait);
    1717  boolean processReply(CamdNetMessage request, CamdNetMessage reply);
    1818  CamdNetMessage peekReply(CamdNetMessage request);
    19   long getMaxCacheWait();
     19  long getMaxCacheWait(long maxCwWait);
    2020
    2121  Properties getUsageStats();
  • trunk/src/com/bowman/cardserv/proxy.xml

    r1 r10  
    1414      </radegast>
    1515      <services-file>etc/services</services-file>
     16      <max-cw-wait>8500 ms</max-cw-wait>
    1617    </profile>
    1718  </ca-profiles>
     
    107108    <cache-config>
    108109      <cw-max-age>19</cw-max-age>
    109       <max-cache-wait>3500 ms</max-cache-wait>
     110      <max-cache-wait>40%</max-cache-wait>
    110111      <local-port>54277</local-port>
    111112      <sync-period>0</sync-period>
Note: See TracChangeset for help on using the changeset viewer.