Skip to content

crimist/trakx

Repository files navigation

Trakx

Performance focused BitTorrent tracker supporting HTTP, UDP, IPv4 and IPv6.

❤️‍🔥 Instances

Try Trakx for yourself! These instances are hosted on Oracles always free tier.

Status Protocol Address
✅Ok IPv4 UDP udp://u4.trakx.crim.ist:1337
✅Ok IPv6 UDP udp://u6.trakx.crim.ist:1337
⚠️Deprecated IPv4 HTTP http://h4.trakx.crim.ist/announce
⚠️Deprecated IPv6 HTTP http://h6.trakx.crim.ist/announce

HTTP trackers are deprecated due to TCPs high load. Use UDP trackers for reliable uptime.

🚀 Install

Go 1.19+ required.

git clone https://github.com/crimist/trakx && cd trakx

# install to go bin
go install .
trakx status # generates configuration

# or build
go build .
./trakx status # generates configuration

See configuration and netdata setup.

🔧 Configuration

Configuration file

The configuration file can be found at ~/.config/trakx/trakx.yaml. You'll have to run the trakx controller at least once to generate this file.

Config settings can be overwritten with environment variables:

$ cat trakx.yaml
...
loglevel = error
...

$ TRAKX_LOGLEVEL=DEBUG trakx run
2022-01-16T19:52:25.627-0800    DEBUG   Debug level enabled, debug panics are on
...

Trakx attempts to load the config file from the following directories in order:

  • .
  • ~/.config/trakx/

Default configuration & webserver files

You can modify the default configuration and files served by the webserver in the tracker/config/embeded/ folder.

NOTE: Trakx webserver will only serve files at their full path. dmca will 404, dmca.html will 200.

Binding to privileged ports

To bind to privileged ports I recommend using CAP_NET_BIND_SERVICE. More information can be found here.

$ sudo setcap 'cap_net_bind_service=+ep' ./trakx
$ TRAKX_TRACKER_HTTP_PORT=80 ./trakx run
2022-04-05T16:18:05.847-0700    INFO    HTTP tracker enabled    {"port": 80}

Netdata setup

Warning: install.sh will overwrite go_expvar.conf. If you are using other expvar programs with netdata manually merge the two files.

  • Run /etc/netdata/edit-config python.d.conf, change go_expvar to yes.
  • Customize the url in netdata/expvar.conf if needed.
  • Install netdata plugins with cd netdata; ./install.sh.

Build Customization

Trakx takes advantage of Go's build tags to target different use cases.

Performance

The fast tag will build Trakx without IP, seed, and leech metrics which will reduce cpu and memory usage.

App engines

The heroku tag will build trakx for app engines. This means the executable will immediately run the tracker rather than provide the daemon controller behavior included in the regular CLI build.

Feel free to customize the tags to suit whichever app engine you prefer in engine_entry.go.

📈 Performance

The following metrics were collected on Heroku free tier running an HTTP tracker with the fast tag disabled.

Heroku dashboard:

performance

Database stats:

performance

Flamegraph:

flame

Trakx has been optimized to use a little CPU time as possible. In most cases, almost all CPU time will be spent handing (negotiating/send/recv) connections, especially for TCP (HTTP).

Trakx has also been optimized to use minimal memory and is mostly limited by the go GC. In this example the GC runs every 2 minutes (the forced GC period) at this level of traffic. The inuse_space delta from GC is 7.5% meaning this collection frequency would be sustained at GOGC=8.