aboutsummaryrefslogtreecommitdiff
path: root/spec/tor-spec/handling-resource-exhaustion.md
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2023-10-12 12:27:58 -0400
committerNick Mathewson <nickm@torproject.org>2023-10-12 12:27:58 -0400
commitf7e5a95ee96d8ef52c1732d066c1249a6f84391e (patch)
tree2e1ddd85f471143518d0df7c7645d066d43bc149 /spec/tor-spec/handling-resource-exhaustion.md
parente4e0d93d56ee8c1aec4c2efaa7046b651f0fe55c (diff)
downloadtorspec-f7e5a95ee96d8ef52c1732d066c1249a6f84391e.tar.gz
torspec-f7e5a95ee96d8ef52c1732d066c1249a6f84391e.zip
Convert text specifications to mdbook.
Diffstat (limited to 'spec/tor-spec/handling-resource-exhaustion.md')
-rw-r--r--spec/tor-spec/handling-resource-exhaustion.md32
1 files changed, 32 insertions, 0 deletions
diff --git a/spec/tor-spec/handling-resource-exhaustion.md b/spec/tor-spec/handling-resource-exhaustion.md
new file mode 100644
index 0000000..b8e89eb
--- /dev/null
+++ b/spec/tor-spec/handling-resource-exhaustion.md
@@ -0,0 +1,32 @@
+<a id="tor-spec.txt-8"></a>
+# Handling resource exhaustion
+
+<a id="tor-spec.txt-8.1"></a>
+## Memory exhaustion.
+
+(See also dos-spec.md.)
+
+If RAM becomes low, an OR should begin destroying circuits until
+more memory is free again. We recommend the following algorithm:
+
+- Set a threshold amount of RAM to recover at 10% of the total RAM.
+
+```text
+ - Sort the circuits by their 'staleness', defined as the age of the
+ oldest data queued on the circuit. This data can be:
+
+ * Bytes that are waiting to flush to or from a stream on that
+ circuit.
+
+ * Bytes that are waiting to flush from a connection created with
+ BEGIN_DIR.
+
+ * Cells that are waiting to flush or be processed.
+
+ - While we have not yet recovered enough RAM:
+
+ * Free all memory held by the most stale circuit, and send DESTROY
+ cells in both directions on that circuit. Count the amount of
+ memory we recovered towards the total.
+```
+