SlideShare a Scribd company logo
High Performance
Systems in Go
Derek Collison
April 24, 2014
GopherCon
About
Architected/Built TIBCO Rendezvous and EMS Messaging Systems

Designed and Built CloudFoundry at VMware

Co-founded AJAX APIs group at Google

Distributed Systems

Founder of Apcera, Inc. in San Francisco, CA

@derekcollison

derek@apcera.com
Derek Collison
Why Go?
• Simple Compiled Language
• Good Standard Library
• Concurrency
• Synchronous Programming Model
• Garbage Collection
• STACKS!
Why Go?
• Not C/C++
• Not Java (or any JVM based language)
• Not Ruby/Python/Node.js
High Performance Systems in Go - GopherCon 2014
What about
High Performance?
NATS
High Performance Systems in Go - GopherCon 2014
NATS Messaging 101
• Subject-Based
• Publish-Subscribe
• Distributing Queueing
• TCP/IP Overlay
• Clustered Servers
• Multiple Clients (Go, Node.js, Java, Ruby)
High Performance Systems in Go - GopherCon 2014
High Performance Systems in Go - GopherCon 2014
NATS
• Originally written to support CloudFoundry
• In use by CloudFoundry, Baidu, Apcera and others
• Written first in Ruby -> 150k msgs/sec
• Rewritten at Apcera in Go (Client and Server)
• First pass -> 500k msgs/sec
• Current Performance -> 5-6m msgs/sec
Tuning NATS (gnatsd)
or
how to get from 500k to 6m
High Performance Systems in Go - GopherCon 2014
Target Areas
• Shuffling Data
• Protocol Parsing
• Subject/Routing
Target Areas
• Shuffling Data
• Protocol Parsing!
• Subject/Routing
Protocol Parsing
• NATS is a text based protocol
• PUB foo.bar 2rnokrn	
• SUB foo.> 2rn	
• Ruby version based on RegEx
• First Go version was port of RegEx
• Current is zero allocation byte parser
High Performance Systems in Go - GopherCon 2014
High Performance Systems in Go - GopherCon 2014
High Performance Systems in Go - GopherCon 2014
Some Tidbits
• Early on, defer was costly
• Text based proto needs conversion from ascii to int
• This was also slow due to allocations in
strconv.ParseInt
defer
defer Results
golang1.3 looks promising
parseSize
parseSize
vs
strconv.ParseInt
Target Areas
• Shuffling Data
• Protocol Parsing
• Subject/Routing
Subject Router
• Matches subjects to subscribers
• Utilizes a trie of nodes and hashmaps
• Has a frontend dynamic eviction cache
• Uses []byte as keys (Go’s builtin does not)
Subject Router
• Tried to avoid []byte -> string conversions
• Go’s builtin hashmap was slow pre 1.0
• Built using hashing algorithms on []byte
• Built on hashmaps with []byte keys
Hashing Algorithms
Hashing Algorithms
Jesteress
HashMap Comparisons
Some Lessons Learned
• Use go tool pprof (linux)
• Avoid short lived objects on the heap
• Use the stack or make long lived objects
• Benchmark standard library builtins (strconv)
• Benchmark builtins (defer, hashmap)
• Don’t use channels in performance critical path
Big Lesson Learned?
Go is a good choice
for performance based
systems
Go is getting better
faster than the others
Thanks
Resources
• https://github.com/apcera/gnatsd
• https://github.com/apcera/nats
• https://github.com/derekcollison/nats

More Related Content

What's hot (20)

PDF
Cilium - Container Networking with BPF & XDP
Thomas Graf
 
PPTX
Network policy @ k8s day
Chia-Chun Shih
 
PDF
Microservices, Containers and Docker
Ioannis Papapanagiotou
 
PDF
What Is Helm
AMELIAOLIVIA2
 
PDF
Getting Started with Kubernetes
VMware Tanzu
 
PDF
What you have to know about Certified Kubernetes Administrator (CKA)
Opsta
 
PDF
Introduction to Docker storage, volume and image
ejlp12
 
PPTX
Kubernetes for Beginners: An Introductory Guide
Bytemark
 
PDF
Introduction to GitHub Actions
Bo-Yi Wu
 
PDF
Introducing Kubeflow (w. Special Guests Tensorflow and Apache Spark)
DataWorks Summit
 
PDF
Cloud Native Networking & Security with Cilium & eBPF
Raphaël PINSON
 
PDF
Kubernetes
erialc_w
 
PPTX
Everything You Need To Know About Persistent Storage in Kubernetes
The {code} Team
 
PPTX
Golang - Overview of Go (golang) Language
Aniruddha Chakrabarti
 
PDF
Docker volume
MyoungSu Shin
 
PDF
Introducing GitLab (September 2018)
Noa Harel
 
PDF
Introduction to Kubernetes Workshop
Bob Killen
 
PDF
Introduction to K6
Knoldus Inc.
 
PDF
Gitlab, GitOps & ArgoCD
Haggai Philip Zagury
 
PDF
Observability in Java: Getting Started with OpenTelemetry
DevOps.com
 
