en

Tor Circuit Establishment Time Tuning for Lower Latency

Tor's latency is largely determined by the time to establish a circuit (3-hop path through the Tor network) plus the round-trip time through the established circuit. Circuit establishment involves multiple public key operations across multiple relays and typically takes 2-10 seconds for new circuits. Optimizing circuit establishment time - through configuration of timeouts, relay selection parameters, and guard relay characteristics - can meaningfully reduce the latency experienced by Tor users and hidden service visitors. This guide covers the tuneable parameters that affect circuit establishment time and their recommended values for different latency/security tradeoffs.

Need this done for your project?

We implement, you ship. Async, documented, done in days.

Start a Brief

Circuit Build Timeout Mechanics

CircuitBuildTimeout controls how long Tor waits for a circuit to be established before giving up and trying a new one. The default is calculated adaptively by LearnCircuitBuildTimeout: Tor observes actual circuit build times and sets the timeout at the 80th percentile plus a buffer. This adaptive mechanism normally works well, but can cause issues in certain network conditions. Set CircuitBuildTimeout manually to override adaptive learning: CircuitBuildTimeout 30 (30 seconds; the default adaptive value is often similar). Reducing this value causes Tor to give up and retry circuits faster but increases load on the Tor network from retries. Increasing it reduces retries but makes Tor appear unresponsive when circuits are slow. For low-latency relay operators: set IntroductionPointPublishPeriod (for hidden services) and RendPostPeriod to more aggressive values to reduce the time between introduction point refreshes.

Guard Relay Selection and Latency Impact

The guard relay (entry node) is the most significant determinant of circuit latency: your Tor client always connects through its selected guard relays. A guard relay with high latency to your client location creates high latency for all circuits. Tor selects guard relays based on bandwidth (weighted probability) and stability, not geographic proximity. You can influence guard relay selection by setting EntryNodes in torrc: EntryNodes {US},{DE},{NL} biases selection toward US, German, and Dutch relays (use ISO country codes). Restricting guard selection too narrowly reduces anonymity (fewer relays to choose from). Use this only if geographic proximity is important for your use case and you accept the reduced anonymity set for guard selection.

LearnCircuitBuildTimeout Configuration

LearnCircuitBuildTimeout 1 (default enabled) allows Tor to learn your network's typical circuit build times and set adaptive timeouts. This is beneficial for most users. LearnCircuitBuildTimeout 0 disables adaptive learning and uses the static CircuitBuildTimeout value. Disable adaptive learning only if: you are running in an environment where circuit build times are highly variable and the adaptive algorithm is making poor timeout estimates, or you need consistent, predictable behavior for testing. When adaptive learning is enabled, Tor measures the time to build 50 circuits and computes the 80th percentile, setting the timeout at 1.5x this value. The adaptive value is saved across restarts. If your typical circuits build in 2-4 seconds, the adaptive timeout will be approximately 4-6 seconds.

Hidden Service Circuit Pre-Building

Tor hidden services can pre-build introduction circuits before they are needed. NumIntroductionPoints (default 3, max 20 for high-security services) determines how many introduction point circuits are maintained. More introduction points: more circuit-building overhead but better availability when introduction points are selected by clients. The hidden service automatically rebuilds introduction circuits when they expire or fail. For hidden services with high client connection rates, increase NumIntroductionPoints to 5-7 to reduce the chance that a client must wait for a new introduction circuit to be built. For low-traffic hidden services, the default of 3 is sufficient.

Network Topology Optimization for Relay Operators

Hidden service operators who also run relay infrastructure can optimize latency by placing the hidden service and some relays in the same or nearby data centers. When Tor selects a circuit to a hidden service, some relays in the circuit are selected from geographically proximate relays (for efficiency). A hidden service located in Iceland with entry guard relays also in Iceland will typically see faster circuit establishment times for Icelandic and European clients than a service hosted in a distant location. This is a subtle optimization for advanced operators and should not override security considerations: the hidden service location should be based primarily on privacy and jurisdiction requirements, not latency optimization.

Why Anubiz Host

100% async — no calls, no meetings
Delivered in days, not weeks
Full documentation included
Production-grade from day one
Security-first approach
Post-delivery support included

Ready to get started?

Skip the research. Tell us what you need, and we'll scope it, implement it, and hand it back — fully documented and production-ready.

Anubiz Chat AI

Online