[ https://issues.apache.org/jira/browse/TS-4909?focusedWorklogId=30200&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-30200 ]
ASF GitHub Bot logged work on TS-4909: -------------------------------------- Author: ASF GitHub Bot Created on: 05/Oct/16 20:00 Start Date: 05/Oct/16 20:00 Worklog Time Spent: 10m Work Description: Github user jpeach commented on a diff in the pull request: https://github.com/apache/trafficserver/pull/1063#discussion_r82056447 --- Diff: proxy/Main.cc --- @@ -346,6 +346,54 @@ class DiagsLogContinuation : public Continuation } }; +class MemoryLimit : public Continuation +{ +public: + MemoryLimit() : Continuation(new_ProxyMutex()), _memory_limit(0) { SET_HANDLER(&MemoryLimit::periodic); } + ~MemoryLimit() { mutex = NULL; } + int + periodic(int event, Event *e) + { + if (event == EVENT_IMMEDIATE) { + // rescheduled from periodic to immediate event + // this is the indication to terminate + delete this; + return EVENT_DONE; + } + if (_memory_limit == 0) { + // first time it has been run + _memory_limit = REC_ConfigReadInteger("proxy.config.memory.max_usage"); + } + if (_memory_limit > 0) { + if (getrusage(RUSAGE_SELF, &_usage) == 0) { + Debug("server", "memory usage - ru_maxrss: %ld memory limit: %" PRId64, _usage.ru_maxrss, _memory_limit); + if (_usage.ru_maxrss > _memory_limit) { + if (net_memory_throttle == false) { + net_memory_throttle = true; + Debug("server", "memory usage exceeded limit - ru_maxrss: %ld memory limit: %" PRId64, _usage.ru_maxrss, _memory_limit); + } + } else { + if (net_memory_throttle == true) { + net_memory_throttle = false; + Debug("server", "memory usage under limit - ru_maxrss: %ld memory limit: %" PRId64, _usage.ru_maxrss, _memory_limit); + } + } + } + } else { + // this feature has not be enabled + Debug("server", "limiting connections baxed on memory usage has been disabled"); --- End diff -- s/baxed/based/ Issue Time Tracking ------------------- Worklog Id: (was: 30200) Time Spent: 40m (was: 0.5h) > Throttling based on resident memory usage > ----------------------------------------- > > Key: TS-4909 > URL: https://issues.apache.org/jira/browse/TS-4909 > Project: Traffic Server > Issue Type: Improvement > Components: Core > Reporter: Bryan Call > Fix For: 7.1.0 > > Time Spent: 40m > Remaining Estimate: 0h > > Add a feature to stop accepting connections if the resident memory is over a > certain limit. -- This message was sent by Atlassian JIRA (v6.3.4#6332)