Chapter 9. Adding distribution to the cache with Mnesia

 

This chapter covers

  • Choosing a strategy for distributing the cache
  • An introduction to Mnesia, the built-in database in Erlang
  • Using Mnesia to distribute the cache over multiple nodes

Your cache application is operationally sound as of chapter 7, and chapter 8 should have brought you up to speed on distribution in Erlang. You’ll need it right away. Members of the team at Erlware have been working on adding login functionality and sessions to the site: this will allow authors to update packages, tweak documentation, and change availability of their packages. You’ve been asked to add some features to your cache to make it suitable for storing sessions in order to support this new functionality.

The site is fronted by a stateless load balancer, so any of the available web servers could be called on to load a page. This means the session information needs to be available to all servers that participate in serving the web application. The problem is that currently your cache is local to the node it runs on and knows nothing about other caches that may be running on the other web servers. A simplified view of the current architecture is shown in figure 9.1.

Figure 9.1. The current, simple architecture of the cache application. Each cache is local to the server it runs on. Because the load balancer distributes work between the servers, the caches need to become distributed as well if they’re to store the session data.

9.1. Distributing the cache

9.2. Distributed data storage with Mnesia

9.3. Distributing the cache with Mnesia

9.4. Summary

sitemap