Your SlideShare is downloading. ×
High Performance Systems in Go - GopherCon 2014
High Performance Systems in Go - GopherCon 2014
High Performance Systems in Go - GopherCon 2014
High Performance Systems in Go - GopherCon 2014
High Performance Systems in Go - GopherCon 2014
High Performance Systems in Go - GopherCon 2014
High Performance Systems in Go - GopherCon 2014
High Performance Systems in Go - GopherCon 2014
High Performance Systems in Go - GopherCon 2014
High Performance Systems in Go - GopherCon 2014
High Performance Systems in Go - GopherCon 2014
High Performance Systems in Go - GopherCon 2014
High Performance Systems in Go - GopherCon 2014
High Performance Systems in Go - GopherCon 2014
High Performance Systems in Go - GopherCon 2014
High Performance Systems in Go - GopherCon 2014
High Performance Systems in Go - GopherCon 2014
High Performance Systems in Go - GopherCon 2014
High Performance Systems in Go - GopherCon 2014
High Performance Systems in Go - GopherCon 2014
High Performance Systems in Go - GopherCon 2014
High Performance Systems in Go - GopherCon 2014
High Performance Systems in Go - GopherCon 2014
High Performance Systems in Go - GopherCon 2014
High Performance Systems in Go - GopherCon 2014
High Performance Systems in Go - GopherCon 2014
High Performance Systems in Go - GopherCon 2014
High Performance Systems in Go - GopherCon 2014
High Performance Systems in Go - GopherCon 2014
High Performance Systems in Go - GopherCon 2014
High Performance Systems in Go - GopherCon 2014
High Performance Systems in Go - GopherCon 2014
High Performance Systems in Go - GopherCon 2014
High Performance Systems in Go - GopherCon 2014
High Performance Systems in Go - GopherCon 2014
High Performance Systems in Go - GopherCon 2014
High Performance Systems in Go - GopherCon 2014
High Performance Systems in Go - GopherCon 2014
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

High Performance Systems in Go - GopherCon 2014

8,362

Published on

Short presentation on some techniques to gain performance of the NATS messaging system as it was rewritten in Go.

Short presentation on some techniques to gain performance of the NATS messaging system as it was rewritten in Go.

Published in: Engineering, Technology
0 Comments
28 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
8,362
On Slideshare
0
From Embeds
0
Number of Embeds
13
Actions
Shares
0
Downloads
108
Comments
0
Likes
28
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. High Performance Systems in Go Derek Collison April 24, 2014 GopherCon
  • 2. 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
  • 3. Why Go? • Simple Compiled Language • Good Standard Library • Concurrency • Synchronous Programming Model • Garbage Collection • STACKS!
  • 4. Why Go? • Not C/C++ • Not Java (or any JVM based language) • Not Ruby/Python/Node.js
  • 5. What about High Performance?
  • 6. NATS
  • 7. NATS Messaging 101 • Subject-Based • Publish-Subscribe • Distributing Queueing • TCP/IP Overlay • Clustered Servers • Multiple Clients (Go, Node.js, Java, Ruby)
  • 8. 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
  • 9. Tuning NATS (gnatsd) or how to get from 500k to 6m
  • 10. Target Areas • Shuffling Data • Protocol Parsing • Subject/Routing
  • 11. Target Areas • Shuffling Data • Protocol Parsing! • Subject/Routing
  • 12. 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
  • 13. 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
  • 14. defer
  • 15. defer Results golang1.3 looks promising
  • 16. parseSize
  • 17. parseSize vs strconv.ParseInt
  • 18. Target Areas • Shuffling Data • Protocol Parsing • Subject/Routing
  • 19. 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)
  • 20. 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
  • 21. Hashing Algorithms
  • 22. Hashing Algorithms
  • 23. Jesteress
  • 24. HashMap Comparisons
  • 25. 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
  • 26. Big Lesson Learned?
  • 27. Go is a good choice for performance based systems
  • 28. Go is getting better faster than the others
  • 29. Thanks
  • 30. Resources • https://github.com/apcera/gnatsd • https://github.com/apcera/nats • https://github.com/derekcollison/nats

×