Dynmaic load shedding
authorWoo Xie <woo@fb.com>
Tue, 28 Apr 2015 22:25:31 +0000 (15:25 -0700)
committerAndrii Grynenko <andrii@fb.com>
Wed, 29 Apr 2015 22:57:33 +0000 (15:57 -0700)
Summary:
add a free system memory limit to Load Shed Configuration for dynamic shedding

Test Plan:
tested on edge241.01.ams3, works as expected. Once the free memory is less than 23G (picked on purpose for testing),  new connections are shedded.   But the shedding rate is totally wrong.  I will explain and address it in another diff.

https://fburl.com/103620501
https://fburl.com/103620701

Reviewed By: afrind@fb.com

Subscribers: trunkagent, fugalh, bmatheny, nimishshah, folly-diffs@, jsedgwick, yfeldblum, chalfant, xning, alexkr

FB internal diff: D2026477

Tasks: 4604893

Signature: t1:2026477:1430176828:65eadd82efa3189a1bebcb8518efaf56cd36beed

folly/wangle/acceptor/LoadShedConfiguration.h

index a7eb85caa95f3edae1a6be449f95a6c06acf7200..57c51b97222e72911ba4355630558715fd594cd7 100644 (file)
@@ -87,6 +87,16 @@ class LoadShedConfiguration {
   }
   double getMaxCpuUsage() const { return maxCpuUsage_; }
 
+  /**
+   * Set/get the minium actual free memory on the system.
+   */
+  void setMinFreeMem(uint64_t min) {
+    minFreeMem_ = min;
+  }
+  uint64_t getMinFreeMem() const {
+    return minFreeMem_;
+  }
+
   void setLoadUpdatePeriod(std::chrono::milliseconds period) {
     period_ = period;
   }
@@ -99,6 +109,7 @@ class LoadShedConfiguration {
   AddressSet whitelistAddrs_;
   NetworkSet whitelistNetworks_;
   uint64_t maxConnections_{0};
+  uint64_t minFreeMem_{0};
   double maxMemUsage_;
   double maxCpuUsage_;
   std::chrono::milliseconds period_;