SlideShare una empresa de Scribd logo
1 de 44
Digital Publishing for Scale
The Economist and Go
Jonas
Lead Engineer, Content Platform
@yigenana
InfoQ.com: News & Community Site
• 750,000 unique visitors/month
• Published in 4 languages (English, Chinese, Japanese and Brazilian
Portuguese)
• Post content from our QCon conferences
• News 15-20 / week
• Articles 3-4 / week
• Presentations (videos) 12-15 / week
• Interviews 2-3 / week
• Books 1 / month
Watch the video with slide
synchronization on InfoQ.com!
https://www.infoq.com/presentations/
the--economist-go
Presented at QCon New York
www.qconnewyork.com
Purpose of QCon
- to empower software development by facilitating the spread of
knowledge and innovation
Strategy
- practitioner-driven conference designed for YOU: influencers of
change and innovation in your teams
- speakers and topics driving the evolution and innovation
- connecting and catalyzing the influencers and innovators
Highlights
- attended by more than 12,000 delegates since 2007
- held in 9 cities worldwide
Print Pressing Forward
Print Pressing Forward
The Happy Path to Go
The Platform
* AWS hosted
* Event Messaging
* Worker microservices
* Distributed
* S3, DynamoDB, and ElasticSearch data
stores
* RESTful API & GraphQL
The Happy Path to Go
Key factors
* Built in concurrency support enables
performance at scale
* Strong networking and API support
* Compiled language simple to deploy
across platforms
* Simple design and syntax quickly
enables developers
Fail Fast: Language
Design
Application Principles
* Minimize startup time
* Fail fast
* Continuous Integration & Delivery
Twelve Factor App
Fail Fast: Errors vs
Exceptions
Errors vs Exception
* No exceptions
* Error as a type
* Failing fast the responsibility of the
developer
Fail Fast: Error Handling
type error interface {
Error() string
}
Fail Fast: Error Handling
// New returns an error that formats as the given text.
func New(text string) error {
return &errorString{text}
}
// errorString is a trivial implementation of error.
type errorString struct {
s string
}
func (e *errorString) Error() string {
return e.s
}
Fail Fast: Error Handling
func fetchContent(id string) (string, error) {
content, err := fetch(id)
if err != nil {
// handle the error.
}
// happy path continues.
}
Fail Fast: Error Handling
package net
type Error interface {
error
Timeout() bool // Is the error a timeout?
Temporary() bool // Is the error temporary?
}
if nerr, ok := err.(net.Error); ok && nerr.Temporary() {
time.Sleep(1e9)
continue
}
if err != nil {
log.Fatal(err)
}
From Error Handling in Go
Fail Fast: Error Handling
Go Error Key Benefits
* Handle errors gracefully
* Improve debugging and visibility
* More user friendly errors responses
* Greater reliability
Consistency: Language
Design
The Canonical Article
* Standard data model for all content
* Aligned to schema.org standards
* Hypermedia references to associated
content
* Query via GraphQL and RESTful API
Consistency: Testing
main.go
package main
func Sum(x int, y int) int {
return x + y
}
Consistency: Testing
main_test.go
package main
import "testing"
func TestSum(t *testing.T) {
total := Sum(1,2)
if total != 3 {
t.Errorf("Sum incorrect, got: %d, want: %d.", total, 3)
}
}
Consistency: Testing
Go Test Features
* Cover: Code test coverage
* Bench: Runs benchmark tests
(Benchxxx)
* TestMain: Add extra setup or teardown
for tests
* Table tests and mocks
Consistency: The Challenges
One moment an empty value is 0.
{
"id": "test123",
"type": "article",
"position": 0
}
The next moment it's an empty string!
{
"id": "test123",
"type": "article",
"position": ""
}
Consistency: Serializing Dynamic Content
package json
// decodeState represents the state while decoding a JSON value.
type decodeState struct {
data []byte
off int // next read offset in data
opcode int // last read result
scan scanner
errorContext struct { // provides context for type errors
Struct string
Field string
}
savedError error
useNumber bool
disallowUnknownFields bool
}
Consistency: Serializing Dynamic Content
func (d *decodeState) value(v reflect.Value) error {
case scanBeginArray:
if v.IsValid() {
if err := d.array(v); err != nil {
return err
}
} else {
d.skip()
}
d.scanNext()
case scanBeginObject:
if v.IsValid() {
if err := d.object(v); err != nil {
return err
}
} else {
d.skip()
}
d.scanNext()
return nil
}
Consistency: Serializing Dynamic Content
// convertNumber converts the number literal s to a float64 or a Number
// depending on the setting of d.useNumber.
func (d *decodeState) convertNumber(s string) (interface{}, error) {
if d.useNumber {
return Number(s), nil
}
f, err := strconv.ParseFloat(s, 64)
if err != nil {
return nil, &UnmarshalTypeError{Value: "number " + s, Type: reflect.TypeOf(0.0), Offset: int64(d.off)}
}
return f, nil
}
Consistency: Serializing Dynamic Content
package canonical
// traverseState represents current state of tree traversal.
type traverseState struct {
object *s3.Object
tags *traverseTags
field reflect.StructField
treePath string
}
Consistency: Serializing Dynamic Content
// traverse is a top level tree traversal function.
func (t traverseState) traverse(v reflect.Value) {
switch v.Kind() {
case reflect.Struct:
switch {
case t.field.Tag.Get(refTag) != "":
t.setRef(v)
default:
t.traverseStruct(v)
}
case reflect.Slice:
if t.field.Tag.Get(pathTag) != "" {
t.setSlice(v)
}
case reflect.String, reflect.Bool, reflect.Int, reflect.Float64:
if t.field.Tag.Get(pathTag) != "" {
t.setPrimitive(v)
}
default:
logger.Warnln("Unknown kind:", v)
}
}
Consistency: Serializing Dynamic Content
func toInt(v reflect.Value) int64 {
switch v.Type {
case int:
return v.Int()
case string:
i, err := strconv.Atoi(v.String())
default:
return 0
}
}
Consistency: Serializing Dynamic Content
BenchmarkCustomSerializer-1 1000 1345080 ns/op
BenchmarkCustomSerializer-2 1000 1410146 ns/op
BenchmarkCustomSerializer-3 1000 1348061 ns/op
BenchmarkCustomSerializer-4 1000 1343668 ns/op
BenchmarkCustomSerializer-5 1000 1411710 ns/op
BenchmarkStandardUnmarshal-1 1000 1451230 ns/op
BenchmarkStandardUnmarshal-2 1000 1771896 ns/op
BenchmarkStandardUnmarshal-3 1000 1396645 ns/op
BenchmarkStandardUnmarshal-4 1000 1720717 ns/op
BenchmarkStandardUnmarshal-5 1000 1475672 ns/op
Scale: HTTP and concurrency
package main
import (
"fmt"
"log"
"net/http"
)
func handler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello World!")
}
func main() {
http.HandleFunc("/", handler)
log.Fatal(http.ListenAndServe(":8080", nil))
}
Scale: HTTP and concurrency
func (srv *Server) Serve(l net.Listener) error {
baseCtx := context.Background() // base is always background, per Issue 16220
ctx := context.WithValue(baseCtx, ServerContextKey, srv)
for {
rw, e := l.Accept()
if e != nil {
select {
case <-srv.getDoneChan():
return ErrServerClosed
default:
}
if ne, ok := e.(net.Error); ok && ne.Temporary() {
continue
}
return e
}
tempDelay = 0
c := srv.newConn(rw)
c.setState(c.rwc, StateNew) // before Serve can return
go c.serve(ctx)
}
}
Scale: Content
Guarantees
CAP Theorum
Pick two
* Consistency
* Availiabity
* Partition Tolerance
Scale: Content Guarantees
func reprocess(searchResult *http.Response) (int, error) {
responses := make([]response, len(searchResult.Hits.Hits))
var wg sync.WaitGroup
wg.Add(len(responses))
for i, hit := range searchResult.Hits.Hits {
wg.Add(1)
go func(i int, item elastic.SearchHit) {
defer wg.Done()
code, err := reprocessItem(item)
responses[i].code = code
responses[i].err = err
}(i, *hit)
}
wg.Wait
return http.StatusOK, nil
}
Scale: Content Guarantees
ProcessTimeAsync-1 20 564.030301ms
ProcessTimeAsync-2 20 813.193206ms
ProcessTimeAsync-3 20 564.536223ms
ProcessTimeAsync-4 20 830.068246ms
ProcessTimeAsync-5 20 865.895741ms
ProcessTimeSync-1 20 3.806562215s
ProcessTimeSync-2 20 4.666270193s
ProcessTimeSync-3 20 4.206750535s
ProcessTimeSync-4 20 3.745507495s
ProcessTimeSync-5 20 4.109966063s
Go Concurrency Patterns & Understanding Channels
Scale: Visibility with
Profiling
PPROF
* CPU profiles, traces, heap profiles, and
mutex profiles.
* CLI tool
* HTTP Endpoint
* Visualizations
Scale: Dependencies
go get
Scale: Dependencies
go where?
Embracing Limitations
Embracing Limitations: Metadata Parsing
// runExif runs the exiftool command with a set of arguments.
func runExif(args []string) ([]byte, error) {
cmdOut, err := exec.Command("exiftool", args...).Output()
if err != nil {
return nil, err
}
return cmdOut, nil
}
Embracing Limitations: HTML Maddness
<br><em>• Percentage change: shows the change in
inflation-adjusted prices between two selected dates</em></p>
<p><em><span class="fontcolor-red"><span class="fontcolor-red">
<span class="fontcolor-black"><span class="fontcolor-red">
We also publish interactive house-price guides to</span>
&nbsp;</span><a href=""http://www.economist.com/houseprices&quot;">global markets</a></span>
&nbsp;<span class="fontcolor-red">and&nbsp;</span>
<em><span class="fontcolor-red"><span class="fontcolor-red">
<span class="fontcolor-black"><a href="http://www.economist.com/blogs/graphicdetail/2014/04/british-house-prices">British regions</a>.
</span></span></span></em></span></em></p>
Embracing Limitations: Simple JSON handling
// getLane returns lane information from the
// envelope. It uses jsonpointer to access the field
// as we want to build on this in a subsequent iteration.
const getLane = (event) => {
const target = '/envelope/responseElements/queue-source';
return pointer.has(event, target) && pointer.get(event, target);
}
GOing Retro
What Went Well?
* Key language design elements for distributed systems
* Concurrency model quick to implement
* Robust Go tooling that fits into workflow
* Fun to write and fun community
What Could be Improved?
* Versioning and vendoring lack standards
* Lacks maturity in some areas
* Verbose for certain use cases
GOing Retro: Scale
GOing Retro: Design
Systems Design
* What are your system goals?
* What guarantees are you providing your
consumers?
* What architecture and patterns are right
for your system?
* How will your system need to scale?
Thank You!
@yigenana
Adorable Gophers by Ashley McNamara
Watch the video with slide
synchronization on InfoQ.com!
https://www.infoq.com/presentations/
the--economist-go

