Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
Designing for Scalability with Erlang/OTP
Preface
Conventions Used in This Book
Using Code Examples
Safari® Books Online
How to Contact Us
1. Introduction
Defining the Problem
OTP
Erlang
Tools and Libraries
System Design Principles
Erlang Nodes
Distribution, Infrastructure and Multi-core
Summing Up
What You’ll Learn in This Book
2. Introducing Erlang
Recursion and Pattern Matching
Functional Influence
Fun with Anonymous Functions
List Comprehensions: generate and test
Processes and Message Passing
Fail Safe!
Links and Monitors for Supervision
Links
Monitors
Records
Maps
Macros
Upgrading Modules
ETS: Erlang Term Storage
Distributed Erlang
Naming and Communication
Node Connections and Visibility
Summing Up
What’s Next?
3. Behaviours
Process Skeletons
Design Patterns
Callback Modules
Extracting Generic Behaviours
Starting The Server
The Client Functions
The Server Loop
Functions Internal to the Server
The Generic Server
Message Passing: Under the hood
Summing up
What’s Next?
4. Generic Servers
Generic Servers
Behaviour Directives
Starting a Server
Message Passing
Synchronous Message Passing
Asynchronous Message Passing
Other Messages
Using From
Unhandled Messages
Termination
Call Timeouts
Deadlocks
Generic Server Timeouts
Hibernating Behaviours
Going Global
Linking Behaviours
Summing Up
What’s Next?
5. Controlling OTP Behaviours
The sys Module
Tracing and Logging
System Messages
Your Own Trace Functions
Statistics, Status, and State
The sys module Recap
Performance Tuning Options
Memory Usage
Process heap
Virtual Binary Heap
Full sweep of the heap
Options to Avoid
Summing Up
What’s Next?
6. Finite State Machines
Finite State Machines the Erlang Way
Coffee Finite State Machine
The Hardware Stub
The Erlang Coffee Machine
Starting
The events
The selection state
The payment state
The remove state
Generic Finite State Machines
A Behaviour Example
Starting the FSM
Sending Events
Asynchronous events
Timeouts
Asynchronous events to all states
Termination
Synchronous events
Summing Up
Get Your Hands Dirty
The Phone Controllers
Let’s Test It
What’s Next?
7. Event Handlers
Events
Generic Event Managers and Handlers
Starting and Stopping Event Managers
Adding Event Handlers
Deleting an Event Handler
Sending Synchronous and Asynchronous Events
Retrieving Data
Handling Errors and Invalid Return Values
Swapping Event Handlers
Wrapping it all up
The SASL Alarm Handler
Summing Up
What’s Next?
8. Supervisors
Supervision Trees
OTP Supervisors
The Supervisor Behaviour
Starting the Supervisor
The Supervisor Specification
The restart tuple
The child specification list
Dynamic Children
Simple one for one
Gluing it all together
Non OTP-Compliant Processes
Supervisor bridges
Adding non OTP Compliant Processes
Scalability and Short-Lived Processes
Synchronous Starts for Determinism
Testing Your Supervision Strategy
How Does This Compare?
Summing Up
What’s Next?
9. Applications
How Applications Run
The Application Structure
The Callback Module
Starting Applications
Stopping Applications
Application Resource Files
The Base Station Controller Application File
Starting an Application
Environment Variables
Distributed Applications
Start Phases
Included Applications
Start Phases in Included Applications
Combining Supervisors and Applications
The SASL Application
Progress Reports
Error Reports
Crash Reports
Supervisor Reports
Summing Up
What’s Next?
10. Special Processes and Your Own Behaviours
Special Processes
The Mutex
Starting Special Processes
Basic template for starting a special process
Asynchronously starting a special process
The Mutex States
Handling Exits
System Messages
Trace and Log Events
Putting it Together
Dynamic Modules and Hibernating
Your Own Behaviours
Rules for creating behaviours
A Example Handling TCP Streams
Summing Up
What’s Next?
11. System Principles and Release Handling
System Principles
Release Directory Structure
Release Resource Files
Creating a Release
Creating the boot file
Script Files
The make_script Parameters
Creating a Release Package
Start Scripts and Configuring on Target
Arguments and Flags
Heart
The Erlang Loader
The init module
Other Tools
Rebar
Generating a rebar Project
Creating a Release with rebar
Rebar Releases with Project Dependencies
Relx
Reltool
Wrapping Up
What’s Next?
12. Release Upgrades
Software Upgrades
The First Version of the Coffee FSM
Adding a state
Creating a Release Upgrade
The Code To Upgrade
Application Upgrade Files
High-Level Instructions
Release Upgrade Files
Low-level instructions
Installing an Upgrade
The Release Handler
Upgrading Environment Variables
Upgrading Special Processes
Upgrading In Distributed Environments
Upgrading The Emulator and Core Applications
Summing Up
What’s Next?
About the Authors
Copyright
← Prev
Back
Next →
← Prev
Back
Next →