<div dir="ltr">So<div>it will hurt Tor if we have too little buffers -> killing circuits -> unstable connections<div>it will hurt Tor if we have too much buffers -> process out of control -> unstable instance</div></div><div><br></div><div>Would it be possible to guestimate typical circuit buffer size?</div><div><br></div><div>One could then estimate value not too big / small based on the number of circuit running through relay.</div><div><br></div><div>If we where to say that a circuit would typically need 128k, one could estimate the setting for a 5K circuit relay to be ~600MB.<br></div><div><br></div><div>Regards</div></div><br><div class="gmail_quote"><div dir="ltr">On Fri, 22 Dec 2017 at 22:55 David Goulet <<a href="mailto:dgoulet@torproject.org">dgoulet@torproject.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 22 Dec (20:37:37), r1610091651 wrote:<br>
> I'm wondering if it is necessary to have a lot of ram assigned to queues?<br>
> Is there some rule of thumb to determine the proper sizing? Based on number<br>
> of circuits maybe?<br>
<br>
So there are probably many different answers to this or ways to look at<br>
it but I can speak on how "tor" is built and why it is important to have<br>
this memory limit assigned to queues.<br>
<br>
A tor relay gets cells in and most of the time will relay them so send<br>
them outbound. But for every cell that comes in, we need to do some<br>
processing on them that is mostly decryption work.<br>
<br>
So we get them, process then put them on a circuit queue. Then tor does<br>
its best to dequeue a "not too big amount of cells" from a circuit and<br>
puts them on the outbound connection buffers which, when the socket is<br>
writable, will be flushed onto the network (write to the socket).<br>
<br>
The MaxMemInQueues parameter basically tells the tor OOM handler when it<br>
is time to start cleaning up allocated memories. But here is the catch,<br>
it only handles cells on circuit queues, not connection's buffer (it<br>
actually handles other things but the majority of allocated data is in<br>
cells usually).<br>
<br>
For that reason, we are better off for now to keep relays with a sane<br>
value for MaxMemInQueues so the OOM is actually triggered before the<br>
load goes out of control.<br>
<br>
If that MaxMemInQueues value is not set in your torrc, tor will pick 3/4<br>
of the total memory of your system. Usually, this is fine for most use<br>
cases but if you machine has 16GB of RAM but only 4GB are available,<br>
problem. So when setting it, it is not that easy to come up with a good<br>
value but a rule of thumb for now is look at how much memory you have<br>
available normally and estimate around it. It is also important to not<br>
go to low, a fast relay limited to 1GB for instance will start to<br>
degrade performance by killing cicuits more often if it sees 20MB/s<br>
(imperically speaking).<br>
<br>
I think we could do a better job at estimating it when not set, we could<br>
do a better job with the OOM, we could do lot more but unfortunately for<br>
now, this is the state of thing we need to deal with. We'll be trying to<br>
work on more DoS resistance feature hopefully in the near future.<br>
<br>
Hope this help!<br>
<br>
Cheers!<br>
David<br>
<br>
><br>
> Do the wise-minds have a guidance on this one?<br>
><br>
> On Fri, 22 Dec 2017 at 21:08 Igor Mitrofanov <<a href="mailto:igor.n.mitrofanov@gmail.com" target="_blank">igor.n.mitrofanov@gmail.com</a>><br>
> wrote:<br>
><br>
> > Thanks. I do have the IP space.<br>
> ><br>
> > It is a pity multiple instances cannot watch the overall RAM<br>
> > remaining. I have quite a bit of RAM left, but there are large<br>
> > discrepancies in terms of how much RAM different relays are using (>3<br>
> > GB for some, <1 GB for others), so it will be tricky to set<br>
> > MaxMemInQueues without making it too conservative.<br>
> ><br>
> > On Fri, Dec 22, 2017 at 11:46 AM, r1610091651 <<a href="mailto:r1610091651@telenet.be" target="_blank">r1610091651@telenet.be</a>><br>
> > wrote:<br>
> > > It would expect it to be per instance. Instances are independent of each<br>
> > > other. Further one can only run 2 instances max / ip.<br>
> > ><br>
> > > On Fri, 22 Dec 2017 at 20:40 Igor Mitrofanov <<br>
> > <a href="mailto:igor.n.mitrofanov@gmail.com" target="_blank">igor.n.mitrofanov@gmail.com</a>><br>
> > > wrote:<br>
> > >><br>
> > >> Hi,<br>
> > >><br>
> > >> Is MaxMemInQueues parameter per-host (global) or per-instance?<br>
> > >> Say, there are 10 relays on the same 24 GB host. Should I set<br>
> > >> MaxMemInQueues to 20 GB, or 2 GB in each torrc?<br>
> > >><br>
> > >> Thanks,<br>
> > >> Igor<br>
> > >> _______________________________________________<br>
> > >> tor-relays mailing list<br>
> > >> <a href="mailto:tor-relays@lists.torproject.org" target="_blank">tor-relays@lists.torproject.org</a><br>
> > >> <a href="https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-relays" rel="noreferrer" target="_blank">https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-relays</a><br>
> > ><br>
> > ><br>
> > > _______________________________________________<br>
> > > tor-relays mailing list<br>
> > > <a href="mailto:tor-relays@lists.torproject.org" target="_blank">tor-relays@lists.torproject.org</a><br>
> > > <a href="https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-relays" rel="noreferrer" target="_blank">https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-relays</a><br>
> > ><br>
> > _______________________________________________<br>
> > tor-relays mailing list<br>
> > <a href="mailto:tor-relays@lists.torproject.org" target="_blank">tor-relays@lists.torproject.org</a><br>
> > <a href="https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-relays" rel="noreferrer" target="_blank">https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-relays</a><br>
> ><br>
<br>
> _______________________________________________<br>
> tor-relays mailing list<br>
> <a href="mailto:tor-relays@lists.torproject.org" target="_blank">tor-relays@lists.torproject.org</a><br>
> <a href="https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-relays" rel="noreferrer" target="_blank">https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-relays</a><br>
<br>
<br>
--<br>
tPcuU+9hl1BRjXh3xHhFgg22HULt2edIxY5kAKLBPPA=<br>
_______________________________________________<br>
tor-relays mailing list<br>
<a href="mailto:tor-relays@lists.torproject.org" target="_blank">tor-relays@lists.torproject.org</a><br>
<a href="https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-relays" rel="noreferrer" target="_blank">https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-relays</a><br>
</blockquote></div>