SlideShare a Scribd company logo
Louis-Philippe Gauthier
Director, Platform Engineering
Staying afloat with Buoy:
a high-performance HTTP client
2
Buoy's raison d'être
Story time
3
1. A
• 2011: ibrowse
• 2012: dlhttpc (fred’s dispcount lhttpc fork)
• 2013: dlhttpc 2.0 (my fork)
• 2017: buoy!
Problems with dlhttpc 2.0
4
• no pipelining!
• reconnects on request
• complex code base with broken test suite
• hacks on hacks on hacks
5
Buoy’s architecture
Buoy’s architecture
6
1. A
2. C
process shackle_pool
buoy_pool_utils
7
Shackle framework
1. A
2. B
3. C
Problem
8
application service
???
Service…?
9
• communicates over socket
• ascii or binary protocols
• synchronous or asynchronous protocols
Goals?!
10
• reusability
• speed (low overhead)
• concurrency
• safety
11
Shackle’s overview
Features (last year)
12
1. A
• multi-protocol support (TCP / UDP)
• fast pool implementation (random, round_robin)
• request pipelining
• backpressure via backlog (OOM protection)
• smart reconnect mechanism (exp. backoff)
Architecture (last year)
13
service
process
msg
sockets
ETS
clients
(proc_lib)
pool options + backlog
Shackle features (today)
14
1. A
• Managed timeouts
• SSL support
• handle_data callback error
• optimizations:
• granderl
• cache pool options with module
• remove setelement/3 calls
2. C
Shackle’s architecture (today)
15
service
process
msg
sockets
ETS
clients
(metal)
backlog
Shackle features (today)
16
2. C
Shackle features (future)
17
1. A
• SCTP network protocol support
• more optimizations!
• better test suite
• better documentation
2. C
Shackle usage
18
19
buoy_client
=init/0
setup/0
handle_request/2
handle_data/2
terminate/2
20
buoy_client
21
1. A
2. C
buoy_client
22
1. A
2. C
buoy_client
23
1. A
2. C
buoy_client
24
1. A
2. C
buoy_protocol request
25
1. A
2. C
buoy_protocol response
26
• small HTTP parser (< 150 lines)
• all-at-once vs streaming parser
• fast! (10x hackney’s parser)
• minimize function calls
• minimize sub-binary creation
• minimize setelement/3 calls
• uses binary:split/{2,3}
2. C
buoy_protocol response
27
1. C
buoy_protocol response
28
1. A
• split 25.7 μs
• split-hipe 20.7 μs
• split2 16.3 μs
buoy_protocol response
29
buoy_protocol response
30
1. A
• implements a subset of RFC2616
• unsupported features:
• arbitrary number of new lines in headers
• random capitalization of headers
• protection against malicious servers
• chunked encoding
2. C
buoy_compiler
31
• generates module buoy_pool_utils
• function cases generated from ETS state
• uses erl_syntax to generate AST
• hot-load with code:load_binary/3
2. C
buoy_compiler
32
1. A
2. C
buoy_compiler
33
1. A
2. C
buoy_compiler
34
1. A
2. C
35
Buoy’s performance
profiling
36
• make profile target
• fprofx (fork of fprof with suspend and GC)
• qcachegrind / kcachegrind
2. C
profiling
37
profiling
38
Staying Afloat with Buoy: A High-Performance HTTP Client
Staying Afloat with Buoy: A High-Performance HTTP Client
extrospect-beam
41
1. A
• sampling profiler using perf events (linux only)
• by Julian Squires (AdGear)
• erlang-write-perf-map PID
2. C
perf top -p PID
42
erlang-sample --only-erlang PID
43
44
HTTP client benchmarks
httpc_bench
45
1. A
• timing_hdr
• HDR histogram by Gil Tene (Azul Systems)
• hdr_histogram_erl (NIF)
• It’s on Github, send PRs!
2. C
httpc_bench
46
1. A
• dlhttpc 2.0
• hackney 1.6.2
• httpc (erlang 18.3.3)
• ibrowse 4.4.0
• katipo 0.4.0
• buoy 0.1.0
2. C
httpc_bench
47
1. A
• bench servers:
• 48 Xeon cores @ 2.20GHz
• 256 GB ram
• SSDs
• latency between servers < 0.1 ms
• Erlang 18.3.3
2. C
httpc_bench
48
1. A
• iterations / # requests
• concurrency / # processes
• pool_size/ # connections
2. C
dlhttpc
49
https://gist.github.com/lpgauth/f9a0ce1f32437b819c4a9ea252896f9b
hackney
50
https://gist.github.com/lpgauth/f9a0ce1f32437b819c4a9ea252896f9b
httpc
51
https://gist.github.com/lpgauth/f9a0ce1f32437b819c4a9ea252896f9b
ibrowse
52
https://gist.github.com/lpgauth/f9a0ce1f32437b819c4a9ea252896f9b
katipo
53
https://gist.github.com/lpgauth/f9a0ce1f32437b819c4a9ea252896f9b
buoy
54
https://gist.github.com/lpgauth/f9a0ce1f32437b819c4a9ea252896f9b
buoy
55
httpc_bench results
56
1. A
• buoy (max: 605K/s)
• katipo (max: 96K/s) - 6.3x
• dlhttpc (max: 70K/s) - 8.6x
• ibrowse (max: 59K/s) 10.2x
• hackney (max: 33K/s) - 18.3x
• httpc (max: 14K/s) - 43x
2. C
57
Tips & Tricks
Performance tips
58
• pattern match
• use iolist()
• keep your server loops lean (specialized)
• use ETS for shared state (R/W)
• compile modules for read only states
Performance tips
59
• bin_opt_info compile opt
• measure everything
Links
60
• http://github.com/lpgauth/buoy
• http://github.com/tokenrove/extrospect-beam
• http://github.com/tokenrove/granderl
• http://github.com/lpgauth/httpc_bench
• http://github.com/lpgauth/metal
• http://github.com/lpgauth/shackle
• https://github.com/lpgauth/timing
@lpgauth
Thank you!

