Infrastructure Engineeringʁ • Responsible for • DevOps / Reliability / Scalability / Performance / Security / Troubleshooting / … • Works are various and varies by • position / organization structure / authoritiy / speciality
As for me • Basically, • Almost all root-user can doʂ • Especially, • Software Engineering in Infrastructure Usually, I designate myself as Software Engineer in Infrastructure Engineering.
Software Engineering in Infrastructure • Developing & Operating • CLI-tools for operations • e.g. nginx-build, slackboard, cachectl • High performance & Scalable systems (e.g. ↓) • Gaurunʙpush [email protected]ʙ These are built with Go
Reason I select Go • Go has features Software Engineer in Infrastructure Engineering likes • Simple build and deployment • Powerful cuncurrency support • Enough scalability & productivity & robustness • Go fits in many situations as alternative for C and LL
Download concurrently parallels := 0 done := make(chan bool) (...) if *pcreStatic { parallels++ go downloadAndExtractParallel(&pcreBuilder, done) } if *openSSLStatic { parallels++ go downloadAndExtractParallel(&openSSLBuilder, done) } if *zlibStatic { parallels++ go downloadAndExtractParallel(&zlibBuilder, done) } parallels++ go downloadAndExtractParallel(&nginxBuilder, done) (...) for i := 0; i < parallels; i++ { }
Go as alternative for shellscript • Before I started to write nginx-build with shellscript • after 2 hours -> (ϊ ʄДʄ)ϊ~~~ᵲᵲ • I noticed Go fits in this case • Easy to maintain and distribute binary • Cross-platform support
cachectl • Page cache controller • https://github.com/cubicdaiya/cachectl • CLI-tool for controlling page cache for OS • Daemonization as cachectld is available
Seamless combination with C • cachectl requires • communication with system calls (posiv_fadivse, mincore, mmap, etc…) • Go provides FFI (cgo) // C.xxx() are functions came from C world func activePages(path string) int { cs := C.CString(path) result := C.activePages(cs) C.free(unsafe.Pointer(cs)) return int(result) }
Cautions for cgo • Allocated objects must be released manually • Not garvage-collected • e.g. Object generated with C.CString(string) requires C.free() • cgo is possible to cause slow-compilation
slackboard • Slack proxy server • https://github.com/cubicdaiya/slackboard • Building blocks • slackboardʙslack proxy serverʙ • slackboard-cliʙclient for slackboardʙ • slackboard-logʙclient for blackboard like cronlogʙ
Go simplifies deployment • Go programs are available as single-binary • Easy to package with RPM • At mercari, administrators can install and update them with yum • cachectl & slackboard-cli are deployed on all servers at setup
Gaurun • A general push notification server for smartphone application • https://github.com/mercari/gaurun • Proxing push-requests to APNS and GCM • Provides HTTP APIs
Go is powerful • Go provides enough • scalability & productivity & robustness • Gaurun scales easily • 1st version of slackboard was written in 1 hour • mercari.go families work fineʂ
Summary • Go has features Software Engineer in Infrastructure Engineering likes • Simple build and deployment • Powerful cuncurrency support • Enough scalability & productivity & robustness • Go fits in many situations as alternative for C and LL