Cilium - Container Networking with BPF & XDP
Thomas Graf
 
Network policy @ k8s day
Chia-Chun Shih
 
Microservices, Containers and Docker
Ioannis Papapanagiotou
 
What Is Helm
AMELIAOLIVIA2
 
Getting Started with Kubernetes
VMware Tanzu
 
What you have to know about Certified Kubernetes Administrator (CKA)
Opsta
 
Introduction to Docker storage, volume and image
ejlp12
 
Kubernetes for Beginners: An Introductory Guide
Bytemark
 
Introduction to GitHub Actions
Bo-Yi Wu
 
Introducing Kubeflow (w. Special Guests Tensorflow and Apache Spark)
DataWorks Summit
 
Cloud Native Networking & Security with Cilium & eBPF
Raphaël PINSON
 
Kubernetes
erialc_w
 
Everything You Need To Know About Persistent Storage in Kubernetes
The {code} Team
 
Golang - Overview of Go (golang) Language
Aniruddha Chakrabarti
 
Docker volume
MyoungSu Shin
 
Introducing GitLab (September 2018)
Noa Harel
 
Introduction to Kubernetes Workshop
Bob Killen
 
Introduction to K6
Knoldus Inc.
 
Gitlab, GitOps & ArgoCD
Haggai Philip Zagury
 
Observability in Java: Getting Started with OpenTelemetry
DevOps.com
 

Viewers also liked (6)

PDF
Corporate Open Source Anti-patterns
bcantrill
 
ODP
Assholes are killing your project
Donnie Berkholz
 
PPTX
Database Scalability - The Shard Conflict
ScaleBase
 
PDF
Detecting Corporate Fraud: Tips from a Crook and a Sleuth by Roddy Boyd and S...
Reynolds Center for Business Journalism
 
PDF
Running Secure Server Software on Insecure Hardware Without Parachute
Cloudflare
 
PPTX
The Hard Truths of Entrepreneurship
Rand Fishkin
 
Corporate Open Source Anti-patterns
bcantrill
 
Assholes are killing your project
Donnie Berkholz
 
Database Scalability - The Shard Conflict
ScaleBase
 
Detecting Corporate Fraud: Tips from a Crook and a Sleuth by Roddy Boyd and S...
Reynolds Center for Business Journalism
 
Running Secure Server Software on Insecure Hardware Without Parachute
Cloudflare
 
The Hard Truths of Entrepreneurship
Rand Fishkin
 
Ad

Similar to High Performance Systems in Go - GopherCon 2014 (20)

PPTX
Scaling applications with go
Vimlesh Sharma
 
PDF
Introduction to Go
zhubert
 
PPTX
Golang
Fatih Şimşek
 
PPTX
Ready, set, go! An introduction to the Go programming language
RTigger
 
PDF
GoSF Summerfest - Why Go at Apcera
Derek Collison
 
PDF
Go After 4 Years in Production - QCon 2015
Travis Reeder
 
PPTX
Introduction to go lang
Amal Mohan N
 
PDF
Beyond the Hype: 4 Years of Go in Production
C4Media
 
PPTX
The GO Language : From Beginners to Gophers
I.I.S. G. Vallauri - Fossano
 
PPTX
Go. Why it goes
Sergey Pichkurov
 
PPT
A First Look at Google's Go Programming Language
Ganesh Samarthyam
 
PPT
Google's Go Programming Language - Introduction
Ganesh Samarthyam
 
PDF
Inroduction to golang
Yoni Davidson
 
PDF
Introduction to Go
Simon Hewitt
 
PDF
Go - Where it's going and why you should pay attention.
Aaron Schlesinger
 
PPTX
Gopher in performance_tales_ms_go_cracow
MateuszSzczyrzyca
 
PDF
Why go ?
Mailjet
 
PPTX
Golang workshop - Mindbowser
Mindbowser Inc
 
PDF
Introduction to go, and why it's awesome
Janet Kuo
 
Scaling applications with go
Vimlesh Sharma
 
Introduction to Go
zhubert
 
Ready, set, go! An introduction to the Go programming language
RTigger
 
GoSF Summerfest - Why Go at Apcera
Derek Collison
 
Go After 4 Years in Production - QCon 2015
Travis Reeder
 
Introduction to go lang
Amal Mohan N
 
Beyond the Hype: 4 Years of Go in Production
C4Media
 
The GO Language : From Beginners to Gophers
I.I.S. G. Vallauri - Fossano
 
Go. Why it goes
Sergey Pichkurov
 
A First Look at Google's Go Programming Language
Ganesh Samarthyam
 
Google's Go Programming Language - Introduction
Ganesh Samarthyam
 
Inroduction to golang
Yoni Davidson
 
Introduction to Go
Simon Hewitt
 
Go - Where it's going and why you should pay attention.
Aaron Schlesinger
 
Gopher in performance_tales_ms_go_cracow
MateuszSzczyrzyca
 
Why go ?
Mailjet
 
Golang workshop - Mindbowser
Mindbowser Inc
 
Introduction to go, and why it's awesome
Janet Kuo
 
Ad

More from Derek Collison (8)

