Chapter 9. Building an Application with OTP

So far this book has shown small pieces of Erlang or other code to demonstrate one idea or another. This chapter does something a bit different. Here I will develop a larger application to demonstrate how all the parts of an Erlang- and Yaws-based web application hang together.

This application will allow a bunch of users to notify each other of updates in status. Whenever a user’s status changes in their browser or on their phone, that change will be made available by the server. It will also keep track of each user’s status so when a user signs in, she can see all the existing status messages. This application can serve as the base of many distributed applications, and I hope it will prove illustrative of how to build an application in Erlang.


Feel free to use this module as a basis for your own product. If you do something really cool with it, please let me know!

This application will also split the application into layers: we’ll have a server level that will coordinate between the users, and a web frontend that will use a simple web interface.

In this chapter we’ll build a more complex application using the standard Erlang/OTP structures. By doing this we can take advantage of the fact that OTP is a very well tested framework for building extremely robust servers, and match that with an interface in Yaws that can work with the web browser.

An OTP application features several parts, all of which must be present. First we have the workers ...

Get Building Web Applications with Erlang now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.