Most active commenters
  • dahrkael(12)
  • immibis(4)
  • KomoD(3)
  • perching_aix(3)
  • LtdJorge(3)
  • toast0(3)

394 points dahrkael | 75 comments | | HN request time: 2.845s | source | bottom

Hello everyone!

I'm currently in a journey to learn and improve my Elixir and Go skills (my daily job uses C++) and looking through my backlog for projects to take on I decided Elixir is the perfect language to write a highly-parallel BitTorrent tracker. So I have spent my free time these last 3 months writing one! Now I think it has enough features to present it to the world (and a docker image to give it a quick try).

I know some people see trackers as relics of the past now that DHT and PEX are common but I think they still serve a purpose in today's Internet (purely talking about public trackers). That said there is not a lot going on in terms of new developments since everyone just throws opentracker in a vps a calls it a day (honorable exceptions: aquatic and torrust).

I plan to continue development for the foreseeable future and add some (optional) esoteric features along the way so if anyone currently operates a tracker please give a try and enjoy the lack of crashes.

note: only swarm_printout.ex has been vibe coded, the rest has all been written by hand.

1. IlikeKitties ◴[] No.44323687[source]
Now that's neat. The Beam VM sounds like a natural fit for a torrent tracker
replies(1): >>44325777 #
2. desireco42 ◴[] No.44323853[source]
Now this is serious business, congrats on the project! I can see how this is perfect fit for elixir...
3. abrookewood ◴[] No.44323981[source]
Hey congrats on the launch! Can you provide any details on how it runs compared to opentracker? I'm really interested in the performance etc.
replies(1): >>44325738 #
4. jhgg ◴[] No.44324011[source]
Really cool! You looking to write Elixir as your main job?
replies(2): >>44325781 #>>44325832 #
5. bavell ◴[] No.44324013[source]
Very cool! Is this suitable for using as a private tracker?
replies(1): >>44325770 #
6. toomuchtodo ◴[] No.44324125[source]
Awesome work!
7. s-mon ◴[] No.44324145[source]
Love Elixir so much, building a kick-ass notification engine with it now. Its so so good.
replies(1): >>44324218 #
8. mikehostetler ◴[] No.44324211[source]
really cool project! well done
9. mikehostetler ◴[] No.44324218[source]
nice, private or OSS? Elixir needs a better notification engine badly
replies(1): >>44324976 #
10. voicedYoda ◴[] No.44324351[source]
Well done. Couple quick notes, move to a logger instead of using IO.puts. Also consider adding OTel.
replies(2): >>44324394 #>>44324623 #
11. guywithahat ◴[] No.44324377[source]
There's something about C++ developers that makes them love Go and Elixir (and I include myself in this demographic). I think it's something about the people who are attracted to C++ for performance are attracted to Go/Elixir for its multithreaded performance. Really cool project
replies(2): >>44325213 #>>44327577 #
12. quechimba ◴[] No.44324380[source]
Nice! I'll check this out some point.

I wrote a basic tracker in Elixir a few years ago, here's the code: https://github.com/aalin/mr_torrent

replies(1): >>44325755 #
13. ai-christianson ◴[] No.44324394[source]
What's your favorite otel sink?
14. arthurcolle ◴[] No.44324427[source]
Check out https://github.com/sergiotapia/magnetissimo it was a popular one like 7 years ago
replies(1): >>44324855 #
15. vivzkestrel ◴[] No.44324563[source]
- how did you start - did you refer to other projects - how long did it take - how much functionality do you think works compared to say qbittorrent?
replies(2): >>44325049 #>>44325860 #
16. solid_fuel ◴[] No.44324623[source]
I'll second this, just using the built in Logger [0] and Telemetry [1] applications would be fine, opentelemetry or anything else can be added to the telemetry hooks easily to export the metrics later.

[0] https://hexdocs.pm/logger/1.18.4/Logger.html [1] https://hexdocs.pm/telemetry/readme.html

replies(1): >>44325746 #
17. KomoD ◴[] No.44324803[source]
I tried it, couldn't get HTTPS to work.

Also my console gets spammed with:

04:43:20.160 [warning] invalid 'event' parameter: size: 6 value: "paused"

but it seems to work. I would've liked to see HTTP stats too but I guess UDP is fine (though I have it disabled)

