Know your limits

I’d like to talk to you for a moment about the web hosting industry, and dirty tricks therein.

Pretty much anyone who takes their web sites seriously has a preferred shared web hosting company. I’ve made no secret about my current fave, A Small Orange (blatant referral link); their uptime is decent, their tech support is fast, and they don’t nickel-and-dime you on things like domain name aliases or SSH access. However, though I think they’re well worth the money, they’re not the cheapest company in the game, so I won’t be surprised if those of you looking for a host pass them by for a cheaper company.

Let me back up and explain a bit about what you’re getting when you buy web hosting. You’re buying the ability to upload files on to a company’s server, which will then serve those files to the web (possibly after processing them first if they’re scripts written in PHP, Python, etc). When this happens, you are consuming three resources of the hosting company: the disk space to store the files you have uploaded; the bandwidth to serve those files to others; and the computer processor time it takes to process and serve your files.

I won’t talk about the processor time issue, because with modern servers and well-written software, it’s usually not an issue. Let’s talk about the disk space and bandwidth aspects.

Many web hosts, like A Small Orange, offer a range of plans which allot you a certain finite limit of disk space and bandwidth; the server won’t allow you to create or upload any more files if you go over the disk space limit, and you’ll be charged a per-gigabyte fee if you go over the bandwidth limit. However, an increasing number of web hosting companies, including my former fave DreamHost, offer a single “unlimited” plan, where all of their customers pay a single flat monthly fee, and can use as much disk space and bandwidth they need.

…Or can they? The servers that are hosting their customers’ sites clearly don’t have unlimited resources, so how can they sell that? Well…

Think of it this way. Imagine you go to an all-you-can-eat buffet for breakfast. But you bring a book, and after eating breakfast, you stick around until lunchtime. Then you eat lunch. Then you maybe break out a Nintendo DS or something and hang out until dinner. Then you eat dinner. Then you crash in a booth overnight and eat breakfast the next day… Well, eventually somebody’s going to catch on and ask you to leave, right? What they really mean when they say “all you can eat” is “as much as most people who aren’t training to be yokozuna could be expected to eat in a single meal.” I don’t think very many reasonable people would argue otherwise.

Well, this is how “unlimited” hosting plans work. In reality, hosting companies know that their average customer will use this much disk space and this much bandwidth, and they allocate customers to their servers accordingly. Now if they have a couple customers who are using notably more than average, it’s okay, because they can probably find a few customers who are using notably less than average and put them on the same servers so that they balance each other out.

However, if your site becomes incredibly popular (may you - and I - ever have such a problem) and it’s suddenly using astronomical amounts of server resources, you’re going to find out that those “unlimited” plans do indeed have their limits. It’s quite likely that your account will be closed and your site taken offline. The internet abounds with stories of unlimited hosting plan customers who have had this happen to them. And it’s not exactly a secret; if you read the fine print of an unlimited hosting plan, it’ll probably say something about how they reserve the right to shut your site down if it’s using more than its fair share.

So, “unlimited” hosting plans do have bandwidth and disk space limits, just like my A Small Orange plan does. The difference is that I know what my limits are, whereas those on unlimited plans don’t know what theirs are until it’s too late and their sites are taken down. (I’m on ASO’s $10 a month plan, which currently offers 1000MB of disk space and 25GB of bandwidth monthly; I’ve hit up against the disk space limit occasionally when I’ve been experimenting with stuff and not cleaning up after myself, but I’ve never come close on the bandwidth allotment.) And furthermore, if I ever go over my bandwidth limit, it’s in ASO’s best interest to keep my site online as much as possible, so that they can charge me the 50¢-per-gigabyte overage rate.

So the next time you see an offer for an “unlimited” hosting plan, think of it as an “unknown and possibly arbritrary limits” plan and let it pass by. Stick with companies that lay out all the details of their plans in front of you and don’t hide their intentions in fine print.

Recent projects

I can’t think of anything more interesting to blog about on this lazy Sunday afternoon, so let me talk about what projects I’ve been hacking away at recently.

With rapidity that surprised even me, I was accepted to be a maintainer of the markItUp! module for Drupal. This module adds the markItUp! editor to text areas, which adds a row of buttons for operations such as making text bold and such - but it’s not WYSIWYG; clicking a button just alters the text in whatever markup system you choose (Markdown, BBcode, etc) to have that property. It’s a nice middle ground; the ease of use of a WYSIWYG editor, but without the crappy code.

