Scalable network servers with libowfat and opentracker
Summary
In 2007 Felix von Leitner proudly reported that The Pirate Bay was switching to opentracker, a BitTorrent tracker that Dirk Engling, alias erdgeist, had written on top of the libowfat library. libowfat comes from von Leitner and contains an abstraction for scalable network servers. At The Pirate Bay, opentracker handled around 17,000 requests per second on four trackers spread across seven machines.
What a tracker does
With BitTorrent, users download files directly from each other. The tracker is the broker: it remembers which computers offer which file and tells new participants. Each request is small, but a large public tracker receives an enormous number of them. This makes a tracker an ideal test of how many simultaneous connections a server can serve efficiently.
libowfat wraps the different mechanisms that operating systems offer for many simultaneous connections, such as epoll on Linux and kqueue on BSD, behind a common interface. That is why opentracker ran both on the developers’ BSD tracker and on Linux at The Pirate Bay. Von Leitner also uses the same library in the gatling web server.
What became of it
The switch showed that carefully written C code can handle very high loads with little hardware. Simple DNS round robin took care of load balancing. The Pirate Bay shut down its trackers at the end of 2009 and then relied on magnet links and the distributed hash table DHT, which works without central trackers. opentracker remained in use for other trackers.
Ideas
- An abstraction layer hides the differences between epoll, kqueue and other mechanisms.
- A tracker only brokers; the actual data flows directly between users.
- DNS round robin distributes load without extra hardware.
Insights
- Real heavy load is the best proof of a library’s scalability.
- Good abstractions make software portable between operating systems without wasting performance.
Facts
- opentracker was written by Dirk Engling on top of libowfat.
- At The Pirate Bay, 17,000 requests per second ran over four trackers on seven machines.
- The Pirate Bay shut down its trackers at the end of 2009 in favour of DHT and magnet links.
References
Remarks
- The Pirate Bay was controversial because of copyright infringements; technically, the case is nevertheless a good example of scalable network software.
Recommendations
- For servers with many connections, use event-driven interfaces such as epoll or kqueue, or a library that wraps them.
- Test scalability under realistic load; benchmarks alone are not enough.
Found a mistake or have something to add? Get in touch.
Links to the original source and the Web Archive open in a new tab.