So it seems if I make any kind of post with a reasonably popular search term in the body some fuck-head spammer finds my site and puts up some bullshit comment that then generates a notification email which makes my phone buzz. Thoroughly annoyed at being disturbed I then have to login to the site and moderate said comment, because fucking spammers have no damn lives. If you are reading this and happen to be a spammer do me a favor and quit breathing.
Yet another boring day at the office, so I decided to dust off my Perl book and try to relearn some basic chops in the language and maybe find a good use for it. Unfortunately that was not the case and in the process of getting myself familiar with it I ported some old code I wrote for artificially creating a load on my servers by crunching prime numbers. Its a pretty ghetto piece of code and I’m not sure about its limitations so if it causes your machine to catch fire or start making noises like a dying goat I’m not responsible, actual bad code after the break.
Continue reading “Bored Code: Primes in Perl”
First let me lay out the issue, then I will explain the title. I help manage a small niche site for a community in NYC which I happen to host out of a NearlyFreeSpeech.net account that also is home to a few other projects of mine. So far the numbers show that the site uses the lion’s share of resources available to the account, roughly 20$ every 4 to 6 months to keep the hosting going and I suspect costs will only go up. Faced with figuring out how to head off rising costs before they become an issue I picked the site apart to figure out what was costing the most money and what areas could increase costs in the future.
After a quit poke about the site and looking at the breakdown of the hosting price I found that the two main consumers of money were the MySQL processes and the disk storage. Without showing a bunch of math it would cost $19.68 roughly for the rest of the year provided no more images were uploaded to the site. The current total size of the site is 169 MB, which works out to 1.69$ per month just to store the content irregardless of it being accessed. Each MySQL process runs $0.02 per day, so thats $7.30 per year on top of the cost of storage, working out to a grand total of $26.98 for storage and a single database to run the site; and all of that ignores the cost of bandwidth (NFS.net uses a micro-transaction system for bandwidth charges) and whatever else I might be forgetting.
Now I know anybody out there with serious hosting experience is laughing their ass off that I’m doing a breakdown of such a simple site and what is arguably a very inexpensive hosting setup when compared to major sites, but when the site doesn’t generate any money at all every penny is important. First I looked into Content Delivery Networks used by major websites; it didn’t take me long to realize that such a venture was going to be absurdly expensive for such a small project.
With the big CDN providers out of the picture I started kicking around ideas of a more DIY nature, such as building my own CDN apparatus that I could host out of my home. Naturally this had risks of downtime due to power outages, etc so that ruled out a home brew setup. I started thinking about other places that played the hosting game and how they got it done when it dawned on me, to host images places like Reddit use imgur.com to host their images. Over to their site I went and lo and behold they have an API and pro accounts which don’t limit you to a certain number of hosted images. This was the pay-dirt I was looking for, and now I have a lead on a way to cap the one dynamic cost of the site for a reasonable price that won’t break the bank.