More Related Content

PDF
Staying Afloat with Buoy: A High-Performance HTTP Client (0.1.1)
PDF
Replacing iptables with eBPF in Kubernetes with Cilium
PPTX
Kernel Proc Connector and Containers
PDF
HCQC : HPC Compiler Quality Checker
PDF
Intel® RDT Hands-on Lab
PDF
Porting and Optimization of Numerical Libraries for ARM SVE
PDF
SDAccel Design Contest: Intro
PDF
SDAccel Design Contest: Vivado HLS
Staying Afloat with Buoy: A High-Performance HTTP Client (0.1.1)
Replacing iptables with eBPF in Kubernetes with Cilium
Kernel Proc Connector and Containers
HCQC : HPC Compiler Quality Checker
Intel® RDT Hands-on Lab
Porting and Optimization of Numerical Libraries for ARM SVE
SDAccel Design Contest: Intro
SDAccel Design Contest: Vivado HLS

What's hot (20)

PDF
EBPF and Linux Networking
PDF
QNIBTerminal Plus InfiniBand - Containerized MPI Workloads
PDF
LCA14: LCA14-412: GPGPU on ARM SoC session
PDF
An Overview of the IHK/McKernel Multi-kernel Operating System
PDF
SDAccel Design Contest: Xilinx SDAccel
ODP
Criu texas-linux-fest-2014
PPTX
eBPF Basics
PDF
SDAccel Design Contest: Vivado
PPTX
runC – Open Container Initiative
PDF
Kernel bug hunting
PDF
Releasing a Distribution in the Age of DevOps.
PDF
2014 11-05 hpcac-kniep_christian_dockermpi
PDF
Running Legacy Applications with Containers
PDF
BKK16-302: Android Optimizing Compiler: New Member Assimilation Guide
PPTX
Modern Linux Tracing Landscape
PDF
BKK16-409 VOSY Switch Port to ARMv8 Platforms and ODP Integration
PDF
Linux System Monitoring with eBPF
PDF
Introduction of eBPF - 時下最夯的Linux Technology
PDF
iptables and Kubernetes
PDF
SGX Trusted Execution Environment
EBPF and Linux Networking
QNIBTerminal Plus InfiniBand - Containerized MPI Workloads
LCA14: LCA14-412: GPGPU on ARM SoC session
An Overview of the IHK/McKernel Multi-kernel Operating System
SDAccel Design Contest: Xilinx SDAccel
Criu texas-linux-fest-2014
eBPF Basics
SDAccel Design Contest: Vivado
runC – Open Container Initiative
Kernel bug hunting
Releasing a Distribution in the Age of DevOps.
2014 11-05 hpcac-kniep_christian_dockermpi
Running Legacy Applications with Containers
BKK16-302: Android Optimizing Compiler: New Member Assimilation Guide
Modern Linux Tracing Landscape
BKK16-409 VOSY Switch Port to ARMv8 Platforms and ODP Integration
Linux System Monitoring with eBPF
Introduction of eBPF - 時下最夯的Linux Technology
iptables and Kubernetes
SGX Trusted Execution Environment
Ad

Viewers also liked (18)