Más contenido relacionado

La actualidad más candente

Introduction to Smalltalk
Introduction to SmalltalkIntroduction to Smalltalk
Introduction to Smalltalkkim.mens
 
Partial Homomorphic Encryption
Partial Homomorphic EncryptionPartial Homomorphic Encryption
Partial Homomorphic Encryptionsecurityxploded
 
(How) can we benefit from adopting scala?
(How) can we benefit from adopting scala?(How) can we benefit from adopting scala?
(How) can we benefit from adopting scala?Tomasz Wrobel
 
Design and Implementation of the Security Graph Language
Design and Implementation of the Security Graph LanguageDesign and Implementation of the Security Graph Language
Design and Implementation of the Security Graph LanguageAsankhaya Sharma
 
Kotlin a problem solver - gdd extended pune
Kotlin   a problem solver - gdd extended puneKotlin   a problem solver - gdd extended pune
Kotlin a problem solver - gdd extended puneHardik Trivedi
 
Smalltalk, the dynamic language
Smalltalk, the dynamic languageSmalltalk, the dynamic language
Smalltalk, the dynamic languagemohamedsamyali
 
Introduction to kotlin for android app development gdg ahmedabad dev fest 2017
Introduction to kotlin for android app development   gdg ahmedabad dev fest 2017Introduction to kotlin for android app development   gdg ahmedabad dev fest 2017
Introduction to kotlin for android app development gdg ahmedabad dev fest 2017Hardik Trivedi
 
