[update]: Some clarification (in it’s favor!) on Mnesia’s limitations thanks to commenter Gleb Peregud
“The Cloud”. Infrastructure as a resource. Whether or not you’ve bought into the hype (or HiPE as you prefer :D ) some of the largest software/IT companies in the world are throwing piles of cash at this idea of a hardware-service. But, for the purposes of new web applications that are looking to take advantage of hardware scaling to meet demand, there’s a lot of work to be done. For a quick roundup on some of the issues facing web applications with the EC2 platform you can check out Tony Arcieri’s Post on Rails with EC2. Just as Tony Points out in his article, Erlang has a lot of tools ready made for these demands, and, with the added side benefit of proven stability/scalability in intense environments, it’s certainly worthy of some consideration for your next cloud ready app.
A Language (and VM) Built to Scale
Erlang has been around the block a few times ( short history ), and it’s been used in some situations with incredible requirements and results. From it’s home at Ericsson to other telecom applications with the likes of Nortel, T-Mobile, and Motorola, where it has achieved 5 nines of availability in some instances, Erlang has been proven as a reliable platform on which to build applications.
Platform is the key word there, because it’s not just the language and its syntax that make it great for it’s appointed task but also the VM that it runs on. Erlang’s VM comes with some really great features that also make concurrent programming a lot easier.
receive_msg
()
->
receive
{
message
,
Text
}
->
io
:
format
(
"Someone told me this:
~s~n
"
,
Text
),
forward
(
Pid
)
end
.
As long as you know the Erlang process id of a given bit of running code you can dial it up and tell it what to do.
Libraries Ready Made for Distributing Load
Erlang comes with a whole host of libraries and modules built in support of its primary goal as a massively concurrent programming language. These libraries are important enough that Erlang is often referred to in conjunction with them as “Erlang/OTP”.
mnesia
:
create_schema
([
somenode
]),
mnesia
:
add_table_copy
(
Tab
,
somenode
,
Type
)
That’s pretty amazing when you consider what it means for easy data distribution.
Mnesia is not without its drawbacks though. Most importantly it wasn’t designed to store enormous tables like SQL databases. In fact it has a 2gb table size limit for disc_only_copy configuration of tables, but the in memory and memory and disc table copies are only limited by ram size. Also, with more than 8-10 nodes the amount of network communication may begin to inflict performance degredation. (Big thanks to comment poster Gleb Peregud, for both of those tidbits).
That’s only two notable examples from an enormouse set of libraries all targeted at reliable distributed infrastructure. Most of which have been proven in the harsh environments mentioned earlier.
Alternatives to Erlang
This is a big enough market that there are bound to be a lot of solutions out there for the problem of easy node addition to applications, and it only takes one look at the comments in one of Yariv’s posts ( Erlang vs Scala ) to see there are a lot of opinions.
At this point I have to confess I can’t really comment with full knowledge on how something like Scala stacks up to Erlang in this specific scenario. What I do know is that Scala runs on the JVM, which is great from a stability perspective but may not be as stellar for massive concurrency because of the way JVM handles threading with real system threads. Much the same, the CLR from Microsoft uses real system threads, but has the ability to use something akin to green threads (reference?). Clearly using either of these has some great advantages, like access to Java libraries (though many argue this might make concurrency more difficult), so it’s not as cut and dry as Erlang > All.
Clouds on the Brain
However you choose to tackle it, the cloud is growing in popularity and importance when considering web applications. Looking to the future, even the most basic hosting plans may consist of on demand hardware for our disposal, and then it will really be up to you how you want to utilize the resources you have to better serve out your apps.
Let me know what you think in the comments!