PDF
Debugging Complex Systems - Erlang Factory SF 2015
PDF
Pythonの処理系はどのように実装され,どのように動いているのか? 我々はその実態を調査すべくアマゾンへと飛んだ.
PDF
7 Steps to Digital Marketing
PPTX
The school of life public talk
PDF
Le marché des ITS en Russie 2017
PPTX
Computador
PPT
Hoe we kunnen zorgen dat iedereen profiteert van robotisering | ConferentieSo...
PPTX
Ortografia a l’aula i arreu
PDF
Cli in the browser
PDF
FJWilson Talent Services and the Institution of Civil Engineers
PPTX
[DE] Keynote: Die Zukunft der elektronischen Archivierung | Dr. Ulrich Kampff...
PPTX
Quelles changements de vision dans la cyber sécurité en 2017 ? - ADN OUEST, s...
PDF
ゆるふわJava8入門
PDF
The Federalist Newsletter with Arsenal history story - March 2017
PPTX
6 things people want from their business leader
PPTX
The Rise of Bots – Talk at GeoBeer #15, March 2017
PDF
Instaclustr Apache Cassandra Best Practices & Toubleshooting
PPTX
Latest Status of Identity Federation
Debugging Complex Systems - Erlang Factory SF 2015
Pythonの処理系はどのように実装され,どのように動いているのか? 我々はその実態を調査すべくアマゾンへと飛んだ.
7 Steps to Digital Marketing
The school of life public talk
Le marché des ITS en Russie 2017
Computador
Hoe we kunnen zorgen dat iedereen profiteert van robotisering | ConferentieSo...
Ortografia a l’aula i arreu
Cli in the browser
FJWilson Talent Services and the Institution of Civil Engineers
[DE] Keynote: Die Zukunft der elektronischen Archivierung | Dr. Ulrich Kampff...
Quelles changements de vision dans la cyber sécurité en 2017 ? - ADN OUEST, s...
ゆるふわJava8入門
The Federalist Newsletter with Arsenal history story - March 2017
6 things people want from their business leader
The Rise of Bots – Talk at GeoBeer #15, March 2017
Instaclustr Apache Cassandra Best Practices & Toubleshooting
Latest Status of Identity Federation
Ad

Similar to Staying Afloat with Buoy: A High-Performance HTTP Client (20)

PDF
PHP projects beyond the LAMP stack
PDF
Varnish - PLNOG 4
PDF
Fast C++ Web Servers
PDF
H2O - the optimized HTTP server
PPTX
APIs at the Edge
PPTX
Mcroservices with docker kubernetes, goang and grpc, overview
PDF
SPDY and HTTP/2
PDF
Linux sever building
PDF
Data in a Cloud - Introduction to Qt Cloud Services
ODP
MNPHP Scalable Architecture 101 - Feb 3 2011
PPTX
Digging deeper into service stack
PPT
Large-scale projects development (scaling LAMP)
PDF
apidays LIVE Paris 2021 - Edge Side APIs by Kevin Dunglas, Les Tilleuls
PDF
Load balancing at tuenti
PDF
Muduo network library
PDF
Socket programming, and openresty
PDF
Networking and Go: An Engineer's Journey (Strangeloop 2019)
PDF
Eduardo Silva - monkey http-server everywhere
PPTX
ql.io: Consuming HTTP at Scale
PDF
2013 - Igor Sysoev - NGINx: origen, evolución y futuro - PHP Conference Argen...
PHP projects beyond the LAMP stack
Varnish - PLNOG 4
Fast C++ Web Servers
H2O - the optimized HTTP server
APIs at the Edge
Mcroservices with docker kubernetes, goang and grpc, overview
SPDY and HTTP/2
Linux sever building
Data in a Cloud - Introduction to Qt Cloud Services
MNPHP Scalable Architecture 101 - Feb 3 2011
Digging deeper into service stack
Large-scale projects development (scaling LAMP)
apidays LIVE Paris 2021 - Edge Side APIs by Kevin Dunglas, Les Tilleuls
Load balancing at tuenti
Muduo network library
Socket programming, and openresty
Networking and Go: An Engineer's Journey (Strangeloop 2019)
Eduardo Silva - monkey http-server everywhere
ql.io: Consuming HTTP at Scale
2013 - Igor Sysoev - NGINx: origen, evolución y futuro - PHP Conference Argen...

Recently uploaded (20)

PDF
System and Network Administration Chapter 2
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PPTX
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PDF
top salesforce developer skills in 2025.pdf
PPTX
L1 - Introduction to python Backend.pptx
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
Nekopoi APK 2025 free lastest update
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PPT
Introduction Database Management System for Course Database
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PPTX
ai tools demonstartion for schools and inter college
PDF
Design an Analysis of Algorithms II-SECS-1021-03
System and Network Administration Chapter 2
Upgrade and Innovation Strategies for SAP ERP Customers
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
Odoo Companies in India – Driving Business Transformation.pdf
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Which alternative to Crystal Reports is best for small or large businesses.pdf
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
wealthsignaloriginal-com-DS-text-... (1).pdf
top salesforce developer skills in 2025.pdf
L1 - Introduction to python Backend.pptx
Adobe Illustrator 28.6 Crack My Vision of Vector Design
2025 Textile ERP Trends: SAP, Odoo & Oracle
Nekopoi APK 2025 free lastest update
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Wondershare Filmora 15 Crack With Activation Key [2025
Introduction Database Management System for Course Database
VVF-Customer-Presentation2025-Ver1.9.pptx
ai tools demonstartion for schools and inter college
Design an Analysis of Algorithms II-SECS-1021-03

Staying Afloat with Buoy: A High-Performance HTTP Client