Introduction to the Open Telecom Platform

Posted by on September 05, 2008

Many people refer to Erlang as “Erlang/OTP.” OTP stands for Open Telecom Platform, and is more or less a set of libraries which come packaged with Erlang. They consist of Erlang behaviors (or behaviours, technically) for writing servers, finite state machines, event managers. But that is not all, OTP also encompasses the application behavior which allows programmers to package their Erlang code into a single “application.” And the supervisor behavior allows programmers to create a hierarchy of processes, where if one process dies, it will be restarted.

OTP is much too complex of a thing to explain in a single article, and I will not attempt to do so here. Instead, I will be making this a series of articles spanning a couple weeks.

Why should I learn about Erlang/OTP?

The platform which comes with Erlang gives you a rich and very generalized set of libraries and behaviors to easily create highly available, fault tolerant, hot code swapping ready systems. The following is a basic list of what it gives you “for free:”

  • Generic server, finite state machine, and event manager behaviors
  • Standardized application structure
  • Hot swappable code
  • Supervisor Trees so your processes always stay up

In addition to these free features, OTP is the standardized way to create systems in Erlang. The big name open source Erlang applications such as ejabberd, CouchDB, and MochiWeb all use OTP.

Therefore, by learning OTP, you will not only gain the knowledge and ability to create powerful Erlang systems, but you’ll be able to readily jump into other open source projects and learn from them, since they follow the same general structure.

If you know the general Erlang syntax, then you’re ready to jump in and begin learning about Erlang/OTP!

Click read more below to read the rest of this introduction :)

The gen_* behaviors

  • gen_server - A behavior which should be used to create a general multiple client to server system.
  • gen_fsm - A behavior to create a finite state machine. I used gen_fsm to create a SOCKS5 proxy server, which is a FSM following the states: wait_for_init, wait_for_auth, ready, and some intermediate steps for different types of authentication. There are many other uses for finite state machines and this is one of my favorite behaviors.
  • gen_event - Used to create event handlers and event dispatchers. The most common use of this is for error logging, which is a dispatcher, and many handlers (terminal, file, etc.) can be attached to it.

The Supervisor Behavior

The supervisor behavior is used to describe its child processes that it will be monitoring. Multiple supervisors are used to create a supervisor hierarchy, so your processes are always up.

To get a great introduction to the supervisor behavior, read this page on it from the Erlang documentation.

The Application Behavior

The application behavior is used to start and stop multiple supervisors and other processes in order to start some code as a single unit. For example, after creating my SOCKS5 server, I created it into an application which I can start by typing application:start(socks5_server).

To read more about the applicaiton behavior, check out the introduction from the Erlang documentation.

What to Look Forward to

This post was meant only as a brief introduction to what OTP is and to answer questions such as why you should learn it and the starting points for where you can learn it. In the coming days I will be posted a series of articles where we’ll create a OTP application.

My next article, which I’ll post tomorrow, will be a comprehensive introduction to gen_server, where we will create a theoretical bank account manager. And by the end of two weeks from now, you will know how to create your own Erlang/OTP-based systems from the ground up.

Trackbacks

Use this link to trackback from your own site.

Comments

Leave a response

  1. scott Sep 05, 2008 10:34

    Hi Mitchell.

    Thank you for taking the time to write about Erlang. As a beginner, I really appreciate your efforts and I’m eagerly awaiting your future posts about Erlang/OTP.

    Cheers,

    Scott

  2. Jay Phillips Sep 05, 2008 21:35

    I usually don’t take time to comment on blogs but I will this time. Keep up the good blog posts! There are definitely too few Erlang bloggers and what you’ve done already is a great start. I’m especially looking forward to your more advanced blog posts which go into depth about practices and patterns you’ve gleaned from working with Erlang. :)

  3. Mitchell Sep 05, 2008 21:38

    Thank you Scott and thank you Jay.

    The comments I receive are really what keep me going and I’m glad to know that there are people out there interested in what I’m doing :) More are definitely along the way! Thanks again for the support.

    Btw, Jay, since at work I also use a lot of Ruby, I’d just like to say that I love adhearsion :P Although I’ve never been able to use it in practice, its a great piece of software and the syntax is awesome!

  4. [...] the introduction to a new series of Erlang/OTP articles for the beginner, Mitchell introduces some basic concepts [...]

  5. grantmichaels Sep 06, 2008 06:49

    i’ve been following your recent posts re: erlang all week, and while i wasn’t sure after reading the first how useful they were going to be, the 2nd and 3rd prove otherwise … i look forward to following along and you’ve definitely got a new subscriber …

    gm

  6. [...] later, they are tagged with a unique tag to the series: otp introduction. As promised in my initial introduction to OTP, we will be making a server to handle the fake bank accounts of people at “ErlyBank” [...]

  7. [...] in 2 modules (actually 3) based on gen_event, the cpxlog stuff and the cdr stuff. gen_event is the OTP module that everyone seems to find hard to use for anything other than logging, but it’s got [...]

  8. Choon Beng Jun 22, 2009 18:52

    Hi I am new to erlang and trying to do failover of naming services on different nodes. Could someone enlighten me thanks alot

Comments

Comments: