Network Programming in Elixir and Erlang
Write High-Performance, Scalable, and Reliable Apps with TCP and UDP
by: Andrea Leopardi
Published | 2025-08-21 |
---|---|
Internal code | alnpee |
Print status | In Print |
Pages | 272 |
User level | Intermediate |
Keywords | network programming, protocols, Elixir, Erlang, BEAM, scalability, systems architecture |
Related titles | PragProg has quite a few Erlang/Elixir books such as “Programming Elixir”, “Programming Phoenix”, “Concurrent Data Processing in Elixir”, and more. This book is not really tied to the other titles, since all the other books focus on other parts of the stack, frameworks, libraries, and system design. As far as networking is concerned, instead, the only two other titles this might be related to are “Programming WebRTC” by Karl Stolley and “Distributed Services with Go” by Travis Jeffery. |
ISBN | 9798888651056 |
Other ISBN |
Channel epub: 9798888651841 |
BISACs | COM043000COM043040COM043040 |
Highlight
TCP, UDP, DNS, HTTP, and more: these are the network protocols that make up the fabric of the Internet. Erlang and Elixir are the perfect fit for building network-intensive applications—the BEAM’s actor model perfectly mirrors the way nodes operate in a network. Learn about networking and the power of the BEAM to write performant and reliable network applications. Create systems that are scalable, resilient, and efficient, thanks to language primitives and OTP. Take advantage of an ecosystem that has been solving network problems for more than thirty years. Learn about design patterns and common pitfalls for network applications on the BEAM.
Description
From smart appliances to gigantic data centers, from phones to satellites, networks are the way computers talk to each other. Learn how to use network protocols, choose or design serialization protocols, and architect systems with servers and clients.
Start with the most widely-used protocol on the Internet: TCP. Build a chat server where multiple clients can chat in real time. Explore client-side TCP by building a client for Redis. Scale and harden server and client, thanks to features of the BEAM. Then dig into UDP, TCP’s “looser” sibling. Code a system for reporting metrics capable of rivaling hardened software like StatsD. Learn about DNS, which powers domain resolution for the Internet. Next, secure your TCP traffic with TLS. Lastly, explore HTTP, the protocol that even your microwave could be using. Build a JSON API, client, and server. Learn the differences between HTTP/1.1 and HTTP/2, and add real-time features via WebSockets.
The BEAM was built for networks and has been honed for more than three decades. It’s the perfect fit. Leverage years of real-world experience building network-intensive applications from a member of the Elixir core team, and become an expert at network programming in Elixir and Erlang.
Contents and Extracts
What Is Network Programming Anyway?
- Erlang and Elixir: The Perfect Fit
- Which One, Though, Erlang or Elixir?
- Where Do We Go Next?
- TCP
- TCP: Exploring the Basics
- TCP 101
- Building a TCP Echo Server
- Testing with TCP
- Becoming Socket Pros with Modes and Packet Parsing
- Wrapping Up
- Designing a Chat Protocol and Its TCP Server
- Designing a Simple Chat Protocol
- Writing Code for the Chat Protocol
- Moving to the Server Side
- Chatting with Clients
- Wrapping Up
- Scaling TCP on the Server Side
- Increasing Scalability with Multiple Acceptors
- Rewriting the Server with Thousand Island
- Wrapping Up
- Building TCP Clients
- The Redis Protocol
- Building Our First Client
- Queuing Requests
- Wrapping Up
- Scaling and Optimizing TCP Clients
- Pooling TCP Client Sockets
- Building State-Machine-Like TCP Clients
- Pooling Connections Through Registry
- Wrapping Up
- Securing Protocols: TLS
- Understanding How TLS Works
- The ssl Application
- Securing Our Chat System
- Wrapping Up
- TCP: Exploring the Basics
- UDP
- Same Layer, Different Protocol: Introducing UDP excerpt
- The Basics of the Protocol
- Building a Metrics Ingestion Daemon
- Wrapping Up
- Adding Guarantees to UDP
- Ordering, Splitting, and Dropping Packets
- Adding Guarantees
- Wrapping Up
- UDP in the Wild: DNS
- Understanding How DNS Works
- Writing a Simple DNS Client
- inet_res
- Writing a DNS Server Is So Easy
- Wrapping Up
- Same Layer, Different Protocol: Introducing UDP excerpt
- HTTP
- Talking the Internet Protocol: HTTP/1.1
- HTTP/1.1 Protocol Basics
- Serving JSON with Plug and Bandit
- Connecting to Servers with Mint
- Higher-Level Client Libraries: Finch and Req
- Wrapping Up
- HTTP/2 and the Future
- HTTP/2: Why It Was Needed and What Changed
- Using HTTP/2 with Plug and Mint
- Evolving in Parallel with QUIC and HTTP/3
- Wrapping Up
- Communicating in Real Time with WebSockets
- The WebSocket Protocol
- Making a Silly Real-Time Game
- Wrapping Up
- Talking the Internet Protocol: HTTP/1.1
- Appendixes
- The OSI Model
- TCP Protocol Details
- TCP Binary Format
- Connection States
- UDP Broadcast and Multicast
- Broadcast
- Multicast
- DNS Protocol Details
- DNS Message Header
- DNS Message Body
- Controlling Other Machines with SSH
- Using SSH as Clients
- SSH Server