Friday, November 28, 2014

Running a craftbukkit minecraft server for less than 512MB of RAM

Note: This post is not for those looking to run a server on a Raspberry Pi. There's a lot of guides for that, and you don't need any additional help

If you play minecraft, you probably know how memory demanding this game can be. This is the same with minecraft servers as well, and if you're running craftbukkit with a good amount of plugins involved, you might as well just have sold your RAM sticks to Satan himself.

The problem is, a lot of people like me might not have enough RAM on our systems, but we still want to run one of those fancy community minecraft servers anyway. So what do we do to solve the impossible?

Well in my case, the machine I wanted to run a bukkit server on was a Digital Ocean VPS that I rented primarily to host my website. Unfortunately, my droplet featured only a 512MB memory module and my LAMP package took up a good percentage of that. So that left me with something close to 350MB of memory for anything else.
Having had experience at running heavy bukkit servers on my home desktop before, I knew that if I ever wanted to run a minecraft server off this system, I'd have to come up with a good solution.

If you've done a bit of research prior to reading this post, you'll know that Spigot is an optimized version of craftbukkit for this very purpose. So the first thing I did was simply drop the spigot jar file on my VPS and run this command :

java -Xms192M -Xmx512M -XX:MaxPermSize=128M -jar spigot.jar

Everything loaded up fine, but whenever I connected to it via my Minecraft client, the Java process got killed by the OS. I tweaked around with the Xms and Xmx flags in the command but no matter what, the server process never survived after a player connecting. All I could see was "Killed" before the process exited and I was sent back to the command line.


After lots of searching on Google and posting on forums, I got the same answer everywhere:

I simply did not have enough RAM on my machine. 

Almost ready to give up, I found this post on my VPS company's support forum.
All Digital Ocean droplets came along with SSD drives for hard storage. In that context, the answer made a lot of sense. Even if the java process did use some of my SSD for memory, the fact that they were Solid State Disks, and not regular Hard Disks should reduce the lag issue that arises from this solution by a huge factor.
Turns out, my VPS did not have swap enabled by default, so I followed the guide provided for my version of Ubuntu to set it up.

Once done, I launched the minecraft server, and voila! It's been running ever since, even with a couple of bukkit plugins attached.
So in summary. if you have less memory to run a minecraft server, the most likely solution is to use a swap file/drive along with your system.

Hopefully, this guide has helped you learn some concepts at least if not for directly helping you out with your issue. If you have the time, feel free to drop by my minecraft server. Point your clients to "enkrypt.in" and you should be set.

Friday, November 21, 2014

The new enkrypt.in is here

After more than a year of rigorous development, the new interface is finally out in the open.
Well I'll be honest, the reason it took me so long for this project was because I have a surprising talent for automatically procrastinating. My daily work cycle includes spending the day with the editor in the background, buried by every distraction the internet has to offer; and then pushing code after midnight at a rate that is not recommended for the healthy. I've lost count of how many sleepless nights this website now owes me, but I am indeed glad that it's finally fucking over.


Procrastination wasn't the only thing that held me back though. I did run into a dilemma halfway through the development process. My web host got taken down a couple of months ago (The host was not owned by me), and that's when I realized that I needed a permanent hosting solution instead of migrating from one free host(er) to another.
So now came the issue of retrieving backups from the expired host, painfully shelling out money to buy some new server space, and then configuring it right to host my website (If I ever somehow finished it). Of course, I did finally finish it, but I also bought a sweet VPS for myself from Digital Ocean along the way.

If you haven't noticed yet, my proudest part of enkrypt.in is the way I've made everything dynamic. Page reloads and statically loading content is for wimps. I hand coded most of what you're seeing with the use of barely any plugins. The site design is completely of my creation but I now wish that I'd used some already existing plugins to help me out and save all that work. There's a lot of PHP, a lot more of Javascript and some HTML from me that's holding this place together.
There are still possibly tons of bugs throughout the site even though I think I've smoothed out most issues, so if you're the kind of guy who likes to toy around with fragile, poorly protected webpages for vulnerabilities, then by all means go ahead. But even if you're not, please let me know if you discover a bug, glitch or error that's not supposed to be there so that I can fix it at once.

I again haven't written a blog post in more than a year because I'd promised myself not to, until I'd finished my site since my blog's being integrated into it. So now that that's done, I'll hopefully stick to my new rule: of keeping my content short. (some of my previous posts were way longer than they needed to be), and posting more often.

Well there should be a good amount of content here on this site for you to go through, and hopefully some will interest you. If you like what I've made and think this is neat, there should be some Like, Share and Plus One buttons on this page that I would really thank you for using.