Hi willy,
i've been running a minecraft server (ip: minecraft.co.in) on an old acer dual core machine running ubuntu 10.04 LTS, since November 2010. its got a 2.0 ghz processor, 2gb ram and a 320gb hdd.
Its not the fastest machine i have (i play on that one ) but it gets the job done. As my server became more popular, a lot of people started complaining of lag. Now, being the good admin i am, i scoured the internetz for a solution, and heres what i came up with.
The two main choke-points were the internet connection and the size of the world. Im getting a new connection right now, so that should solve the internet problem. For world size, there's lots of posts saying that a SSD can improve the server speed. This is because the minecraft map is stored in a HUGE number of individual files for each 'chunk' (16x16x128 blocks) of the world. ATM my world is ~112mb and ~34000 individual files (Here's a MAP). For each player online, the server loads a 40x40 chunk 'Active' region around them, and the balance chunks loaded are dependent on their view distance. The 'Active' region is basically where mobs spawn, trees grow etc. So, for EVERY player, there are a lot of HDD reads and writes that have to take place. This is where an SSD with its blazing r/w speeds comes in handy.
I personally cannot afford a SSD at the moment so i went and did one better, i used a RAMdisk. While the average SSD reads at ~700mbps, a RAMdisk reads at ~1300mbps. (i read these figures somewhere, i dont remember exactly where and they might not be accurate but RAM is a helluva lot faster than any SSD). The disadvantages of a RAMdisk is the volatility of your data, which basically means that if the power dies, your data goes too. This can be avoided with a regular backup and some smart scripting. Ubuntu has a default ramdisk (located at /dev/shm) which takes not more that half your ram. Which basically means that in my setup, i have a 1gb (max) ramdisk, which is more than enough to run my world.
So here's what i did.
Assuming that you have a folder layout like this:
/home/$USER/Desktop/MCSERVER
/home/$USER/Desktop/MCSERVER/world/
/home/$USER/Desktop/MCSERVER/minecraft_server.jar
etc.
Step 1. Move world to permanent storage
Code:
cd /home/$USER/Desktop/MCSERVER
mv world/ world_storage/
Step 2. Link the world to ramdisk
Code:
mkdir -pv /dev/shm/minecraft/world
ln -s /dev/shm/minecraft/world/ .
You will now have a folder called world in you MC directory which is a symbolic link to the folder on the ramdisk.This folder is currently empty, and we will populate it with our modified startup script:
Code:
#!/bin/sh
RAM="/home/$USER/Desktop/MCSERVER/world/"
HDD="/home/$USER/Desktop/MCSERVER/world_storage/"
mkdir -pv /dev/shm/minecraft/world
rsync -r -t -v "$HDD" "$RAM"
java -Xms1024M -Xmx1024M -jar Minecraft_Mod.jar nogui
So when we start the server(even after a power outage), the world gets copied to the ramdisk and then the server starts. We now need to create a script which will copy the world from the ramdisk back to the hdd at regular intervals. Save the following script as saveworld.sh
Code:
#!/bin/sh
RAM="/home/$USER/Desktop/MCSERVER/world/"
HDD="/home/$USER/Desktop/MCSERVER/world_storage/"
rsync -r -t -v "$RAM" "$HDD"
Now all we have to do is add a simple cron job and we're done
This will open the editor to add a cron job. I am saving my files every 5 minutes but you can change that to suit your needs.
Code:
*/5 * * * * bash /home/<your username>/Desktop/MCSERVER/save_world.sh &>/dev/null
That's it... Your Done...
A little advice against griefers: TAKE MULTIPLE BACKUPS
I use Back in Time (available in the repos) to backup my entire minecraft folder every 15 minutes. Its hassle free, lets you restore from multiple restore points and saves only changes into the backup. So if your world is ~20mb and players make changes worth ~1mb, the second backup will not be 21mb but just 1mb, which saves A LOT of hdd space, and game time lost to griefers.
Bookmarks