I ended up refactoring the entire module; there were some hoops to jump through before I got it usable. I initially wanted it to work on all text areas which allowed styled text, including those created by CCK and such, but due to the way markItUp! currently works, it’s not too happy about working with more than one textarea at a time, particularly if you want to be able to change the “sets” (buttons) it’s using depending on which input format is selected and such. But eventually I got to where I was happy with it and released it as a 2.0 dev release. I may have also screwed up the original 1.0 dev release while I was at it; the jury’s still out on that. Argh, I hate CVS.

I’m also still hacking away at Ubercart Auction in between waiting for folks to get back to me on other projects and such. I recently added an optional submodule which allows people to “Buy Now” auctioned products. Implementing this properly required reworking a lot of the guts of the original module, but it’s better than ever now. The client was originally hoping to go live with this site this month, but it’s looking like that might not happen; they haven’t got back to me on it. Oh well. I hope to shore up the Views support in the future.

Also, as you may have seen in the “ego menu” there on the right, I recently started a new site called Yen Plus Info. It’s intended to be a database of the people and comics featured in Yen Plus, a new monthly comics anthology which features Japanese, Korean and domestic comics - a nice blend of genres which offers something for everyone, really. I’ve never been much of a comics geek and never thought I’d start a site like this… it was an afternoon project which turned into a weekend project which turned into a “well, I’ve got this far; might as well finish it” project. I ended up getting it done all with contributed modules; not counting the template (which prominently features my spartan, text-heavy design style; IANAartist), I didn’t write any custom code to get this up and running.

I’m also moving forward on another clients’ site which I can’t quite reveal at this moment which makes heavy use of Domain Access. It’s going to be quite cool; so cool that I’m going to do a write-up of it and see if I can get it on the front page of Drupal.org. Domain Access is an amazing system; mad props to Ken Rickard for making this possible.

Finally, I’ve been considering finally getting back to work at the transition of SigFeeder to Drupal. I actually got pretty far on this over the summer, if I recall correctly, but then I just kinda stopped working on it for whatever reason and never got back to work on it.

Getting my vein tapped

BloodmobileLast night at around 7:00 PM I received a call from the local blood bank reminding me that I was able to donate again, and that a “bloodmobile” would be in the city park walking distance from my apartment the next day.

This would be my third time giving blood. It’s something I’ve always wanted to do, because I’ve always known how helpful it can be. But for whatever reason, cowardice kept me from doing it until my first time a few months ago. Needles are needles, and needles are scary. But finally one day I knew it was something that had to be done, so I did some research on what to expect, and then finally just did it.

And they’ve been asking me back every eight weeks since. It turns out my blood type is O Negative, which makes me a “universal donor;” my blood can be accepted by anyone. However, the other types of blood are incompatible with each other in varying ways. So they like to get as much as my kind of blood as possible.

After my first donation, I was sent a donor card with a barcode. By scanning the card, they don’t have to ask me a bunch of personal information that they already have on file. Some information, however, is always re-asked; have I ever taken any drugs on this particular list, am I currently taking antibiotics, have I been engaging in any risky sexual behavior, have I been overseas in the last three years - that one, for a few months more at least, I still answer yes to and explain my stay in Japan. Previously, this questionnaire is done with checkboxes on a sheet of paper, but on this newer high-tech van - “M1, but we call it M-wonderful,” said one of the nurses; the other two are smaller and apparently older - it was done with a tablet PC. This wasn’t much of an improvement, though, as questions appeared one-at-a-time on the tablet and there was about a two-second lag time between questions, so it took more time than simply quickly checking boxes on a form.

A nurse then took me in a closed room and verified my answers. Once all that is cleared, she pricks my finger and takes a small blood sample, putting it in a thin glass tube which then goes into a centrifuge for a moment. The centrifuge separates all the various gunk in my blood which allows her to check to make sure it’s all in correct proportions. She also checks my pulse and blood pressure.

Once I clear all that, it’s back into the main body of the van to choose an arm and a chair. My left arm seems to be the good one, with a nice thick vein close to the skin on the inside of my elbow. The nurse sits me in a reclined chair with a rest for my left arm. She asks me my name and date of birth as one final confirmation that I am who I say I am. She gives me a rubber ball to squeeze to really make the vein pop, then marks its location on my skin with a marker. (This is the part where I start to get kind of spooked - the anticipation of the poke.) Another nurse hands her the bag and tubes which will collect my blood, which she drapes over my arm for convenience. She rubs the area thoroughly with a swab of some cootie-killer whose name I can’t recall, and then… I close my eyes and try to calm myself as the needle slides into my skin and vein.