PDF
What's beyond Virtualization - The Future of Cloud Platforms
Derek Collison
 
PDF
Apcera Case Study: The selection of the Go language
Derek Collison
 
PDF
Distributed Design and Architecture of Cloud Foundry
Derek Collison
 
PDF
Cloud Foundry: Inside the Machine
Derek Collison
 
PDF
RubyWorld 2011
Derek Collison
 
PDF
OSCON 2011
Derek Collison
 
PDF
Scalable and Available, Patterns for Success
Derek Collison
 
PDF
Ruby conf2010 OpenPaaS
Derek Collison
 
What's beyond Virtualization - The Future of Cloud Platforms
Derek Collison
 
Apcera Case Study: The selection of the Go language
Derek Collison
 
Distributed Design and Architecture of Cloud Foundry
Derek Collison
 
Cloud Foundry: Inside the Machine
Derek Collison
 
RubyWorld 2011
Derek Collison
 
OSCON 2011
Derek Collison
 
Scalable and Available, Patterns for Success
Derek Collison
 
Ruby conf2010 OpenPaaS
Derek Collison
 

Recently uploaded (20)

PPTX
Evaluation and thermal analysis of shell and tube heat exchanger as per requi...
shahveer210504
 
PPTX
The Role of Information Technology in Environmental Protectio....pptx
nallamillisriram
 
PPTX
MobileComputingMANET2023 MobileComputingMANET2023.pptx
masterfake98765
 
PPTX
Introduction to Neural Networks and Perceptron Learning Algorithm.pptx
Kayalvizhi A
 
PPTX
Damage of stability of a ship and how its change .pptx
ehamadulhaque
 
PPTX
美国电子版毕业证南卡罗莱纳大学上州分校水印成绩单USC学费发票定做学位证书编号怎么查
Taqyea
 
PPTX
Hashing Introduction , hash functions and techniques
sailajam21
 
PDF
Biomechanics of Gait: Engineering Solutions for Rehabilitation (www.kiu.ac.ug)
publication11
 
PPTX
Product Development & DevelopmentLecture02.pptx
zeeshanwazir2
 
PDF
Basic_Concepts_in_Clinical_Biochemistry_2018كيمياء_عملي.pdf
AdelLoin
 
PDF
Pressure Measurement training for engineers and Technicians
AIESOLUTIONS
 
PDF
MAD Unit - 1 Introduction of Android IT Department
JappanMavani
 
PPTX
Depth First Search Algorithm in 🧠 DFS in Artificial Intelligence (AI)
rafeeqshaik212002
 
PDF
Reasons for the succes of MENARD PRESSUREMETER.pdf
majdiamz
 
PDF
Design Thinking basics for Engineers.pdf
CMR University
 
PDF
Unified_Cloud_Comm_Presentation anil singh ppt
anilsingh298751
 
PPTX
Green Building & Energy Conservation ppt
Sagar Sarangi
 
PPTX
VITEEE 2026 Exam Details , Important Dates
SonaliSingh127098
 
PPTX
265587293-NFPA 101 Life safety code-PPT-1.pptx
chandermwason
 
PPTX
Mechanical Design of shell and tube heat exchangers as per ASME Sec VIII Divi...
shahveer210504
 
Evaluation and thermal analysis of shell and tube heat exchanger as per requi...
shahveer210504
 
The Role of Information Technology in Environmental Protectio....pptx
nallamillisriram
 
MobileComputingMANET2023 MobileComputingMANET2023.pptx
masterfake98765
 
Introduction to Neural Networks and Perceptron Learning Algorithm.pptx
Kayalvizhi A
 
Damage of stability of a ship and how its change .pptx
ehamadulhaque
 
美国电子版毕业证南卡罗莱纳大学上州分校水印成绩单USC学费发票定做学位证书编号怎么查
Taqyea
 
Hashing Introduction , hash functions and techniques
sailajam21
 
Biomechanics of Gait: Engineering Solutions for Rehabilitation (www.kiu.ac.ug)
publication11
 
Product Development & DevelopmentLecture02.pptx
zeeshanwazir2
 
Basic_Concepts_in_Clinical_Biochemistry_2018كيمياء_عملي.pdf
AdelLoin
 
Pressure Measurement training for engineers and Technicians
AIESOLUTIONS
 
MAD Unit - 1 Introduction of Android IT Department
JappanMavani
 
Depth First Search Algorithm in 🧠 DFS in Artificial Intelligence (AI)
rafeeqshaik212002
 
Reasons for the succes of MENARD PRESSUREMETER.pdf
majdiamz
 
Design Thinking basics for Engineers.pdf
CMR University
 
Unified_Cloud_Comm_Presentation anil singh ppt
anilsingh298751
 
Green Building & Energy Conservation ppt
Sagar Sarangi
 
VITEEE 2026 Exam Details , Important Dates
SonaliSingh127098
 
265587293-NFPA 101 Life safety code-PPT-1.pptx
chandermwason
 
Mechanical Design of shell and tube heat exchangers as per ASME Sec VIII Divi...
shahveer210504
 

High Performance Systems in Go - GopherCon 2014