Stream analysis with kafka native way and considerations about monitoring as ...
Stream analysis with kafka native way and considerations about monitoring as ...Stream analysis with kafka native way and considerations about monitoring as ...
Stream analysis with kafka native way and considerations about monitoring as ...Andrew Yongjoon Kong
 
The Ring programming language version 1.2 book - Part 5 of 84
The Ring programming language version 1.2 book - Part 5 of 84The Ring programming language version 1.2 book - Part 5 of 84
The Ring programming language version 1.2 book - Part 5 of 84Mahmoud Samir Fayed
 
12th CBSE Computer Science Project
12th CBSE Computer Science Project  12th CBSE Computer Science Project
12th CBSE Computer Science Project Ashwin Francis
 
Functional, Type-safe, Testable Microservices with ZIO and gRPC
Functional, Type-safe, Testable Microservices with ZIO and gRPCFunctional, Type-safe, Testable Microservices with ZIO and gRPC
Functional, Type-safe, Testable Microservices with ZIO and gRPCNadav Samet
 
CS101- Introduction to Computing- Lecture 29
CS101- Introduction to Computing- Lecture 29CS101- Introduction to Computing- Lecture 29
CS101- Introduction to Computing- Lecture 29Bilal Ahmed
 
06 - Qt Communication
06 - Qt Communication06 - Qt Communication
06 - Qt CommunicationAndreas Jakl
 
Simseer.com - Malware Similarity and Clustering Made Easy
Simseer.com - Malware Similarity and Clustering Made EasySimseer.com - Malware Similarity and Clustering Made Easy
Simseer.com - Malware Similarity and Clustering Made EasySilvio Cesare
 
File Encryption Application For Windows Based On Polyalphabetic Substitution ...
File Encryption Application For Windows Based On Polyalphabetic Substitution ...File Encryption Application For Windows Based On Polyalphabetic Substitution ...
File Encryption Application For Windows Based On Polyalphabetic Substitution ...Sabyasachi Ghosh
 

La actualidad más candente (20)

Introduction to Smalltalk
Introduction to SmalltalkIntroduction to Smalltalk
Introduction to Smalltalk
 
Partial Homomorphic Encryption
Partial Homomorphic EncryptionPartial Homomorphic Encryption
Partial Homomorphic Encryption
 
(How) can we benefit from adopting scala?
(How) can we benefit from adopting scala?(How) can we benefit from adopting scala?
(How) can we benefit from adopting scala?
 
Design and Implementation of the Security Graph Language
Design and Implementation of the Security Graph LanguageDesign and Implementation of the Security Graph Language
Design and Implementation of the Security Graph Language
 
packet destruction in NS2
packet destruction in NS2packet destruction in NS2
packet destruction in NS2
 
NS2 Shadow Object Construction
NS2 Shadow Object ConstructionNS2 Shadow Object Construction
NS2 Shadow Object Construction
 
Kotlin a problem solver - gdd extended pune
Kotlin   a problem solver - gdd extended puneKotlin   a problem solver - gdd extended pune
Kotlin a problem solver - gdd extended pune
 
Smalltalk, the dynamic language
Smalltalk, the dynamic languageSmalltalk, the dynamic language
Smalltalk, the dynamic language
 
Introduction to kotlin for android app development gdg ahmedabad dev fest 2017
Introduction to kotlin for android app development   gdg ahmedabad dev fest 2017Introduction to kotlin for android app development   gdg ahmedabad dev fest 2017
Introduction to kotlin for android app development gdg ahmedabad dev fest 2017
 
Introduction to kotlin
Introduction to kotlinIntroduction to kotlin
Introduction to kotlin
 
Stream analysis with kafka native way and considerations about monitoring as ...
Stream analysis with kafka native way and considerations about monitoring as ...Stream analysis with kafka native way and considerations about monitoring as ...
Stream analysis with kafka native way and considerations about monitoring as ...
 
The Ring programming language version 1.2 book - Part 5 of 84
The Ring programming language version 1.2 book - Part 5 of 84The Ring programming language version 1.2 book - Part 5 of 84
The Ring programming language version 1.2 book - Part 5 of 84
 