My arm being drainedBefore the blood flows into the big bag, she collects some in test tubes, presumably for testing for disease before my blood is used. Both these tubes and the bag are given matching barcode stickers. Then, by closing some tubes and opening others, the blood starts to flow into the big bag, which will hold about a pint (half a liter) when full. The bag is placed on a scale which is out of sight from where I’m reclining.

Filling the bag takes about five or six minutes. It’s a bit of a weird experience. You know what’s happening, because you can see the tubes coming out of your arm, full of your dark red life-stuff; but you don’t really feel it going out or anything, just a little pinch of your arm where the needle is. I pass the time chatting with the nurses, and am pleasantly surprised when I ask one if she’ll take a picture of my arm with the tubes coming out of it and she does so, resulting in this great shot.

The scale holding the bag of blood beeps as the bag gets near full, then beeps faster after it’s full. The nurse clamps the tubes shut and removes the needle. She uses special pincers to squeeze all the blood left in the tubes into the bag, then seals the bag shut. She has me place gauze over the hole in my arm and raise my arms for a few moments as she does this. Finally she checks my arm to confirm that I’m not leaking, then puts on some fresh gauze and a bandage. (She offers me to choose the bandage color; when I say I don’t care, she reaches for the rolls of bandages behind her without looking and randomly grabs the red one.) I’m instructed to not skip meals or do strenuous exercise for the next couple of days and sent to the back of the van. I grab half of a vaguely banana-flavored muffin from the counter and a tropical punch juice box from a cooler. After a little chit-chat, I start heading home.

A bag of blood!Some people who give blood apparently feel dizzy or even faint afterwards; for me so far, it’s been more like brief moments of feeling stunned, like when I’ve gone too long without sleep. I experience this for a moment while walking home; I slow down my pace and make it home in one piece. At home, my arm is a little sore and it kind of feels like time is passing faster than normal (what? It’s almost 8:00 already?), but I’m doing okay.

I take the pictures off my new camera’s memory card, post them on Flickr, and post this article on my blog.

Folks, every day in the world, there’s a certain number of people who have a Really Bad Day. Donating your blood to them can make their day a little better. It’s safe (if a little scary) and typically takes less than an hour of your time every eight weeks. Don’t be an idiot like me and put it off; start now and do it often. Do some research, then check your local phone book or ask around about donation organizations in your area.

See this Flickr set for more and full-sized photos. This is my first time using Flickr… not bad.

Macworld 2009 new toys: my thoughts

iLife ‘09: It looks like iMovie ‘09 is fixing some of the “dumbing-down” that occurred with the previous verison. I don’t do much with DV nowadays, but I would be interested with giving the new iMovie a try. The interface - with those weird pop-up menus - is wandering into dangerously un-Mac-like territory, though. Hmm.

As for iPhoto, I never really did use it, but the new features for geotagging and Flickr and Facebook export look cool. The face recognition is… a little creepy, I think. Can it work with pets, I wonder? Or how about children that have grown into adults?

GarageBand’s new tutorials look cool, but I can’t help but wonder if they’re more gimmicky than useful. I’ll keep an eye on reviews, and if they’re positive, maybe I’ll pick it up and give learning the guitar one more try.

iWork ‘09: Evolutionary steps. Nothing too exciting in my opinion. I wonder how iWork.com works? Are they PDFs?

17” MacBook Pro: Lust-inducing. However, I’m not too hot on the non-replacable battery idea, even if it does last for eight marketing-hours (six and a half human-hours, maybe). I’m currently having problems with my 15” MPB’s battery; it only lasts about five minutes, and when it empties out, it powers off hard instead of going to sleep. Seventeen-inch laptops are a bit too big for me, though - not to mention expensive.

New iTunes stuff: No DRM! Yay! I already upgraded everything that iTunes would let me to the DRM-free versions. The lack of DRM is one of the reasons I’ve been heading to Amazon’s music store first instead of the iTunes store recently.

Staggered pricing! Um… yay? I guess this is something that had to be done in order for the music companies to let Apple sell DRM-free music, but, well… nobody likes paying more. They’re saying that significant chunks of the library will use the cheaper 69-cent rate, though. Well, we’ll see.

Phil Schiller: I’m watching the live restream of the show. Phil kinda looks like my dad, and I think he’s doing a good job. If Apple reverses their decision to not come to Macworld any more - and I think they should - I think he’ll do a competent job of keynoting in the future.

Running FreeBSD 7 in VMware Fusion 2

UPDATE (10 March 2009): I can’t get networking to work in FreeBSD 7.1 in Version 2.0.2 of VMware Fusion. I’m not sure if this is due to a change in VMware Fusion, which for some reason changed its interface quite a bit in an +x.y.1 release and possibly changed some behind-the-scenes things as well, or due to FreeBSD 7.1. Arg.

