Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Go from PHP engineer's perspective

Go from PHP engineer's perspective

Introduction to Go programming language from PHP engineer's perspective.

The topic was presented at GetYourGuide’s internal tech talk. The original article can be found here: http://sobit.me/2016/02/25/go-from-php-engineers-perspective/

Sobit Akhmedov

March 17, 2016
Tweet

Other Decks in Programming

Transcript

  1. GO FROM PHP ENGINEER’S PERSPECTIVE THEY STARTED WITH PHP ▸

    Facebook ▸ Yahoo! ▸ Wikipedia ▸ Wordpress ▸ Tumblr
  2. GO FROM PHP ENGINEER’S PERSPECTIVE PHP AND MICROSERVICES ▸ Good

    response time on single application only ✓ ▸ Good for WEB development ✓ ▸ Bad for microservices architectures: ✗ ▸ Timeout handling ✗ ▸ Metrics collection ✗ ▸ Bulkheads ✗ ▸ Circuit breakers ✗
  3. GO (OFTEN REFERRED TO AS GOLANG) IS AN OPEN SOURCE

    PROGRAMMING LANGUAGE DEVELOPED AT GOOGLE IN 2007 BY ROBERT GRIESEMER, ROB PIKE, AND KEN THOMPSON. DESIGNED PRIMARILY FOR SYSTEMS PROGRAMMING, IT IS A COMPILED, STATICALLY TYPED LANGUAGE IN THE TRADITION OF C AND C++, WITH GARBAGE COLLECTION, VARIOUS SAFETY FEATURES AND CSP-STYLE CONCURRENT PROGRAMMING FEATURES ADDED. Wikipedia GO FROM PHP ENGINEER’S PERSPECTIVE
  4. GO FROM PHP ENGINEER’S PERSPECTIVE MEET GO ▸ Developed at

    Google in 2007 ▸ Due to the frustration of dealing with the complexity ▸ Announced in November 2009 ▸ Special feature: extreme simplicity ▸ Go: 25 keywords ▸ PHP: 67 keywords
  5. GO FROM PHP ENGINEER’S PERSPECTIVE GO AND MICROSERVICES ▸ Fast

    compilation ▸ Parallel execution ▸ Transport protocols ▸ JSON over HTTP, gRPC, Protocol Buffers, Thrift ▸ Request tracing in Zipkin ▸ Metrics exporting to statsd, Prometheus, etc. ▸ Rate limiters ▸ … others
  6. GO FROM PHP ENGINEER’S PERSPECTIVE LANGUAGE ▸ Goroutine — a

    function executing concurrently with other goroutines in the same address space ▸ Exits silently on completion
  7. GO FROM PHP ENGINEER’S PERSPECTIVE TOOLS ▸ go fmt ▸

    go doc ▸ go vet ▸ go test ▸ go get github.com/hoisie/redis ▸ … others
  8. GO FROM PHP ENGINEER’S PERSPECTIVE DEPLOYING PHP APPLICATION (BASIC) ▸

    Checkout the latest code on the target server into a new release folder ▸ Copy cached dependencies and install updated ones ▸ Copy environment-specific configuration files ▸ Run all the scripts to warm the application up ▸ Point the current release symlink into the new release folder ▸ Restart PHP-FPM
  9. GO FROM PHP ENGINEER’S PERSPECTIVE DEPLOYING PHP APPLICATION (ADVANCED) ▸

    Checkout the latest code on the build server ▸ “Build” it (install dependencies, warm the caches up, etc.) ▸ Create a distributable “artifact” (an archived tar.gz file) ▸ Transfer the artifact to the target server ▸ Unarchive into a new release folder ▸ Point the current release symlink into the new release folder ▸ Restart PHP-FPM
  10. GO FROM PHP ENGINEER’S PERSPECTIVE DEPLOYING GO APPLICATION ▸ Checkout

    the latest code on the build server ▸ Build it (note the absence of quotes) ▸ Transfer the artifact (again no quotes) to the target server ▸ Restart the running application
  11. GO FROM PHP ENGINEER’S PERSPECTIVE DEPLOYING GO APPLICATION ▸ No

    need to install Go on target servers ▸ Builds for different OS and architectures ▸ From single machine ▸ Even for Windows!
  12. GO FROM PHP ENGINEER’S PERSPECTIVE CONCLUSION ▸ Premature decomposition =

    failure ▸ PHP fits monolithic application strategy ▸ Building microservices with PHP is painful ▸ Consider Go ▸ Easier than Java or Scala ▸ Performance is not far behind C
  13. GO FROM PHP ENGINEER’S PERSPECTIVE HOW CAN I CONTINUE? ▸

    Learn: https://golang.org/doc/#learning ▸ Learn more: https://github.com/golang/go/wiki/Learn ▸ IDEs: https://github.com/golang/go/wiki/IDEsAndTextEditorPlugins ▸ https://github.com/go-lang-plugin-org/go-lang-idea-plugin ▸ Go kit: https://github.com/go-kit/kit ▸ Client-side Go: http://www.gopherjs.org/ ▸ Go for mobile apps: https://github.com/golang/go/wiki/Mobile