12th CBSE Computer Science Project
12th CBSE Computer Science Project  12th CBSE Computer Science Project
12th CBSE Computer Science Project
 
Functional, Type-safe, Testable Microservices with ZIO and gRPC
Functional, Type-safe, Testable Microservices with ZIO and gRPCFunctional, Type-safe, Testable Microservices with ZIO and gRPC
Functional, Type-safe, Testable Microservices with ZIO and gRPC
 
CS101- Introduction to Computing- Lecture 29
CS101- Introduction to Computing- Lecture 29CS101- Introduction to Computing- Lecture 29
CS101- Introduction to Computing- Lecture 29
 
Internship_Mid_Eval.pdf
Internship_Mid_Eval.pdfInternship_Mid_Eval.pdf
Internship_Mid_Eval.pdf
 
06 - Qt Communication
06 - Qt Communication06 - Qt Communication
06 - Qt Communication
 
Computing on Encrypted Data
Computing on Encrypted DataComputing on Encrypted Data
Computing on Encrypted Data
 
Simseer.com - Malware Similarity and Clustering Made Easy
Simseer.com - Malware Similarity and Clustering Made EasySimseer.com - Malware Similarity and Clustering Made Easy
Simseer.com - Malware Similarity and Clustering Made Easy
 
File Encryption Application For Windows Based On Polyalphabetic Substitution ...
File Encryption Application For Windows Based On Polyalphabetic Substitution ...File Encryption Application For Windows Based On Polyalphabetic Substitution ...
File Encryption Application For Windows Based On Polyalphabetic Substitution ...
 

Similar a Digital Publishing for Scale: The Economist and Go

Reactive programming with RxJS - Taiwan
Reactive programming with RxJS - TaiwanReactive programming with RxJS - Taiwan
Reactive programming with RxJS - Taiwanmodernweb
 
GDG Devfest 2019 - Build go kit microservices at kubernetes with ease
GDG Devfest 2019 - Build go kit microservices at kubernetes with easeGDG Devfest 2019 - Build go kit microservices at kubernetes with ease
GDG Devfest 2019 - Build go kit microservices at kubernetes with easeKAI CHU CHUNG
 
Reactive programming every day
Reactive programming every dayReactive programming every day
Reactive programming every dayVadym Khondar
 
Microservices Chaos Testing at Jet
Microservices Chaos Testing at JetMicroservices Chaos Testing at Jet
Microservices Chaos Testing at JetC4Media
 
HashiCorp Vault Plugin Infrastructure
HashiCorp Vault Plugin InfrastructureHashiCorp Vault Plugin Infrastructure
HashiCorp Vault Plugin InfrastructureNicolas Corrarello
 
5 x HTML5 worth using in APEX (5)
5 x HTML5 worth using in APEX (5)5 x HTML5 worth using in APEX (5)
5 x HTML5 worth using in APEX (5)Christian Rokitta
 
2008 - TechDays PT: WCF, JSON and AJAX for performance and manageability
2008 - TechDays PT: WCF, JSON and AJAX for performance and manageability2008 - TechDays PT: WCF, JSON and AJAX for performance and manageability
2008 - TechDays PT: WCF, JSON and AJAX for performance and manageabilityDaniel Fisher
 
Drinking from the Elixir Fountain of Resilience
Drinking from the Elixir Fountain of ResilienceDrinking from the Elixir Fountain of Resilience
Drinking from the Elixir Fountain of ResilienceC4Media
 
Go 1.10 Release Party - PDX Go
Go 1.10 Release Party - PDX GoGo 1.10 Release Party - PDX Go
Go 1.10 Release Party - PDX GoRodolfo Carvalho
 
Writing DSL with Applicative Functors
Writing DSL with Applicative FunctorsWriting DSL with Applicative Functors
Writing DSL with Applicative FunctorsDavid Galichet
 
Inroduction to golang
Inroduction to golangInroduction to golang
Inroduction to golangYoni Davidson
 
Patterns & Practices for Cloud-based Microservices
Patterns & Practices for Cloud-based MicroservicesPatterns & Practices for Cloud-based Microservices
Patterns & Practices for Cloud-based MicroservicesC4Media
 
Spark what's new what's coming
Spark what's new what's comingSpark what's new what's coming
Spark what's new what's comingDatabricks
 
Maximilian Michels – Google Cloud Dataflow on Top of Apache Flink
Maximilian Michels – Google Cloud Dataflow on Top of Apache FlinkMaximilian Michels – Google Cloud Dataflow on Top of Apache Flink
Maximilian Michels – Google Cloud Dataflow on Top of Apache FlinkFlink Forward
 
20230721_OKC_Meetup_MuleSoft.pptx
20230721_OKC_Meetup_MuleSoft.pptx20230721_OKC_Meetup_MuleSoft.pptx
20230721_OKC_Meetup_MuleSoft.pptxDianeKesler1
 
Spicy javascript: Create your first Chrome extension for web analytics QA
Spicy javascript: Create your first Chrome extension for web analytics QASpicy javascript: Create your first Chrome extension for web analytics QA
Spicy javascript: Create your first Chrome extension for web analytics QAAlban Gérôme
 
От Java Threads к лямбдам, Андрей Родионов
От Java Threads к лямбдам, Андрей РодионовОт Java Threads к лямбдам, Андрей Родионов
От Java Threads к лямбдам, Андрей РодионовYandex
 

Similar a Digital Publishing for Scale: The Economist and Go (20)