replies(2): >>44325719 #>>44325803 #
18. KomoD ◴[] No.44324855[source]
That's not a bittorrent tracker.
replies(1): >>44325012 #
19. nayuki ◴[] No.44324880[source]
Similar to: https://news.ycombinator.com/item?id=44265851 "Show HN: I wrote a BitTorrent Client from scratch" [2025-06-13], https://github.com/piyushgupta53/go-torrent-client
replies(1): >>44325045 #
20. rhgraysonii ◴[] No.44324976{3}[source]
What do you mean exactly? If you need a notification engine, reaching for a pubsub implementation is very easy with phoenix’s popularity and quite battle tested. I’ve implemented notifications at scale a few times in the ecosystem. What problems are you encountering that you don’t feel you have a tool in the shed to work with in this case?
replies(1): >>44324986 #
21. rhgraysonii ◴[] No.44324986{4}[source]
And if you wanna buy over build, check out https://knock.app - also built in elixir
22. lionkor ◴[] No.44325045[source]
No that's a client
23. lionkor ◴[] No.44325049[source]
it's a tracker, not a torrenting client.
replies(1): >>44325338 #
24. uncircle ◴[] No.44325213[source]
Not sure about C++ devs, but Erlang/Elixir are great to handle parsing of protocols, with its implementation of pattern matching. Also, makes the code much cleaner because pattern matching basically eliminates most branching and thus depth of the code base.

The let it crash philosophy allows you to ignore most corner cases with the knowledge that, if they are encountered or a cosmic ray flips a bit, the crash is localised to a single client. I have worked with Elixir almost a decade at this point, and I have never seen an unexpected downtime of the apps I deployed. Aside of maintenance and updates, they all have 100% uptime. How cool is that?

This is how I sell it to clients. “Will you be using Python, Go?” Me: “What about Elixir and the promise that your service won’t ever crash? And you get cool dashboards with it.” Them: “Sold.”

I wish there was a systems language that allows you to pattern match on structs and enums, and in function signatures like Elixir

replies(3): >>44325678 #>>44326953 #>>44331527 #
25. NooneAtAll3 ◴[] No.44325338{3}[source]
what does tracker mean?
replies(1): >>44325368 #
26. devoutsalsa ◴[] No.44325368{4}[source]
A torrent tracker is basically the world’s most antisocial matchmaking service that knows who has what files but refuses to actually store anything itself, like that friend who always knows where the party is but never hosts one. When your BitTorrent client asks “hey who’s got that Linux ISO,” the tracker dumps a list of IP addresses faster than a startup pivoting after their Series A falls through. Your client then connects to these strangers (seeders with complete files and leechers still downloading) and starts exchanging data while the tracker pretends nothing happened. It’s like Tinder but for file sharing, except everyone’s anonymous and probably downloading something weird at 3am.
replies(1): >>44325509 #
27. arch-choot ◴[] No.44325462[source]
Interesting! I'd done something similar in Typescript to learn more about BT, and then redid it in rust to learn rust (https://github.com/ckcr4lyf/kiryuu).

However I decided to just use redis as the DB. It sounds like your entire DB is in memory? Any interesting design decisions you made and/or problems faced in doing so?

