Do NOT host a server on a Raspberry Pi!
I feel the need to explain to everyone why using a raspberry PI for a server is an
extremely unintelligent and inconsiderate compromise to make over using an old laptop
with a SATA hard drive
. The speed of the CPU is not the bottleneck, the problem is the way that minecraft stores worlds. It creates ‘region’ files (.mcr or .mca) which each store a thousand chunks and these different
region files are each opened as a java.nio.RandomAccessFile. The chunks in these files are in an arbitrary order, they are sorted from the oldest chunk in the region it tried to save to the newest chunk in the region it tried
to save which means the chunks are in a random order that is not cache-friendly. Minecraft constantly seeks through these files completely randomly to deserialize chunks into memory that need to be loaded while simultaneously
serializing other chunks into completely other random parts of the file that need to be saved. It opens multiple files like this all at once and performs these sorts of transactions all at the same time on each file and that
makes them become fragmented within the filesystem itself from slowly and randomly growing over a long period of time while being mixed up with other files that are also slowly and randomly growing over time. All of this messes
up the cache out of it’s randomness, so you end up limited only by the hardware’s speed and only the speed of your specific hardware under the load of random reads and writes is what you will be limited by instead of it’s sequential
read and write speed which is what is always commercially advertised as the ‘speed’ of the SD card you choose.
If you look at this graph of the difference in speed on SAS and SATA and fiber channel HDDs when performing random reads and writes vs sequential reads and writes, the last two columns on average show a maximum of around
a 50% decrease in speed between maximum sequential storage speed and maximum random storage speed (the low and high error margins shown are because of the speed of the disk’s rotation is faster on the outer portion of the platter
than it is near the center so you can compare the low to the low and the high to the high and disregard the low to the high) and this accounts for both reading and writing because the bottleneck on an HDD is mechanical not
Now look at this graph of SD cards, if we focus on microSDHC which is what is most common with the PI, we can see that data columns 3 and 4 describe the speed of random access reads vs random access writes. There are two
PI equivalent microSDHC benchmarks in this table, and both of them get about 11.5 megabytes per second for performing both sequential and random access reads (over around 60MB/s on a HDD). This is only relevant for loading
chunks, when the chunks are loaded they begin autosaving randomly back to the same file based on what chunks change or whatever the fuck else mojang’s chunk storage decides to rewrite chunks for. We can see that both microSDHC
cards have a pathetic random access write speed of only 0.62 megabytes per second, which is 18.5x slower than the random access read speed, and therefore the SD card will be 18.5x slower than already how much slower random
reads were from it’s commercially advertised speed listed when taking a quick glance of the specs on the packaging. Hard drives were only 2x slower, which makes them 9.3x better than microSDHC in terms of the loss of efficiency
between performing random writes compared to random reads while they are also already 6x faster than the SD card at reads in the first place because the data does not have to go over the shared SPI bus which was originally
designed for simple low speed serial packet communication between microcontrollers. If you’ve ever used something like a simple 24 character LCD screen on a PI for some project, you are using the same transistors that will
now have to handle the random access reading and writing of 40+ players on your minecraft server on that same SD card. In total, microSDHC is 6x slower than SATA/SAS/fiber at reads and 108x slower than SATA/SAS/fiber for writes.\
So as cool as you think you are by putting public eaglercraft on a PI, you are digging yourself a debugging grave once you realize your server isn’t saving chunks even though the best buy packaging that you read all the
information you know about your SD card says specs that made you think it might even just work in the first place.