Reactive programming with RxJS - Taiwan
Reactive programming with RxJS - TaiwanReactive programming with RxJS - Taiwan
Reactive programming with RxJS - Taiwan
 
GDG Devfest 2019 - Build go kit microservices at kubernetes with ease
GDG Devfest 2019 - Build go kit microservices at kubernetes with easeGDG Devfest 2019 - Build go kit microservices at kubernetes with ease
GDG Devfest 2019 - Build go kit microservices at kubernetes with ease
 
Reactive programming every day
Reactive programming every dayReactive programming every day
Reactive programming every day
 
Microservices Chaos Testing at Jet
Microservices Chaos Testing at JetMicroservices Chaos Testing at Jet
Microservices Chaos Testing at Jet
 
HashiCorp Vault Plugin Infrastructure
HashiCorp Vault Plugin InfrastructureHashiCorp Vault Plugin Infrastructure
HashiCorp Vault Plugin Infrastructure
 
5 x HTML5 worth using in APEX (5)
5 x HTML5 worth using in APEX (5)5 x HTML5 worth using in APEX (5)
5 x HTML5 worth using in APEX (5)
 
Android best practices
Android best practicesAndroid best practices
Android best practices
 
2008 - TechDays PT: WCF, JSON and AJAX for performance and manageability
2008 - TechDays PT: WCF, JSON and AJAX for performance and manageability2008 - TechDays PT: WCF, JSON and AJAX for performance and manageability
2008 - TechDays PT: WCF, JSON and AJAX for performance and manageability
 
Drinking from the Elixir Fountain of Resilience
Drinking from the Elixir Fountain of ResilienceDrinking from the Elixir Fountain of Resilience
Drinking from the Elixir Fountain of Resilience
 
Go 1.10 Release Party - PDX Go
Go 1.10 Release Party - PDX GoGo 1.10 Release Party - PDX Go
Go 1.10 Release Party - PDX Go
 
Writing DSL with Applicative Functors
Writing DSL with Applicative FunctorsWriting DSL with Applicative Functors
Writing DSL with Applicative Functors
 
mobl
moblmobl
mobl
 
Inroduction to golang
Inroduction to golangInroduction to golang
Inroduction to golang
 
Patterns & Practices for Cloud-based Microservices
Patterns & Practices for Cloud-based MicroservicesPatterns & Practices for Cloud-based Microservices
Patterns & Practices for Cloud-based Microservices
 
Spark what's new what's coming
Spark what's new what's comingSpark what's new what's coming
Spark what's new what's coming
 
Maximilian Michels – Google Cloud Dataflow on Top of Apache Flink
Maximilian Michels – Google Cloud Dataflow on Top of Apache FlinkMaximilian Michels – Google Cloud Dataflow on Top of Apache Flink
Maximilian Michels – Google Cloud Dataflow on Top of Apache Flink
 
Kubernetes debug like a pro
Kubernetes debug like a proKubernetes debug like a pro
Kubernetes debug like a pro
 
20230721_OKC_Meetup_MuleSoft.pptx
20230721_OKC_Meetup_MuleSoft.pptx20230721_OKC_Meetup_MuleSoft.pptx
20230721_OKC_Meetup_MuleSoft.pptx
 
Spicy javascript: Create your first Chrome extension for web analytics QA
Spicy javascript: Create your first Chrome extension for web analytics QASpicy javascript: Create your first Chrome extension for web analytics QA
Spicy javascript: Create your first Chrome extension for web analytics QA
 
От Java Threads к лямбдам, Андрей Родионов
От Java Threads к лямбдам, Андрей РодионовОт Java Threads к лямбдам, Андрей Родионов
От Java Threads к лямбдам, Андрей Родионов
 

Más de C4Media

Streaming a Million Likes/Second: Real-Time Interactions on Live Video
Streaming a Million Likes/Second: Real-Time Interactions on Live VideoStreaming a Million Likes/Second: Real-Time Interactions on Live Video
Streaming a Million Likes/Second: Real-Time Interactions on Live VideoC4Media
 
Next Generation Client APIs in Envoy Mobile
Next Generation Client APIs in Envoy MobileNext Generation Client APIs in Envoy Mobile
Next Generation Client APIs in Envoy MobileC4Media
 
Software Teams and Teamwork Trends Report Q1 2020
Software Teams and Teamwork Trends Report Q1 2020Software Teams and Teamwork Trends Report Q1 2020
Software Teams and Teamwork Trends Report Q1 2020C4Media
 
Understand the Trade-offs Using Compilers for Java Applications
Understand the Trade-offs Using Compilers for Java ApplicationsUnderstand the Trade-offs Using Compilers for Java Applications
Understand the Trade-offs Using Compilers for Java ApplicationsC4Media
 
Kafka Needs No Keeper
Kafka Needs No KeeperKafka Needs No Keeper
Kafka Needs No KeeperC4Media
 
High Performing Teams Act Like Owners
High Performing Teams Act Like OwnersHigh Performing Teams Act Like Owners
High Performing Teams Act Like OwnersC4Media
 
Does Java Need Inline Types? What Project Valhalla Can Bring to Java
Does Java Need Inline Types? What Project Valhalla Can Bring to JavaDoes Java Need Inline Types? What Project Valhalla Can Bring to Java
Does Java Need Inline Types? What Project Valhalla Can Bring to JavaC4Media
 
Service Meshes- The Ultimate Guide
Service Meshes- The Ultimate GuideService Meshes- The Ultimate Guide
Service Meshes- The Ultimate GuideC4Media
 