As promised, here’s a write-up of how I got VMware Fusion 2.0 and FreeBSD 7.0-RELEASE to play nicely with each other - or at least as nice as I could hope, I guess.

This guide is going to assume you are familiar with, or at least willing to learn as you go, the following things:

  • How to use the FreeBSD installer. (It isn’t really that difficult; not quite in line with some of the easier Linux distributions, but far from rocket science too.)
  • How to install stuff in FreeBSD, using either ports (which downloads source code, applies FreeBSD-specific patches and compiles it on your system, or its packages collection (which downloads and installs pre-compiled software). In my case, I used the ports system whenever possible because I am under the delusion that compiling software on your own machine makes it run significantly faster.
  • Basic use of the Unix command line interface; navigating directories, running applications, mounting disks, using an editor, halting and rebooting, etc. Also, Unix concepts such as home directories, users and groups (especially root), etc.
  • If you wish to run X, you should know how to start and configure that, as well as what it is in the first place.

If you need to catch yourself up on any of this, don’t forget the incredibly handy FreeBSD handbook. Most of what I’ve learned to get this working came either from that handbook, or this handy thread on VMware’s forums.

There’s no shame in screwing up and starting all over. In fact, one of the great things about VMs is that doing this is much easier than it is with real hardware. So experiment! You can’t delete VMs from within the VMware interface (grr), but you’ll find all their data in single individual files in the “Virtual Machines” folder in your Documents folder. Deleting them in the Finder will cause VMware to remove them from its “Library” window.

Finally, the stuff below worked for me. I can’t really guarantee that it’ll work for you. If you have questions or problems, feel free to post in the comments, but don’t expect me to be of much help - I’m still a n00b at VMware, and almost as much as a n00b at FreeBSD. Also comment if you think I’ve left something out - I’ve tried to remember everything and put it all in the right order, but I am just slightly short of the perfect human being. That said, let’s get started, shall we?

Step 0: Print these instructions

If I may be so bold, I recommend you print this web page. Why? Because to switch back and forth between your web browser and VMware, you’re either going to have to press Command-Tab (the standard OS X app switching key command) or Control-Command (which tells VMware to let the Mac have input focus back instead of the VM). And, as I whined in my previous post, VMware Fusion seems to send a press of the Escape key to the virtual system when you press the Command key on your real one. This may result in you backing up or exiting out of things accidentally, especially when using the FreeBSD installer. I’ve tweaked my site’s stylesheets to be more printer-friendly just for this article, so go kill a tree.

Step 1: Download a FreeBSD disk image

You should get the amd64 version - your Mac does not have an AMD processor, but it is 64-bit, and “amd64” is sort of shorthand for a 64-bit PC-compatible processor regardless of manufacturer. I also recommend getting the “bootonly” disk image, which just boots the FreeBSD installer but downloads all the stuff it will install as it installs it. The full disk images can take a long time to download, and this way you’ll save time by making sure that you’re only downloading the parts you really need. (The rest of this guide will assume you are taking this advice.)

Step 2: Set up a virtual machine

Start up VMware. When you see the “Virtual Machine Library” window, click the “New…” button. When it asks you for an operating system, select “Other” from the “Operating System” menu, then “FreeBSD 64-bit” from the “Version” menu. The other options should be self-expanatory (though make sure you’re allocating enough disk space to your VM now; increasing its size later will be a painful process). Once you get to the “Finish” screen, uncheck the “Start virtual machine and install operating system now” check box. Select the “Use operating system installation disk image file” radio button, select “Other…” from the menu below it, then navigate to the ISO file you downloaded in the previous step and select it. Click “Finish.”

Now you’ll be back at the “Virtual Machine Library” window. We didn’t want to immediately start the VM because there’s one more step I recommend doing before you fire it up; select your new VM and click the “Settings” button. From the list on the left, select “Processors” (expand “System Hardware” if you don’t see it), and set this setting to as high as it will let you set it. By default, it’ll only tell your virtual system use one of your processors (or cores). This is great if you want to make sure your Mac outside of the VM always has at least one processor to work with, but you might as well let your VM use as much power as it needs, especially if you’re going to be compiling ports.

OK out of the settings pane and head back to the “Library” window. Click “Run” and your new VM will fire up and start booting from the FreeBSD disk image.

Step Somewhere In Between: Networking, yay!

Accessing the internet with FreeBSD, both when you’re booting from the disk image and when you’re running your VM straight from your hard drive, seems to not be a problem with VMware… for the most part. By default, VMware will use its “NAT” network setting to pass networking stuff from your Mac’s network system to the VM. But I’ve noticed that, for no apparent reason, networking will eventually stop working. It’s seemingly random, but it’s fixed easily: just use the “Bridged” networking setting instead, then reboot the VM. This can be changed by clicking on the icon with the ethernet symbol on the lower left of the VMware window, or through the “Settings” pane (where we selected the number of processors to use above). Once this change is made, problems seem to never recur.

Step 3: Installing FreeBSD

Like I said, it’s fairly straightforward. Install the standard boot manager, because dual-booting a VM is weird. When it comes time to choose what to install, I don’t recommend installing X at this point, but do install the ports collection. When it asks you to try to use IPv6 and DHCP, both should work, so say Yes to both. Create user accounts and then reboot to finalize the installation. “Eject” the installation disk image by selecting “Virtual Machine” > “CD/DVD” > “Disconnect CD/DVD” from the Mac’s menu bar or clicking the icon in the lower-left of the window that looks like a disc. If all has gone well so far, your new VM will boot and present you with a login prompt. Log in as root.

Step 4: Edit /boot/loader.conf

Your new VM is now running, but it’s using more than its fair share of your Mac’s resources. This is due to the operating system polling the VM too often for interrupts, or something like that that geekier people than I would only understand. Fortunately, this is easily fixed. Your first step after logging in to your new VM for the first time should be editing /boot/loader.conf. It’ll be a blank file to start; add the line:

kern.hz=100

Save and reboot. Log in as root again.

Step 5: Update ports

This step is probably unnecessary if you’re just installing packages instead, but it won’t hurt. When you installed ports in step 3, you also installed a very handy took for updating ports called portsnap.

# portsnap fetch; portsnap update

…and go make a sandwich while your ports collection is updated. This will take some time the first time you run it.

Step 6: Install compat6x

We’re going to want to install VMware Tools, but it doesn’t directly support FreeBSD 7, so we’ll need to install a compatibility doodad. The port is in misc/compat6x; make install clean it. (I’m not sure if this will work as a package, but you can try…)

Now we need to put the doodad in a place where VMware Tools will find it.

# ln -s /usr/local/lib/compat/libc.so.6 /lib

Step 7: Install Perl

Installing VMware Tools requires Perl, so if you don’t have it yet, install it. The port is in lang/perl5.8, or install the package if you’d rather.

Step 8: Install VMware Tools

From VMware’s “Virtual Machine” menu, select “Install VMware Tools.” This won’t do anything obvious, but what it actually did was stick a virtual CD-ROM into your virtual machine’s virtual optical drive. mount /cdrom it. It will contain a single file, entitled “vmware-freebsd-tools.tar.gz”. Extract it to somewhere convenient. This will create a directory named “vmware-tools-distrib”; cd into it, then ./vmware-install.pl.

During the installation process, the installer will tell you that it looks like you’re installing via a remote shell, and are you sure you want to continue? This is, of course, a dirty rotten lie, so say “yes.” Other than that, all of the default choices should suffice.

Step 9: Install X and a WM of some sort

If you don’t intend to use X, you’re done. If you do, there’s one more step. Install X and your window manager of choice now, and test that it works. You’ll notice that it works inside an annoyingly tiny window, though.

(If you want to install command-line stuff like vim and bash now too, go ahead.)

Step 10: Run vmware-config-tools.pl

Exit out of X and go back to the command line. Run /usr/local/bin/vmware-config-tools.pl. Like the previous Perl script, you may be told you’re logging in from a remote terminal.

Step 11: vmware-toolbox

Start X again and start up your X-powered terminal of choice. Run vmware-toolbox for an ugly X application which will let you adjust a few other options with regards to how VMware interacts with X.

Known unknowns

Two problems not solved by the steps above, and which may not be solvable: One, how to stop an escape character from being sent to the standard FreeBSD command line when you press the Command key on your keyboard (interestingly, this doesn’t seem to happen once you’ve got X running), and two, how to get VMware to realize when you’ve moved the pointer to the edge of the screen in X and release it so that you are controlling it in your Mac again, just as it can do with Windows. How to stop VMs from grabbing focus just when you merely mouse over their windows would be great to know too. If you’ve solved any of these problems yourself, please share in the comments.

Syndicate content

About RGR

Ray Gun Robot is the personal site of Garrett Albright, a fairly decent web developer and Drupal themer living in northern California. I don’t update this site much anymore, though. Find out more about me.