Say I set up a server in the cloud as a relay, how can I set it up so I get maximum speed out of the network? And how fast can a Tor-relay get with optimal bandwidth/response time?
As of today, the highest performing Tor node is pushing about 30 MB/s so if you are looking for tips, I'd suggest trying to match what the fastest Tor nodes are doing.
Firstly, choose a good platform. Linux works well, as does FreeBSD. Avoid Windows; while it is possible to get good performance out of Windows it requires a very different programming style to that of Unix and Tor hasn't been optimised for that style.
Of course you will need to turn off any arbitrary limits, such as the
BandwidthRate Tor configuration option, but also the system limits (such as the maximum number of file descriptors, by calling
ulimit -n, as performed by the Debian launch script).
And have a powerful computer – your CPU needs to be able to keep up with your network and Tor requires several cryptographic operations for each cell that gets put on the network.
Most importantly, get a good network connection. Most Tor nodes are limited by their Internet connection's bandwidth so a reasonably low-latency high bandwidth link to a lot of Tor nodes will be necessary to get the best out of your node. Tor needs mostly the same upload and download bandwidth so a symmetric connection is best.
Once you've done all of these, keep an eye on the network and CPU usage and check for bottlenecks. ARM is a useful tool for monitoring a server. Do remember that it will take a long time (maybe a couple of months) for your node to pick up enough users for it to reach capacity.