Justin Rudd’s Drivel

Erlang

August 27, 2006 · 3 Comments

I’ve been reading a few Erlang weblogs lately.  One that I’ve been reading the most is Yariv Sadan.  He has a post titled Ericsson’s Biggest PR Blunder: Forgetting to Tell Us that Erlang programming is fun.  He gives some information about Yaws (a dynamic content webserver written in Erlang), ejabberd (a Jabber server written in Erlang), and the required Ericsson projects (phone switches using Erlang, etc.).  It is a well written post.  Most of Yariv’s post are informational and easy to read (except his Smerl posts.  But that is because I don’t grasp the Erlang syntax a 100% yet).

One thing I’ve noticed is that Erlang users tend to push you towards the Mnesia for your storage needs.  But there seem to be some issues with its handling of data.  Especially large amounts of data.  But I can’t seem to find any information about what qualifies as a large amount of data.

But Mnesia has some very cool features.  I especially like the location transparency of data.  I can start off with the data on a local node, and then at a later time move that data onto a remote node.  Or possibly replicate the data to another node for scale out scenarios.   But I can do all of these without the client code caring.

I was reading in The Erlang Fix by Joel Reymont about his experience Writing low-pain massively scalable multiplayer servers.  Joel’s article is the best I’ve seen when it comes to writing backend code (Yariv tends to focus on web development with Erlang).  He describes how Mnesia was used for sharing configuration data between nodes, how it has multiple masters and slaves.  He describes the architecture for getting users connected to game servers, the login protocol, etc.  I can see how a lot of what he did could be applied to projects that I work on.

For example, we have upstream systems that send us data.  Right now that happens with a queuing system.  But I can see how each upstream system could first go through a Gateway to be directed to a real instance.  Then the data that comes in from upstream is owned by that node, but is replicated to other nodes to allow for fault tolerance.  As with my Scala experiments, I can’t seem to grasp how I’m going to process the incoming data.  This is what I’m struggling with.  Too many years in an OO and procedural world I guess :)

A simple example, when an order gets assigned to a warehouse, that order comes into my team’s software.  If the order doesn’t exist, then we create it and decide when it is going to ship out.  If the order does exist, then we figure out what the differences are (added an item, removed an item, etc.) and apply them.  So I can see doing a Mnesia lookup for the order.  Taking what comes back and doing pattern matching on it to do the next step instead of an if statement like in procedural world.  It makes sense to me.  But applying it is the hard part.  Not to mention getting all the data out of Oracle into Mnesia :)  I don’t even want to think what that would take.

It is an interesting experiment.  I’ve heard rumors that groups within Amazon are looking at Erlang as well.  The idea of services that just don’t go down is appealing to all groups within Amazon.  That would just allow us to worry about things that we don’t have control over like the network and true high severity situations instead of a lot of the fire drills that we do.

But in a lot of the comments I’ve read, Erlang is definitely one of those “bus” languages.  What they mean by that is, you need to ensure that whoever is writing it has a backup for the case where he/she is hit by a bus.

You know what?  I hate this logic.  We’ve got C++ code that is 6+ years old.  I know C++ pretty good.  And I struggle to understand what the hell that code is doing.  Would the code in Erlang be harder to pick up?  Probably.  But like Smalltalk, Erlang seems to only have a handful of constructs.  Once you understand them, the rest is figuring out the logic, which is hard no matter what the language is.

Categories: Functional · Programming

3 responses so far ↓

  • joelr1 // August 30, 2006 at 1:27 am

    Hi Justin!

    I’m glad you liked my article! I have an Erlang deployment in mind that would be ideal for EC2. The beta is closed so I would likely have to pay $250/mo for a server. I could get at least 3 EC2s for that amount of money :-(.

    Who do I have to beg at Amazon to get in on the beta? Since Amazon is interested in Erlang this could be the experiment for them to watch.

    What I would like to do is run Erlang, Yaws, ejabberd and PostgreSQL and possibly balance it over a couple of EC2 units.

    Thanks, Joel

    http://wagerlabs.com

  • joelr1 // August 30, 2006 at 1:28 am

    Hi Justin! I’m glad you liked my article! I have an Erlang deployment in mind that would be ideal for EC2. The beta is closed so I would likely have to pay $250/mo for a server.

    Who do I have to beg at Amazon to get on the beta?

    What I would like to do is run Erlang, Yaws, ejabberd and PostgreSQL and possibly balance it over a couple of EC2 units.

    Thanks, Joel

    http://wagerlabs.com

  • Justin // August 30, 2006 at 1:33 am

    Hey Joel,

    I’m not sure who you would need to contact. I’ll do some digging and point them your way.

    I can’t promise any though. EC2 is way outside my domain (I’m involved in the “boring” retail side of Amazon).

Leave a Comment