Shifting Left with Cloud Native CI/CD
Shifting Left with Cloud Native CI/CDShifting Left with Cloud Native CI/CD
Shifting Left with Cloud Native CI/CDC4Media
 
CI/CD for Machine Learning
CI/CD for Machine LearningCI/CD for Machine Learning
CI/CD for Machine LearningC4Media
 
Fault Tolerance at Speed
Fault Tolerance at SpeedFault Tolerance at Speed
Fault Tolerance at SpeedC4Media
 
Architectures That Scale Deep - Regaining Control in Deep Systems
Architectures That Scale Deep - Regaining Control in Deep SystemsArchitectures That Scale Deep - Regaining Control in Deep Systems
Architectures That Scale Deep - Regaining Control in Deep SystemsC4Media
 
ML in the Browser: Interactive Experiences with Tensorflow.js
ML in the Browser: Interactive Experiences with Tensorflow.jsML in the Browser: Interactive Experiences with Tensorflow.js
ML in the Browser: Interactive Experiences with Tensorflow.jsC4Media
 
Build Your Own WebAssembly Compiler
Build Your Own WebAssembly CompilerBuild Your Own WebAssembly Compiler
Build Your Own WebAssembly CompilerC4Media
 
User & Device Identity for Microservices @ Netflix Scale
User & Device Identity for Microservices @ Netflix ScaleUser & Device Identity for Microservices @ Netflix Scale
User & Device Identity for Microservices @ Netflix ScaleC4Media
 
Scaling Patterns for Netflix's Edge
Scaling Patterns for Netflix's EdgeScaling Patterns for Netflix's Edge
Scaling Patterns for Netflix's EdgeC4Media
 
Make Your Electron App Feel at Home Everywhere
Make Your Electron App Feel at Home EverywhereMake Your Electron App Feel at Home Everywhere
Make Your Electron App Feel at Home EverywhereC4Media
 
The Talk You've Been Await-ing For
The Talk You've Been Await-ing ForThe Talk You've Been Await-ing For
The Talk You've Been Await-ing ForC4Media
 
Future of Data Engineering
Future of Data EngineeringFuture of Data Engineering
Future of Data EngineeringC4Media
 
Automated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and MoreAutomated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and MoreC4Media
 

Más de C4Media (20)

Streaming a Million Likes/Second: Real-Time Interactions on Live Video
Streaming a Million Likes/Second: Real-Time Interactions on Live VideoStreaming a Million Likes/Second: Real-Time Interactions on Live Video
Streaming a Million Likes/Second: Real-Time Interactions on Live Video
 
Next Generation Client APIs in Envoy Mobile
Next Generation Client APIs in Envoy MobileNext Generation Client APIs in Envoy Mobile
Next Generation Client APIs in Envoy Mobile
 
Software Teams and Teamwork Trends Report Q1 2020
Software Teams and Teamwork Trends Report Q1 2020Software Teams and Teamwork Trends Report Q1 2020
Software Teams and Teamwork Trends Report Q1 2020
 
Understand the Trade-offs Using Compilers for Java Applications
Understand the Trade-offs Using Compilers for Java ApplicationsUnderstand the Trade-offs Using Compilers for Java Applications
Understand the Trade-offs Using Compilers for Java Applications
 
Kafka Needs No Keeper
Kafka Needs No KeeperKafka Needs No Keeper
Kafka Needs No Keeper
 
High Performing Teams Act Like Owners
High Performing Teams Act Like OwnersHigh Performing Teams Act Like Owners
High Performing Teams Act Like Owners
 
Does Java Need Inline Types? What Project Valhalla Can Bring to Java
Does Java Need Inline Types? What Project Valhalla Can Bring to JavaDoes Java Need Inline Types? What Project Valhalla Can Bring to Java
Does Java Need Inline Types? What Project Valhalla Can Bring to Java
 
Service Meshes- The Ultimate Guide
Service Meshes- The Ultimate GuideService Meshes- The Ultimate Guide
Service Meshes- The Ultimate Guide
 
Shifting Left with Cloud Native CI/CD
Shifting Left with Cloud Native CI/CDShifting Left with Cloud Native CI/CD
Shifting Left with Cloud Native CI/CD
 
CI/CD for Machine Learning
CI/CD for Machine LearningCI/CD for Machine Learning
CI/CD for Machine Learning
 
Fault Tolerance at Speed
Fault Tolerance at SpeedFault Tolerance at Speed
Fault Tolerance at Speed
 
Architectures That Scale Deep - Regaining Control in Deep Systems
Architectures That Scale Deep - Regaining Control in Deep SystemsArchitectures That Scale Deep - Regaining Control in Deep Systems
Architectures That Scale Deep - Regaining Control in Deep Systems
 
ML in the Browser: Interactive Experiences with Tensorflow.js
ML in the Browser: Interactive Experiences with Tensorflow.jsML in the Browser: Interactive Experiences with Tensorflow.js
ML in the Browser: Interactive Experiences with Tensorflow.js
 
Build Your Own WebAssembly Compiler
Build Your Own WebAssembly CompilerBuild Your Own WebAssembly Compiler
Build Your Own WebAssembly Compiler
 
User & Device Identity for Microservices @ Netflix Scale
User & Device Identity for Microservices @ Netflix ScaleUser & Device Identity for Microservices @ Netflix Scale
User & Device Identity for Microservices @ Netflix Scale
 
Scaling Patterns for Netflix's Edge
Scaling Patterns for Netflix's EdgeScaling Patterns for Netflix's Edge
Scaling Patterns for Netflix's Edge
 