(My redis solution isn't great since it does not randomize peers in subsequent announces afaik)

replies(1): >>44325659 #
28. vjerancrnjak ◴[] No.44325509{5}[source]
not anonymous at all, while interacting with the tracker can be done with https, all of the communication between peers is unencrypted.
replies(2): >>44325642 #>>44326328 #
29. dahrkael ◴[] No.44325659[source]
in my case using the in-memory ETS has been the best decision, it lets me read&write the peer's data concurrently each on its own process so contention and latency are minimal. the only sequential part is when a new swarm is initially created but that doesn't happen a lot so its fine. there's sadly no native support for taking random rows directly from the tables, so for now i grab the whole swarm and then take a random subset (https://github.com/Dahrkael/ExTracker/blob/master/lib/ex_tra...)
replies(1): >>44330601 #
30. dahrkael ◴[] No.44325678{3}[source]
Indeed. when your daily job is tracking down memory stomps, deadlocks, invalid pointers and unexpected state in very big codebases then using Elixir feels like "why is this so easy? it just works?". Also i'm a network programmer so the binary pattern matching is very much appreciated.
31. bill876 ◴[] No.44325719[source]
The "paused" event is part of BEP 21. Clients send it to the tracker to let it know that the client is still incomplete, but won't download anymore. For example, because a user only wants some files from the torrent. Readme of the project shows that support for BEP 21 is not implemented.
replies(1): >>44327185 #
32. dahrkael ◴[] No.44325738[source]
For small trackers opentracker is probably faster and use a bit less memory. Where extracker is gonna shine compared to it is when core count starts having 2 digits. I still have to do a proper benchmark though.
33. dahrkael ◴[] No.44325746{3}[source]
I use Logger through all the project except for the table pretty print. Telemetry is optionally available in prometheus and html formats: https://github.com/Dahrkael/ExTracker/tree/master/lib/ex_tra...
34. dahrkael ◴[] No.44325755[source]
interesting! why did you decide on a private tracker specifically?
35. dahrkael ◴[] No.44325770[source]
not out of the box but it can be done. All the required moving parts are there (hash whitelist support, udp path parsing, peer rejection, etc).
36. dahrkael ◴[] No.44325777[source]
I feel like ETS has been the real killer feature to pull this, being able to concurrently read and write from protected tables makes the whole thing incredibly parallel
37. dahrkael ◴[] No.44325781[source]
It's one of my options yes, I'm sure I would enjoy it more than C++.
38. dahrkael ◴[] No.44325803[source]
Telemetry for the HTTP side is in my ToDo list yes, since I'm using a 3rd party library for the webserver I still need to figure out how to do it right. For HTTPS to work you need to provide a valid certificate path in :https_keyfile but right now I would recommend sticking Caddy or Nginx in front of the tracker if you want HTTPS. I have certbot integration planned but is not a priority since most of the torrent peers use UDP.
39. pdimitar ◴[] No.44325832[source]
Not OP but I am working with Elixir for 9 years and 2 months now. Know Rust and Golang as well. You hiring?
40. dahrkael ◴[] No.44325860[source]
I started because I needed a tracker for another project but the tracker turned to be more fun to make. I did glance over other trackers code but their code tends to be either overly complex or too simple so not very useful. So far its been 3 months of revenge bedtime procrastination. While this is not a client like qbittorrent I have ideas for a seedbox-oriented client project in the future.
41. nesarkvechnep ◴[] No.44326028[source]
I really wished to see an OTP-first design. Unfortunately for me, the code is almost procedural as it's touching ETS or Application, which is built on ETS, in nearly every operation.

If the author wishes to learn how to design services in Elixir, or any BEAM language, with OTP, they can take a look at "Designing Elixir Systems with OTP" by by James Edward Gray and Bruce Tate, and "Functional Web Development with Elixir, OTP, and Phoenix" by Lance Halvorsen.

replies(5): >>44326242 #>>44326931 #>>44330044 #>>44334192 #>>44338003 #
42. dahrkael ◴[] No.44326242[source]
On my first try I did write it in a more OTP-y style but the scaling potential for this very specific flow is just not the same. In the end a torrent tracker is just a specialized database and handling the data as fast as possible is the top objective. That said I'll give the books a go.
replies(1): >>44327623 #
43. immibis ◴[] No.44326328{6}[source]
There's an optional encryption extension, with no BEP because the BitTorrent company (which issues BEPs) is ideologically opposed to encryption.
44. salviati ◴[] No.44326931[source]
If, like me, you don't know what OTP means in this context, here it is:

OTP stands for Open Telecom Platform, although it's not that much about telecom anymore (it's more about software that has the property of telecom applications, but yeah.) If half of Erlang's greatness comes from its concurrency and distribution and the other half comes from its error handling capabilities, then the OTP framework is the third half of it.

https://learnyousomeerlang.com/what-is-otp

45. Thaxll ◴[] No.44326953{3}[source]
"The let it crash philosophy allows you to ignore most corner cases"

This is such a dangerous take. Also Elixir is not strongly typed, so...

replies(1): >>44327350 #
46. KomoD ◴[] No.44327185{3}[source]
> Readme of the project shows that support for BEP 21 is not implemented.

Ah, missed that.

47. ricketycricket ◴[] No.44327350{4}[source]
It's not though. Processes can be supervised and crashes can just lead to "restart with good state" behavior. It's not that you don't try handling any errors at all, you just can be confident that anything you missed won't bring the system down.

And Elixir is strongly typed by most definitions. Perhaps you mean static?

replies(1): >>44329274 #
48. eatbitseveryday ◴[] No.44327376[source]
Trackers are not relics - they're used exclusively in private tracker websites. Public-access torrents would more commonly use DHT and PEX for discovery.
replies(2): >>44327580 #>>44331040 #
49. TheJoeMan ◴[] No.44327403[source]
Could you please clarify what DHT and PEX are? I'm having trouble searching "tracker PEX".
replies(2): >>44327470 #>>44328225 #
50. yesco ◴[] No.44327470[source]
- https://en.m.wikipedia.org/wiki/Mainline_DHT

- https://en.m.wikipedia.org/wiki/Peer_exchange

