Sunday, February 17, 2008

Why Erlang will run "The Matrix"

Ok, so I had blogged and even somewhat complained about Erlang as an "every day" language. I'm here right now to say that I was dead wrong.

Erlang is simply amazing as I've gone from merely flipping through pages and references online and in books, to fiddling with gen_server off and on and to actually implementing a small facebook application based on Nick Gerakines' erlang_facebook module.

What I found funny about that last bit (the facebook app) is that after seeing an implementation of it in Ruby, it was actually easier to comprehend just what all was going on in the ERLANG version. Yes, I said it, the Erlang was easier to read.

Getting back on track...

After digging deep into getting my head around Erlang, something kind of crept up on me as I went along. Particularly when it came to message passing and "hot" code swapping...

You ready? Put on your tinfoil hat. Below is my list of reasons that "The Matrix" could become a reality and why it would be implemented in Erlang.

1. You ever wonder why we can only really "use" less than 10% of our brains? Ever wonder what that other 90-some percent is doing? That's right, passing messages to other "processes" and handling other distributed tasks.

2. When it comes to the hot code loading, this (I think) is a prime example of how a "Smith" would work. Think about it, "Oh, someone just ate the blue pill, better inject myself without taking this heap offline!". Bahng!

3. This blog post is currently fueled by Jameson 18 yr. Irish Whiskey.

4. Anything that scales just by adding cores (or nice, warm, fresh humans) and has been sitting somewhat idle in the wings for the last 20 years or so has GOT to be hiding something. I mean c'mon, most of the "love languages" (your Ruby, Python, PHP) look at a multi-core system and don't really know what to do with themselves.

5. (And this will be the last one as I'm losing momentum) The system can self-sustain for obscene periods of time, if one had the crazy "available systems" (people) one could die (literally and figuratively) and it really wouldn't matter, you'd have another waiting to take it's place AND you've got around 90% of it's processing power at your disposal.

This has been fun() (I can't help myself, I'm sorry) I hope some of you who come across this add some more to this list in the comments, I think there's a lot of cracks to be made.

Monday, February 11, 2008

'Wings BACK on a 3 game skid

Dan Cleary is out 6-8 weeks after taking a puck to the jaw and breaking it in two places (his jaw, not the puck). So there's an integral part of Detroit's 2nd-line scoring gone until, let's face it; April - hell, probably until the playoffs start.

Does this mean Kenny Holland is going to become more...I don't want to say desperate, but let's say...alert during the trade deadline? Looking over the list of names available out there, no one really looks to be a good fit for Cleary's "out of the way" scoring tactics. Finding someone with the knack that Cleary has (in my opinion) is like trying to find someone to replace Brett Hull. You really can't. The way these guys creep into the play completely unnoticed is simply incredible. Yes, it's true - I'm sure it is very easy to lose sight of whom to cover when Detroit is in your zone but c'mon, hasn't anyone gone and looked at tape? You'd be amazed how many goals Dan would score just slipping into the area around the face-off circles. If I had the time and the resources, I'd make you a little scatterplot to make you a believer.

I just hope the Red Wings can find someone to fill that void(?) on defense, I'm not too keen about Rob Blake for some reason, probably because he's 38 and is currently nursing a foot injury. Being a defenseman myself I know how often you take pucks to the feet - IT'S A LOT!!! So to pick up a huge name like that and be teetering on the brink of injury like he is...I can't see Ken Holland picking him up; I just can't. But Brad, didn't they sign Bertuzzi last year? Yes, they did - look how that turned out. He played in 8 games for Detroit last year: 2 goals, 2 assists and he was a +3. ZZZZZZzzzz...Don't come in here with that attitude. Detroit has chunks of guys like him in their stool. They're a dime a dozen on their farm team. I think for the 'Wings to have a great success in the trade arena, they should pick up a scorer: Mats Sundin is available! And finally, try to find at least a decent defenseman - maybe a stable, stay-at-home type of guy. If it works out with Blake, fantastic - I'd love to see Detroit bring a championship back home again, but boy does it not sit well with me.

Wednesday, February 6, 2008

Attachment Mania

I'm sitting face to face with a problem...

That problem being the ability to add an attachment to a "message" of sorts. Think of it as attaching a file to a forum post...except not everyone should have access to this file. And we need to do this with Ruby on Rails.

So what do we need?

Well, first and foremost I suggest we create a directory which sits outside the rails app itself. Say:
/var/myapp/attachments

Brad, why in the hell do you want to do that?


Simple, these are very private files which are going to be stored. No one should be able to just key-up the path in the browser to get to them. It will save me the lawsuit and bandwidth.

The second thing we need is to free up mongrel from serving up any static files. Let mongrel handle requests for rails but let nginx handle the static file response. This little nugget will allow us to do such a thing from rails in a clear, concise manner.

The last thing we need is to alter our capistrano script to not whipe our cache of attachments each time we deploy a new version of our rails application.

I'll post a response with my findings, if anyone has any suggestions...well, you know where to post.

Ask and ye shal receive

So as an update to my post earlier today (Wed), I've come to find out (via a conversation with Thin's main man Marc-André Cournoyer) that a PATCH to run Thin via Swiftiply is in the release queue as seen m'eow.

So, the instant the 0.7 release is out look for a whole new round of benchmarks to be produced. From what I was told, usage will reflect something like this:
this start --servers 3 --switiply --port 5000


Also, read the comments, you'll see some numbers which are being hacked away at on a work in progress. Only 22 days until 0.7 releases; I can't wait!

Application Throughput is for Closers Only

After reading a few informative posts and some statistics on application deployments and their performance with rails and the growing number of available proxies/webservers, I thought I'd take my shot at putting something fast together on a not-so beefy machine.

Read this article first and then this (Thin), this (Garbage Collection in Rails) and then this (Rails Routing).

Ok, ok, you probably didn't reall all of those...but at least read the first one. My goal is to try to bake all these together with an app that will actually do something outside of "hello, world" and see what type of performance I can juice out of an Ubuntu (Gibbon) box running on a 1.8Ghz AMD and 1.5Gb RAM. I have a fairly lightweight financial management application I've built on rails that is a perfect candidate for this type of experiment.

What's going to be involved? Nginx, Swiftiply, Thin, Postgresql and of course Rails. Now I'd like to mention here that currently (correct me if I'm wrong) there isn't a patch to run Thin via Swiftiply - I plan on changing that now that I don't have to huddle my family into a crawl space due to the 8,000 tornado warnings we had last night. It's like the world didn't want me to implement it!

Anyway, I'll post progress as I make it - if nothing else it's going to be a fun learning experience. Maybe some notoriety will come about from it if I can tie Thin into Swiftiply "un-shittily" (I'm sure someone will bitch about something).

That's all for now.

Saturday, February 2, 2008

I'm gonna make it after all...

Started my new job with a fine non-profit organization. I'll probably get to the second part of why I wasn't a good fit at my previous employer at some point. So much going on at the moment with side projects, wife taking back-to-back vacations, the economy taking a big dump on itself (we're all screwed by the way). It's been rather difficult trying to get some shut-eye the last two weeks, hopefully in the coming month I'll get some time to relax, dump my brain into this blog and finally share some dirty ruby and or rails goodness. Hell, with the installation of my new linux desktop (kudos to the Ubuntu guys for a great desktop implementation with gutsy gibbon) I really hope to get some time to tinker with merb, thin and nginx running from postgres with a datamapper ORM. But we'll cross that bridge when we come to it...

Back to the goat rodeo.