Make Your Electron App Feel at Home Everywhere
Make Your Electron App Feel at Home EverywhereMake Your Electron App Feel at Home Everywhere
Make Your Electron App Feel at Home Everywhere
 
The Talk You've Been Await-ing For
The Talk You've Been Await-ing ForThe Talk You've Been Await-ing For
The Talk You've Been Await-ing For
 
Future of Data Engineering
Future of Data EngineeringFuture of Data Engineering
Future of Data Engineering
 
Automated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and MoreAutomated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and More
 

Último

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 

Último (20)

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 

Digital Publishing for Scale: The Economist and Go

  • 1. Digital Publishing for Scale The Economist and Go Jonas Lead Engineer, Content Platform @yigenana
  • 2. InfoQ.com: News & Community Site • 750,000 unique visitors/month • Published in 4 languages (English, Chinese, Japanese and Brazilian Portuguese) • Post content from our QCon conferences • News 15-20 / week • Articles 3-4 / week • Presentations (videos) 12-15 / week • Interviews 2-3 / week • Books 1 / month Watch the video with slide synchronization on InfoQ.com! https://www.infoq.com/presentations/ the--economist-go
  • 3. Presented at QCon New York www.qconnewyork.com Purpose of QCon - to empower software development by facilitating the spread of knowledge and innovation Strategy - practitioner-driven conference designed for YOU: influencers of change and innovation in your teams - speakers and topics driving the evolution and innovation - connecting and catalyzing the influencers and innovators Highlights - attended by more than 12,000 delegates since 2007 - held in 9 cities worldwide
  • 6.
  • 7. The Happy Path to Go The Platform * AWS hosted * Event Messaging * Worker microservices * Distributed * S3, DynamoDB, and ElasticSearch data stores * RESTful API & GraphQL
  • 8. The Happy Path to Go Key factors * Built in concurrency support enables performance at scale * Strong networking and API support * Compiled language simple to deploy across platforms * Simple design and syntax quickly enables developers
  • 9. Fail Fast: Language Design Application Principles * Minimize startup time * Fail fast * Continuous Integration & Delivery Twelve Factor App
  • 10. Fail Fast: Errors vs Exceptions Errors vs Exception * No exceptions * Error as a type * Failing fast the responsibility of the developer
  • 11. Fail Fast: Error Handling type error interface { Error() string }
  • 12. Fail Fast: Error Handling // New returns an error that formats as the given text. func New(text string) error { return &errorString{text} } // errorString is a trivial implementation of error. type errorString struct { s string } func (e *errorString) Error() string { return e.s }
  • 13. Fail Fast: Error Handling func fetchContent(id string) (string, error) { content, err := fetch(id) if err != nil { // handle the error. } // happy path continues. }
  • 14. Fail Fast: Error Handling package net type Error interface { error Timeout() bool // Is the error a timeout? Temporary() bool // Is the error temporary? } if nerr, ok := err.(net.Error); ok && nerr.Temporary() { time.Sleep(1e9) continue } if err != nil { log.Fatal(err) } From Error Handling in Go
  • 15. Fail Fast: Error Handling Go Error Key Benefits * Handle errors gracefully * Improve debugging and visibility * More user friendly errors responses * Greater reliability
  • 16. Consistency: Language Design The Canonical Article * Standard data model for all content * Aligned to schema.org standards * Hypermedia references to associated content * Query via GraphQL and RESTful API
  • 17. Consistency: Testing main.go package main func Sum(x int, y int) int { return x + y }
  • 18. Consistency: Testing main_test.go package main import "testing" func TestSum(t *testing.T) { total := Sum(1,2) if total != 3 { t.Errorf("Sum incorrect, got: %d, want: %d.", total, 3) } }
  • 19. Consistency: Testing Go Test Features * Cover: Code test coverage * Bench: Runs benchmark tests (Benchxxx) * TestMain: Add extra setup or teardown for tests * Table tests and mocks
  • 20. Consistency: The Challenges One moment an empty value is 0. { "id": "test123", "type": "article", "position": 0 } The next moment it's an empty string! { "id": "test123", "type": "article", "position": "" }
  • 21. Consistency: Serializing Dynamic Content package json // decodeState represents the state while decoding a JSON value. type decodeState struct { data []byte off int // next read offset in data opcode int // last read result scan scanner errorContext struct { // provides context for type errors Struct string Field string } savedError error useNumber bool disallowUnknownFields bool }
  • 22. Consistency: Serializing Dynamic Content func (d *decodeState) value(v reflect.Value) error { case scanBeginArray: if v.IsValid() { if err := d.array(v); err != nil { return err } } else { d.skip() } d.scanNext() case scanBeginObject: if v.IsValid() { if err := d.object(v); err != nil { return err } } else { d.skip() } d.scanNext() return nil }
  • 23. Consistency: Serializing Dynamic Content // convertNumber converts the number literal s to a float64 or a Number // depending on the setting of d.useNumber. func (d *decodeState) convertNumber(s string) (interface{}, error) { if d.useNumber { return Number(s), nil } f, err := strconv.ParseFloat(s, 64) if err != nil { return nil, &UnmarshalTypeError{Value: "number " + s, Type: reflect.TypeOf(0.0), Offset: int64(d.off)} } return f, nil }
  • 24. Consistency: Serializing Dynamic Content package canonical // traverseState represents current state of tree traversal. type traverseState struct { object *s3.Object tags *traverseTags field reflect.StructField treePath string }
  • 25. Consistency: Serializing Dynamic Content // traverse is a top level tree traversal function. func (t traverseState) traverse(v reflect.Value) { switch v.Kind() { case reflect.Struct: switch { case t.field.Tag.Get(refTag) != "": t.setRef(v) default: t.traverseStruct(v) } case reflect.Slice: if t.field.Tag.Get(pathTag) != "" { t.setSlice(v) } case reflect.String, reflect.Bool, reflect.Int, reflect.Float64: if t.field.Tag.Get(pathTag) != "" { t.setPrimitive(v) } default: logger.Warnln("Unknown kind:", v) } }
  • 26. Consistency: Serializing Dynamic Content func toInt(v reflect.Value) int64 { switch v.Type { case int: return v.Int() case string: i, err := strconv.Atoi(v.String()) default: return 0 } }
  • 27. Consistency: Serializing Dynamic Content BenchmarkCustomSerializer-1 1000 1345080 ns/op BenchmarkCustomSerializer-2 1000 1410146 ns/op BenchmarkCustomSerializer-3 1000 1348061 ns/op BenchmarkCustomSerializer-4 1000 1343668 ns/op BenchmarkCustomSerializer-5 1000 1411710 ns/op BenchmarkStandardUnmarshal-1 1000 1451230 ns/op BenchmarkStandardUnmarshal-2 1000 1771896 ns/op BenchmarkStandardUnmarshal-3 1000 1396645 ns/op BenchmarkStandardUnmarshal-4 1000 1720717 ns/op BenchmarkStandardUnmarshal-5 1000 1475672 ns/op
  • 28. Scale: HTTP and concurrency package main import ( "fmt" "log" "net/http" ) func handler(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "Hello World!") } func main() { http.HandleFunc("/", handler) log.Fatal(http.ListenAndServe(":8080", nil)) }
  • 29. Scale: HTTP and concurrency func (srv *Server) Serve(l net.Listener) error { baseCtx := context.Background() // base is always background, per Issue 16220 ctx := context.WithValue(baseCtx, ServerContextKey, srv) for { rw, e := l.Accept() if e != nil { select { case <-srv.getDoneChan(): return ErrServerClosed default: } if ne, ok := e.(net.Error); ok && ne.Temporary() { continue } return e } tempDelay = 0 c := srv.newConn(rw) c.setState(c.rwc, StateNew) // before Serve can return go c.serve(ctx) } }
  • 30. Scale: Content Guarantees CAP Theorum Pick two * Consistency * Availiabity * Partition Tolerance
  • 31. Scale: Content Guarantees func reprocess(searchResult *http.Response) (int, error) { responses := make([]response, len(searchResult.Hits.Hits)) var wg sync.WaitGroup wg.Add(len(responses)) for i, hit := range searchResult.Hits.Hits { wg.Add(1) go func(i int, item elastic.SearchHit) { defer wg.Done() code, err := reprocessItem(item) responses[i].code = code responses[i].err = err }(i, *hit) } wg.Wait return http.StatusOK, nil }
  • 32. Scale: Content Guarantees ProcessTimeAsync-1 20 564.030301ms ProcessTimeAsync-2 20 813.193206ms ProcessTimeAsync-3 20 564.536223ms ProcessTimeAsync-4 20 830.068246ms ProcessTimeAsync-5 20 865.895741ms ProcessTimeSync-1 20 3.806562215s ProcessTimeSync-2 20 4.666270193s ProcessTimeSync-3 20 4.206750535s ProcessTimeSync-4 20 3.745507495s ProcessTimeSync-5 20 4.109966063s Go Concurrency Patterns & Understanding Channels
  • 33. Scale: Visibility with Profiling PPROF * CPU profiles, traces, heap profiles, and mutex profiles. * CLI tool * HTTP Endpoint * Visualizations
  • 37. Embracing Limitations: Metadata Parsing // runExif runs the exiftool command with a set of arguments. func runExif(args []string) ([]byte, error) { cmdOut, err := exec.Command("exiftool", args...).Output() if err != nil { return nil, err } return cmdOut, nil }
  • 38. Embracing Limitations: HTML Maddness <br><em>• Percentage change: shows the change in inflation-adjusted prices between two selected dates</em></p> <p><em><span class="fontcolor-red"><span class="fontcolor-red"> <span class="fontcolor-black"><span class="fontcolor-red"> We also publish interactive house-price guides to</span> &nbsp;</span><a href=""http://www.economist.com/houseprices&quot;">global markets</a></span> &nbsp;<span class="fontcolor-red">and&nbsp;</span> <em><span class="fontcolor-red"><span class="fontcolor-red"> <span class="fontcolor-black"><a href="http://www.economist.com/blogs/graphicdetail/2014/04/british-house-prices">British regions</a>. </span></span></span></em></span></em></p>
  • 39. Embracing Limitations: Simple JSON handling // getLane returns lane information from the // envelope. It uses jsonpointer to access the field // as we want to build on this in a subsequent iteration. const getLane = (event) => { const target = '/envelope/responseElements/queue-source'; return pointer.has(event, target) && pointer.get(event, target); }
  • 40. GOing Retro What Went Well? * Key language design elements for distributed systems * Concurrency model quick to implement * Robust Go tooling that fits into workflow * Fun to write and fun community What Could be Improved? * Versioning and vendoring lack standards * Lacks maturity in some areas * Verbose for certain use cases
  • 42. GOing Retro: Design Systems Design * What are your system goals? * What guarantees are you providing your consumers? * What architecture and patterns are right for your system? * How will your system need to scale?
  • 44. Watch the video with slide synchronization on InfoQ.com! https://www.infoq.com/presentations/ the--economist-go