51. ◴[] No.44327577[source]
52. ◴[] No.44327580[source]
53. throwawaymaths ◴[] No.44327623{3}[source]
using ets is fine.
54. atmosx ◴[] No.44328225[source]
DHT (Distributed Hash Table) and PEX (Peer Exchange) let torrent clients find peers without centralised trackers. Hence, you don't need a central place / public tracker anymore
replies(1): >>44328273 #
55. Thaxll ◴[] No.44328273{3}[source]
You still need a central server though...
replies(2): >>44328943 #>>44328959 #
56. perching_aix ◴[] No.44328943{4}[source]
Yes, they just don't track the individual torrents anymore. They only play a role during the initial peer discovery stage (bootstrapping). Peers find torrent swarms on their own, the bootstrap servers are excluded from all that.
57. LtdJorge ◴[] No.44328959{4}[source]
If you are connected to the DHT network, you don’t. Unless you mean for DNS and such.
replies(1): >>44328985 #
58. perching_aix ◴[] No.44328985{5}[source]
No, they mean specifically that in order to connect to such a network, you need to hit some specific central nodes first.
replies(1): >>44329166 #
59. LtdJorge ◴[] No.44329166{6}[source]
The bootstrap nodes. But those don't _need_ to be centralized, even if they have historically been to some degree. There coul be millions.
replies(2): >>44329242 #>>44334328 #
60. immibis ◴[] No.44329242{7}[source]
If there are millions of bootstrap nodes, how do you find them?
replies(2): >>44330143 #>>44331791 #
61. immibis ◴[] No.44329274{5}[source]
You can be more confident. But remember that time an Ericsson switch crashed upon handling a message that it sends to adjacent switches every time it restarts? That crashed the whole network, and you could still do that in Erlang.
replies(1): >>44414148 #
62. Zarathu ◴[] No.44330044[source]
Out of curiosity, what would an "OTP-first" design look like?

ETS is built into OTP, so how is using ETS not "OTP-first"? What's wrong with using ETS? It's just an in-memory store.

I looked through the code and didn't find it to be anywhere close to procedural in style.

63. toast0 ◴[] No.44330143{8}[source]
If they listen on a well known port, and there are millions, send out a few thousand probes to 'random' IPv4 addresses and you'll most likely find one.

If you get and keep a list of bootstrap nodes when you find one, then you can random select from the bootstrap addresses rather than all routable IPv4 addresses.

replies(1): >>44331766 #
64. toast0 ◴[] No.44330601{3}[source]
I don't remember if there's a way to see how many slots an ets table has, but if you're ok with imperfect distribution, you could maybe pick a slot at random and use ets:slot/2 to get all the items in that slot, then select from those.

You might be able to get the slot count from eta:table_info(Table, stats), although that's not intended for production use, so the format may change without notice.

65. dewey ◴[] No.44331040[source]
But also private trackers are far from popular these days. Even if I’m a heavy user, but I know it’s a niche.
66. sea-gold ◴[] No.44331527{3}[source]
Maybe look into Inko[1]. It is has good pattern matching (but perhaps not on function/method signatures).

[1] https://docs.inko-lang.org/manual/latest/getting-started/pat...

67. immibis ◴[] No.44331766{9}[source]
What's your IPv6 plan?
replies(1): >>44332037 #
68. LtdJorge ◴[] No.44331791{8}[source]
You can embed them in the torrent, same as the tracker. But the tracker has to handle all the state, while a bootstrap node just hooks you up with a few (or one) node in the DHT network. After that, it's fully decentralized.

There could other ways, embedding them on SRV DNS records, etc. It's the same issue as with getting a DNS server. You could in theory get addresses of bootstrap nodes from your ISP through DHCP (lol, sure).

69. toast0 ◴[] No.44332037{10}[source]
Probing IPv6 would be pretty difficult. You could make some assumptions that might hold, like assume only the lowest /64 out of a /48 is used and ::0 or ::1 for the end of the address. Likely you'll still need too many probes to be feasible.

You'd need to probe v4 space through NAT64 and exchange v6 addresses after that, or include a cache of viable v6 addresses with clients. That gets you close to centralized service again, because how do you get the viable addresses to distribute with the client? Probably by running a supernode and dumping the list of supernodes into the client source every so often; but starting off with just that node listed.

70. andyleclair ◴[] No.44334153[source]
This is really good, my dude. I took a peruse through the code and I'm definitely impressed, this is like, code I would expect my senior engineers with elixir experience to turn in. Great job!
71. andyleclair ◴[] No.44334192[source]
Building a BitTorrent tracker out of GenServers makes zero sense. ETS is the correct choice to make here 100% (for a single server configuration). Obviously it doesn't scale horizontally but it will scale vertically to the moon and chances are, yagni anyway
72. perching_aix ◴[] No.44334328{7}[source]
You still need to have a list of a subset of them, and you just have to trust they connect you to the "same network", to the extent that even makes sense, no?
73. lawik ◴[] No.44338003[source]
A lot of the glory of Elixir and Erlang are in that you can write code that is very straightforward but performs well.

There may be cool cases for extra GenServers or gen_statems but a lot of uses of Elixir and Phoenix don't warrant making any fancy architectural choices. Partly because the runtime is already fancy for you.

74. uncircle ◴[] No.44414148{6}[source]
“Remember that one time that software crashed?”

The fact that you recall a single instance of crashing software says a lot about the quality assurance of the BEAM.