SlideShare una empresa de Scribd logo
1 de 41
Descargar para leer sin conexión
Go @ Tokopedia Qasim Zaidi
About Tokopedia
• Launched in 2009
• 300K Active merchants
• 8 Million Products
• Indonesia’s biggest online marketplace
• Everyone pays shipping charges
• Shipping is a function of distance
• No discounting or cash-backs, neutral marketplace.
• Most payments are offline
nginx
ssl termination and
proxy pass
nginx-mod_perl
nginx-mod_perl
nginx-mod_perl
The Stack
postgres
mongo
redis
proxy_pass
What we already use go for
• Search & Discovery
• Image Uploads
• Analytics
60% of the time, it works every time.
nginx
ssl termination and
proxy pass
nginx-mod_perl
nginx-mod_perl
nginx-mod_perl
The Stack
postgres
mongo
redis
proxy_pass
mod_perl blocks nginx
isolation is hard
cancellation is harder
Challenges of scaling with mod_perl
• Each request is
synchronously
processed in a worker
• If there is one bad
request, it ends up
queuing everything else.
• Cancellation is not easy
- so even when the user
moves away, the request
continues to run.
In 2012, we bet on node.js
scaled well too - from 50K transactions in 2012 to over a million in 2015
node.js challenges
• Too easy to mess up (dynamic, no type checking)
• linting, code reviews
• Unbounded Concurrency is hard.
• async, promises
• Scale issues with http client for c10k
• even dns latencies can have big impact
Picking a new language in 2015.
the no QA philosophy
QA is not a different role.

Developers are responsible for
testing their code.
Testing in Go
• Easy to write unit tests
func TestFoo(t *testing.T) {
...
}
• run as go test
• No separate frameworks
• Benchmarking is as easy as testing
the no Documentation
philosophy
Code should be self explanatory.

Documentation outside of code is
never updated.
Documentation with GoDoc
• Comments in code - e.g.
preceding function definition
• It extracts the comments
and presents them:
• $ godoc strings Join



func Join(a []string, sep
string) string



Join concatenates the
elements of a to create a
single string. The separator
string sep is placed between
elements in the resulting
string.
// Join concatenates the elements of a to create
a single string.

// The separator string sep is placed between
elements in the resulting string.



func Join(a []string, sep string) string {

//self explanatory blah blah blah

//more of the same
}
godoc - examples and testing
func ExampleJoin() {
s := []string{"foo", "bar", "baz"}
fmt.Println(strings.Join(s, ", "))
// Output: foo, bar, baz
}
• Also integrated with the testing framework to provide testable
example functions.
godoc - webview
Concurrency should
be easy
And not yet forced. 

Too much concurrency spoils the
code.
Code should be hard
to mess with
A compiler that catches bugs

and is not too slow

statically compiled binaries - no
library mess
Institutional knowledge
Go brings google’s institutional
knowledge to you, for free

- Groupcache

- Expvars

- Single-flights and Cancellations
Object Caching
• In node.js - we built in an object caching solution in
house, that can easily make a function called cached
without changing much code.
• var wrapper = cache.wrap(original);
• Can chose whether to cache in memory or redis.
• Can avoid thundering herds - single flighting
Enter group cache
• In memory
• distributed
• single flight
ELB
app
groupcache
app app
groupcachegroupcache
http http
expvars - server metrics over http
• Export variables over http
• http://localhost:8123/debug/vars

{

"cmdline": ["/var/folders/bc/27hv15_d2zvcc3n3s9dxmfg00000gn/T/go-build421732654/command-
line-arguments/_obj/exe/main","-l","debug","-s","i.sock","-c","realtest"],

"counters": {"a": 10, "b": 10},

"memstats": {"Alloc":1076016,"TotalAlloc":1801544,"Sys":5966072,"Lookups":209,"Mallocs":
7986,"Frees":4528,"HeapAlloc":1076016,"HeapSys":2097152,"HeapIdle":327680,"HeapInuse":
1769472,"HeapReleased":0,"HeapObjects":3458,"StackInuse":212992,"StackSys":
917504,"MSpanInuse":21504,"MSpanSys":32768,"MCacheInuse":8800,"MCacheSys":
16384,"BuckHashSys":1441160,"GCSys":1183744,"OtherSys":277360,"NextGC":
1436032,"LastGC":1418102095002592201,"PauseTotalNs":2744531,"PauseNs":
[480149,171430,603839,288381,494934,522995,182803,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"NumGC":7,"EnableGC":true,"DebugGC":false}

}
Cancellations
• User moves away, nginx sends 499, but queries keep
running.
• Not Abandoning work when user has moved away is
often wasteful
• Go’s has advisory cancellations - cancel across go-
routines
• facilitated by contexts
moving from ‘dynamic’ to ‘compiled’
• Deployment changes
• from git clone to compile, build & deploy
• have a way of knowing binary version that is automatic
BUILDHASH=$(shell cd src/$(SRCDIR) && git rev-parse --verify HEAD | cut -c 1-7)

go build —ldflags -X $BUILDHASH
appname —version
• config and code is separate
• make sure everything you may ever need to configure is in config/flags, can’t change
binary
appname —port
appname —configtest
appname —debug
• have good debugging (we have debug() statements that are turned on by —debug flag)
The go workflow
jenkins
dpkg-
buildpackagetriggers build
build dpkg using go get
ansible
srv1 srv1 srv1
elb
nginx
binary, run via upstart
deploy dpkg
restart
2
1
triggers deploy
3
No templates, no exceptions, weird and sometimes inconsistent.
Go is an opinionated language
“Instructions, registers, and assembler
directives are always in UPPER CASE to
remind you that assembly programming is
a fraught endeavor.”
- Rob Pike
-Dick Gabriel, from the golang FAQ
Who would have guessed sophistication
bought such noise?
Golang - missing a package manager?
• go get - but its not complete
• No dependency management, unlike npm, no easy
hermetic builds
• gopkg.in is a solution - allows versioning
• if you have to change versions, edit every single import
Deployment Challenges
• No Fork() - forking with subroutines ain’t easy
• Facebook grace (https://github.com/facebookgo/grace)
• PID changes - no relationship
• problems with upstart / job monitor
• log rotation
Moving from a script to binary
• Deployment changes (from git clone to build, package and deploy)
• Need to know which version of code is running
• appname —version
• Need to debug easily
• appname —debug - enables debug() output
• Keep configuration flexible, because in case of issues, you can’t just edit and
deploy
• appname —configtest
• appname —port (over ride config)
Go @ Tokopedia
• Go is a modern language, very suitable for web.
• Go is Performant, unless you are doing C.
• Go is mostly google still, and not 100% complete.
• Go is opinionated, like Plan9, and there will be a learning
curve.
• Go is slower for prototyping, e.g. when compared to
node.js
Questions?

Más contenido relacionado

La actualidad más candente

THE THREE DISCIPLINES OF CI/CD SECURITY, DANIEL KRIVELEVICH, Cider Security
THE THREE DISCIPLINES OF CI/CD SECURITY, DANIEL KRIVELEVICH, Cider SecurityTHE THREE DISCIPLINES OF CI/CD SECURITY, DANIEL KRIVELEVICH, Cider Security
THE THREE DISCIPLINES OF CI/CD SECURITY, DANIEL KRIVELEVICH, Cider Security
DevOpsDays Tel Aviv
 

La actualidad más candente (20)

デキるプログラマだけが知っているコードレビュー7つの秘訣(DevLove版)
デキるプログラマだけが知っているコードレビュー7つの秘訣(DevLove版)デキるプログラマだけが知っているコードレビュー7つの秘訣(DevLove版)
デキるプログラマだけが知っているコードレビュー7つの秘訣(DevLove版)
 
Cypress e2e automation testing - day1 intor by: Hassan Hameed
Cypress e2e automation testing -  day1 intor by: Hassan HameedCypress e2e automation testing -  day1 intor by: Hassan Hameed
Cypress e2e automation testing - day1 intor by: Hassan Hameed
 
Why you should switch to Cypress for modern web testing?
Why you should switch to Cypress for modern web testing?Why you should switch to Cypress for modern web testing?
Why you should switch to Cypress for modern web testing?
 
conte - ABEMA's Design System
conte - ABEMA's Design Systemconte - ABEMA's Design System
conte - ABEMA's Design System
 
[스마트스터디] 재택근무 잘 하고 있어요
[스마트스터디] 재택근무 잘 하고 있어요[스마트스터디] 재택근무 잘 하고 있어요
[스마트스터디] 재택근무 잘 하고 있어요
 
Professional Services Insights into Improving Sitecore XP
Professional Services Insights into Improving Sitecore XPProfessional Services Insights into Improving Sitecore XP
Professional Services Insights into Improving Sitecore XP
 
Security Testing with Zap
Security Testing with ZapSecurity Testing with Zap
Security Testing with Zap
 
DevOpsを支える原則、3つの道
DevOpsを支える原則、3つの道DevOpsを支える原則、3つの道
DevOpsを支える原則、3つの道
 
【Swift】 それ、enumとstructでやってみましょう!!
【Swift】 それ、enumとstructでやってみましょう!!【Swift】 それ、enumとstructでやってみましょう!!
【Swift】 それ、enumとstructでやってみましょう!!
 
gRPC Design and Implementation
gRPC Design and ImplementationgRPC Design and Implementation
gRPC Design and Implementation
 
Spring IO 2023 - Dynamic OpenAPIs with Spring Cloud Gateway
Spring IO 2023 - Dynamic OpenAPIs with Spring Cloud GatewaySpring IO 2023 - Dynamic OpenAPIs with Spring Cloud Gateway
Spring IO 2023 - Dynamic OpenAPIs with Spring Cloud Gateway
 
Flutterで単体テストを行う方法とGitHub Actionsを使った自動化
Flutterで単体テストを行う方法とGitHub Actionsを使った自動化Flutterで単体テストを行う方法とGitHub Actionsを使った自動化
Flutterで単体テストを行う方法とGitHub Actionsを使った自動化
 
[2022 DevOpsDays Taipei] 走過 DevOps 風雨的下一步
[2022 DevOpsDays Taipei] 走過 DevOps 風雨的下一步[2022 DevOpsDays Taipei] 走過 DevOps 風雨的下一步
[2022 DevOpsDays Taipei] 走過 DevOps 風雨的下一步
 
Clean code with SOLID principles
Clean code with SOLID principlesClean code with SOLID principles
Clean code with SOLID principles
 
Shougoの開発環境
Shougoの開発環境Shougoの開発環境
Shougoの開発環境
 
Why you should care about Go (Golang)
Why you should care about Go (Golang)Why you should care about Go (Golang)
Why you should care about Go (Golang)
 
Cypress - Best Practices
Cypress - Best PracticesCypress - Best Practices
Cypress - Best Practices
 
THE THREE DISCIPLINES OF CI/CD SECURITY, DANIEL KRIVELEVICH, Cider Security
THE THREE DISCIPLINES OF CI/CD SECURITY, DANIEL KRIVELEVICH, Cider SecurityTHE THREE DISCIPLINES OF CI/CD SECURITY, DANIEL KRIVELEVICH, Cider Security
THE THREE DISCIPLINES OF CI/CD SECURITY, DANIEL KRIVELEVICH, Cider Security
 
gRPC and Microservices
gRPC and MicroservicesgRPC and Microservices
gRPC and Microservices
 
How BDD enables True CI/CD
How BDD enables True CI/CDHow BDD enables True CI/CD
How BDD enables True CI/CD
 

Destacado

Presentasi Tokopedia di Bancakan 2.0 3rd meetup
Presentasi Tokopedia di Bancakan 2.0 3rd meetupPresentasi Tokopedia di Bancakan 2.0 3rd meetup
Presentasi Tokopedia di Bancakan 2.0 3rd meetup
Fachry Bafadal
 
Amazon ppt
Amazon pptAmazon ppt
Amazon ppt
aftabssm
 
SISTIM INFORMASI MANAJEMEN BUKALAPAK.COM
SISTIM INFORMASI MANAJEMEN BUKALAPAK.COMSISTIM INFORMASI MANAJEMEN BUKALAPAK.COM
SISTIM INFORMASI MANAJEMEN BUKALAPAK.COM
Niar Afriyani
 

Destacado (19)

Tokopedia - How Tokopedia Became one of Indonesia’s Most Promising Startups
Tokopedia - How Tokopedia Became one of Indonesia’s Most Promising StartupsTokopedia - How Tokopedia Became one of Indonesia’s Most Promising Startups
Tokopedia - How Tokopedia Became one of Indonesia’s Most Promising Startups
 
Presentasi Tokopedia di Bancakan 2.0 3rd meetup
Presentasi Tokopedia di Bancakan 2.0 3rd meetupPresentasi Tokopedia di Bancakan 2.0 3rd meetup
Presentasi Tokopedia di Bancakan 2.0 3rd meetup
 
TOKOPEDIA
TOKOPEDIA TOKOPEDIA
TOKOPEDIA
 
Kopi Chat with William Tanuwijaya founder of Tokopedia
Kopi Chat with William Tanuwijaya founder of TokopediaKopi Chat with William Tanuwijaya founder of Tokopedia
Kopi Chat with William Tanuwijaya founder of Tokopedia
 
Cyber-security
Cyber-securityCyber-security
Cyber-security
 
Statistik 5th anniversary tokopedia di Ecommerce Indonesia
Statistik 5th anniversary tokopedia di Ecommerce IndonesiaStatistik 5th anniversary tokopedia di Ecommerce Indonesia
Statistik 5th anniversary tokopedia di Ecommerce Indonesia
 
Amazon ppt
Amazon pptAmazon ppt
Amazon ppt
 
Amazon.com Strategic Analysis
Amazon.com Strategic AnalysisAmazon.com Strategic Analysis
Amazon.com Strategic Analysis
 
SISTIM INFORMASI MANAJEMEN BUKALAPAK.COM
SISTIM INFORMASI MANAJEMEN BUKALAPAK.COMSISTIM INFORMASI MANAJEMEN BUKALAPAK.COM
SISTIM INFORMASI MANAJEMEN BUKALAPAK.COM
 
500 Startups: Kopi Chat at @Blk71 Singapore
500 Startups: Kopi Chat at @Blk71 Singapore500 Startups: Kopi Chat at @Blk71 Singapore
500 Startups: Kopi Chat at @Blk71 Singapore
 
10 Langkah Strategis Membangun Toko Online Dengan Jejualan.com
10 Langkah Strategis Membangun Toko Online Dengan Jejualan.com10 Langkah Strategis Membangun Toko Online Dengan Jejualan.com
10 Langkah Strategis Membangun Toko Online Dengan Jejualan.com
 
LINE@ Blogger Success Tools & Guidelines
LINE@ Blogger Success Tools & GuidelinesLINE@ Blogger Success Tools & Guidelines
LINE@ Blogger Success Tools & Guidelines
 
Tokopedia & Google Drive
Tokopedia & Google DriveTokopedia & Google Drive
Tokopedia & Google Drive
 
Antresol Pitch Deck
Antresol Pitch DeckAntresol Pitch Deck
Antresol Pitch Deck
 
Media Sosial & Perniagaan Mudah Alih 303 oleh Avana
Media Sosial & Perniagaan Mudah Alih 303 oleh AvanaMedia Sosial & Perniagaan Mudah Alih 303 oleh Avana
Media Sosial & Perniagaan Mudah Alih 303 oleh Avana
 
Marketplace Site Begin To Dominate E-Commerce Marke tin Indonesia 2015
Marketplace Site Begin To Dominate E-Commerce Marke tin Indonesia 2015Marketplace Site Begin To Dominate E-Commerce Marke tin Indonesia 2015
Marketplace Site Begin To Dominate E-Commerce Marke tin Indonesia 2015
 
Liputan #KopdarRpx : SFS Cara Paling Murah dan Mudah Menambah Followers Insta...
Liputan #KopdarRpx : SFS Cara Paling Murah dan Mudah Menambah Followers Insta...Liputan #KopdarRpx : SFS Cara Paling Murah dan Mudah Menambah Followers Insta...
Liputan #KopdarRpx : SFS Cara Paling Murah dan Mudah Menambah Followers Insta...
 
LINE@ reward card manual
LINE@ reward card manualLINE@ reward card manual
LINE@ reward card manual
 
Apple Computers to Apple Inc
Apple Computers to Apple IncApple Computers to Apple Inc
Apple Computers to Apple Inc
 

Similar a Golang @ Tokopedia

Similar a Golang @ Tokopedia (20)

Angular 2 overview
Angular 2 overviewAngular 2 overview
Angular 2 overview
 
How we realized SOA by Python at PyCon JP 2015
How we realized SOA by Python at PyCon JP 2015How we realized SOA by Python at PyCon JP 2015
How we realized SOA by Python at PyCon JP 2015
 
Continuous Development Pipeline
Continuous Development PipelineContinuous Development Pipeline
Continuous Development Pipeline
 
Hadoop: Big Data Stacks validation w/ iTest How to tame the elephant?
Hadoop:  Big Data Stacks validation w/ iTest  How to tame the elephant?Hadoop:  Big Data Stacks validation w/ iTest  How to tame the elephant?
Hadoop: Big Data Stacks validation w/ iTest How to tame the elephant?
 
Deploying software at Scale
Deploying software at ScaleDeploying software at Scale
Deploying software at Scale
 
Google AppEngine (GAE/J) - Introduction and Overview from a Java Guy
Google AppEngine (GAE/J) - Introduction and Overview from a Java GuyGoogle AppEngine (GAE/J) - Introduction and Overview from a Java Guy
Google AppEngine (GAE/J) - Introduction and Overview from a Java Guy
 
Django Deployment with Fabric
Django Deployment with FabricDjango Deployment with Fabric
Django Deployment with Fabric
 
Exploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQLExploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQL
 
Google App Engine Java, Groovy and Gaelyk
Google App Engine Java, Groovy and GaelykGoogle App Engine Java, Groovy and Gaelyk
Google App Engine Java, Groovy and Gaelyk
 
Smarter deployments with octopus deploy
Smarter deployments with octopus deploySmarter deployments with octopus deploy
Smarter deployments with octopus deploy
 
Stackato v6
Stackato v6Stackato v6
Stackato v6
 
SynapseIndia drupal presentation on drupal info
SynapseIndia drupal  presentation on drupal infoSynapseIndia drupal  presentation on drupal info
SynapseIndia drupal presentation on drupal info
 
WTF is Twisted?
WTF is Twisted?WTF is Twisted?
WTF is Twisted?
 
Gophers Riding Elephants: Writing PostgreSQL tools in Go
Gophers Riding Elephants: Writing PostgreSQL tools in GoGophers Riding Elephants: Writing PostgreSQL tools in Go
Gophers Riding Elephants: Writing PostgreSQL tools in Go
 
PHP Mega Meetup, Sep, 2020, Anti patterns in php
PHP Mega Meetup, Sep, 2020, Anti patterns in phpPHP Mega Meetup, Sep, 2020, Anti patterns in php
PHP Mega Meetup, Sep, 2020, Anti patterns in php
 
Using Apache Camel as AKKA
Using Apache Camel as AKKAUsing Apache Camel as AKKA
Using Apache Camel as AKKA
 
Pipeline as code for your infrastructure as Code
Pipeline as code for your infrastructure as CodePipeline as code for your infrastructure as Code
Pipeline as code for your infrastructure as Code
 
SenchaCon 2016: The Modern Toolchain - Ross Gerbasi
SenchaCon 2016: The Modern Toolchain - Ross Gerbasi   SenchaCon 2016: The Modern Toolchain - Ross Gerbasi
SenchaCon 2016: The Modern Toolchain - Ross Gerbasi
 
Developers Testing - Girl Code at bloomon
Developers Testing - Girl Code at bloomonDevelopers Testing - Girl Code at bloomon
Developers Testing - Girl Code at bloomon
 
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
 

Último

一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样
ayvbos
 
一比一原版犹他大学毕业证如何办理
一比一原版犹他大学毕业证如何办理一比一原版犹他大学毕业证如何办理
一比一原版犹他大学毕业证如何办理
F
 
一比一原版(Dundee毕业证书)英国爱丁堡龙比亚大学毕业证如何办理
一比一原版(Dundee毕业证书)英国爱丁堡龙比亚大学毕业证如何办理一比一原版(Dundee毕业证书)英国爱丁堡龙比亚大学毕业证如何办理
一比一原版(Dundee毕业证书)英国爱丁堡龙比亚大学毕业证如何办理
AS
 
一比一原版贝德福特大学毕业证学位证书
一比一原版贝德福特大学毕业证学位证书一比一原版贝德福特大学毕业证学位证书
一比一原版贝德福特大学毕业证学位证书
F
 
Indian Escort in Abu DHabi 0508644382 Abu Dhabi Escorts
Indian Escort in Abu DHabi 0508644382 Abu Dhabi EscortsIndian Escort in Abu DHabi 0508644382 Abu Dhabi Escorts
Indian Escort in Abu DHabi 0508644382 Abu Dhabi Escorts
Monica Sydney
 
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
ayvbos
 
call girls in Anand Vihar (delhi) call me [🔝9953056974🔝] escort service 24X7
call girls in Anand Vihar (delhi) call me [🔝9953056974🔝] escort service 24X7call girls in Anand Vihar (delhi) call me [🔝9953056974🔝] escort service 24X7
call girls in Anand Vihar (delhi) call me [🔝9953056974🔝] escort service 24X7
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
ydyuyu
 
原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查
原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查
原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查
ydyuyu
 
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
ydyuyu
 

Último (20)

APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53
 
Trump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts SweatshirtTrump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts Sweatshirt
 
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样
 
一比一原版犹他大学毕业证如何办理
一比一原版犹他大学毕业证如何办理一比一原版犹他大学毕业证如何办理
一比一原版犹他大学毕业证如何办理
 
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
 
一比一原版(Dundee毕业证书)英国爱丁堡龙比亚大学毕业证如何办理
一比一原版(Dundee毕业证书)英国爱丁堡龙比亚大学毕业证如何办理一比一原版(Dundee毕业证书)英国爱丁堡龙比亚大学毕业证如何办理
一比一原版(Dundee毕业证书)英国爱丁堡龙比亚大学毕业证如何办理
 
一比一原版贝德福特大学毕业证学位证书
一比一原版贝德福特大学毕业证学位证书一比一原版贝德福特大学毕业证学位证书
一比一原版贝德福特大学毕业证学位证书
 
Indian Escort in Abu DHabi 0508644382 Abu Dhabi Escorts
Indian Escort in Abu DHabi 0508644382 Abu Dhabi EscortsIndian Escort in Abu DHabi 0508644382 Abu Dhabi Escorts
Indian Escort in Abu DHabi 0508644382 Abu Dhabi Escorts
 
Local Call Girls in Gomati 9332606886 HOT & SEXY Models beautiful and charmi...
Local Call Girls in Gomati  9332606886 HOT & SEXY Models beautiful and charmi...Local Call Girls in Gomati  9332606886 HOT & SEXY Models beautiful and charmi...
Local Call Girls in Gomati 9332606886 HOT & SEXY Models beautiful and charmi...
 
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
 
"Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency""Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency"
 
call girls in Anand Vihar (delhi) call me [🔝9953056974🔝] escort service 24X7
call girls in Anand Vihar (delhi) call me [🔝9953056974🔝] escort service 24X7call girls in Anand Vihar (delhi) call me [🔝9953056974🔝] escort service 24X7
call girls in Anand Vihar (delhi) call me [🔝9953056974🔝] escort service 24X7
 
Call girls Service in Ajman 0505086370 Ajman call girls
Call girls Service in Ajman 0505086370 Ajman call girlsCall girls Service in Ajman 0505086370 Ajman call girls
Call girls Service in Ajman 0505086370 Ajman call girls
 
PIC Microcontroller Structure & Assembly Language.ppsx
PIC Microcontroller Structure & Assembly Language.ppsxPIC Microcontroller Structure & Assembly Language.ppsx
PIC Microcontroller Structure & Assembly Language.ppsx
 
Vip Firozabad Phone 8250092165 Escorts Service At 6k To 30k Along With Ac Room
Vip Firozabad Phone 8250092165 Escorts Service At 6k To 30k Along With Ac RoomVip Firozabad Phone 8250092165 Escorts Service At 6k To 30k Along With Ac Room
Vip Firozabad Phone 8250092165 Escorts Service At 6k To 30k Along With Ac Room
 
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
 
原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查
原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查
原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查
 
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
 
Sensual Call Girls in Tarn Taran Sahib { 9332606886 } VVIP NISHA Call Girls N...
Sensual Call Girls in Tarn Taran Sahib { 9332606886 } VVIP NISHA Call Girls N...Sensual Call Girls in Tarn Taran Sahib { 9332606886 } VVIP NISHA Call Girls N...
Sensual Call Girls in Tarn Taran Sahib { 9332606886 } VVIP NISHA Call Girls N...
 
Leading-edge AI Image Generators of 2024
Leading-edge AI Image Generators of 2024Leading-edge AI Image Generators of 2024
Leading-edge AI Image Generators of 2024
 

Golang @ Tokopedia

  • 1. Go @ Tokopedia Qasim Zaidi
  • 2. About Tokopedia • Launched in 2009 • 300K Active merchants • 8 Million Products • Indonesia’s biggest online marketplace • Everyone pays shipping charges • Shipping is a function of distance • No discounting or cash-backs, neutral marketplace. • Most payments are offline
  • 3. nginx ssl termination and proxy pass nginx-mod_perl nginx-mod_perl nginx-mod_perl The Stack postgres mongo redis proxy_pass
  • 4. What we already use go for • Search & Discovery • Image Uploads • Analytics
  • 5.
  • 6.
  • 7.
  • 8. 60% of the time, it works every time.
  • 9. nginx ssl termination and proxy pass nginx-mod_perl nginx-mod_perl nginx-mod_perl The Stack postgres mongo redis proxy_pass mod_perl blocks nginx isolation is hard cancellation is harder
  • 10. Challenges of scaling with mod_perl • Each request is synchronously processed in a worker • If there is one bad request, it ends up queuing everything else. • Cancellation is not easy - so even when the user moves away, the request continues to run.
  • 11.
  • 12.
  • 13. In 2012, we bet on node.js
  • 14. scaled well too - from 50K transactions in 2012 to over a million in 2015
  • 15. node.js challenges • Too easy to mess up (dynamic, no type checking) • linting, code reviews • Unbounded Concurrency is hard. • async, promises • Scale issues with http client for c10k • even dns latencies can have big impact
  • 16. Picking a new language in 2015.
  • 17. the no QA philosophy QA is not a different role. Developers are responsible for testing their code.
  • 18. Testing in Go • Easy to write unit tests func TestFoo(t *testing.T) { ... } • run as go test • No separate frameworks • Benchmarking is as easy as testing
  • 19. the no Documentation philosophy Code should be self explanatory. Documentation outside of code is never updated.
  • 20. Documentation with GoDoc • Comments in code - e.g. preceding function definition • It extracts the comments and presents them: • $ godoc strings Join
 
 func Join(a []string, sep string) string
 
 Join concatenates the elements of a to create a single string. The separator string sep is placed between elements in the resulting string. // Join concatenates the elements of a to create a single string.
 // The separator string sep is placed between elements in the resulting string.
 
 func Join(a []string, sep string) string {
 //self explanatory blah blah blah
 //more of the same }
  • 21. godoc - examples and testing func ExampleJoin() { s := []string{"foo", "bar", "baz"} fmt.Println(strings.Join(s, ", ")) // Output: foo, bar, baz } • Also integrated with the testing framework to provide testable example functions.
  • 23. Concurrency should be easy And not yet forced. Too much concurrency spoils the code.
  • 24. Code should be hard to mess with A compiler that catches bugs and is not too slow statically compiled binaries - no library mess
  • 25. Institutional knowledge Go brings google’s institutional knowledge to you, for free - Groupcache - Expvars - Single-flights and Cancellations
  • 26. Object Caching • In node.js - we built in an object caching solution in house, that can easily make a function called cached without changing much code. • var wrapper = cache.wrap(original); • Can chose whether to cache in memory or redis. • Can avoid thundering herds - single flighting
  • 27. Enter group cache • In memory • distributed • single flight ELB app groupcache app app groupcachegroupcache http http
  • 28. expvars - server metrics over http • Export variables over http • http://localhost:8123/debug/vars
 {
 "cmdline": ["/var/folders/bc/27hv15_d2zvcc3n3s9dxmfg00000gn/T/go-build421732654/command- line-arguments/_obj/exe/main","-l","debug","-s","i.sock","-c","realtest"],
 "counters": {"a": 10, "b": 10},
 "memstats": {"Alloc":1076016,"TotalAlloc":1801544,"Sys":5966072,"Lookups":209,"Mallocs": 7986,"Frees":4528,"HeapAlloc":1076016,"HeapSys":2097152,"HeapIdle":327680,"HeapInuse": 1769472,"HeapReleased":0,"HeapObjects":3458,"StackInuse":212992,"StackSys": 917504,"MSpanInuse":21504,"MSpanSys":32768,"MCacheInuse":8800,"MCacheSys": 16384,"BuckHashSys":1441160,"GCSys":1183744,"OtherSys":277360,"NextGC": 1436032,"LastGC":1418102095002592201,"PauseTotalNs":2744531,"PauseNs": [480149,171430,603839,288381,494934,522995,182803,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"NumGC":7,"EnableGC":true,"DebugGC":false}
 }
  • 29. Cancellations • User moves away, nginx sends 499, but queries keep running. • Not Abandoning work when user has moved away is often wasteful • Go’s has advisory cancellations - cancel across go- routines • facilitated by contexts
  • 30. moving from ‘dynamic’ to ‘compiled’ • Deployment changes • from git clone to compile, build & deploy • have a way of knowing binary version that is automatic BUILDHASH=$(shell cd src/$(SRCDIR) && git rev-parse --verify HEAD | cut -c 1-7)
 go build —ldflags -X $BUILDHASH appname —version • config and code is separate • make sure everything you may ever need to configure is in config/flags, can’t change binary appname —port appname —configtest appname —debug • have good debugging (we have debug() statements that are turned on by —debug flag)
  • 31. The go workflow jenkins dpkg- buildpackagetriggers build build dpkg using go get ansible srv1 srv1 srv1 elb nginx binary, run via upstart deploy dpkg restart 2 1 triggers deploy 3
  • 32. No templates, no exceptions, weird and sometimes inconsistent. Go is an opinionated language “Instructions, registers, and assembler directives are always in UPPER CASE to remind you that assembly programming is a fraught endeavor.” - Rob Pike
  • 33. -Dick Gabriel, from the golang FAQ Who would have guessed sophistication bought such noise?
  • 34. Golang - missing a package manager? • go get - but its not complete • No dependency management, unlike npm, no easy hermetic builds • gopkg.in is a solution - allows versioning • if you have to change versions, edit every single import
  • 35.
  • 36.
  • 37. Deployment Challenges • No Fork() - forking with subroutines ain’t easy • Facebook grace (https://github.com/facebookgo/grace) • PID changes - no relationship • problems with upstart / job monitor • log rotation
  • 38.
  • 39. Moving from a script to binary • Deployment changes (from git clone to build, package and deploy) • Need to know which version of code is running • appname —version • Need to debug easily • appname —debug - enables debug() output • Keep configuration flexible, because in case of issues, you can’t just edit and deploy • appname —configtest • appname —port (over ride config)
  • 40. Go @ Tokopedia • Go is a modern language, very suitable for web. • Go is Performant, unless you are doing C. • Go is mostly google still, and not 100% complete. • Go is opinionated, like Plan9, and there will be a learning curve. • Go is slower for prototyping, e.g. when compared to node.js