33
GO FROM PHP ENGINEER’S PERSPECTIVE SOBIT AKHMEDOV

Go from PHP engineers perspective

Embed Size (px)

Citation preview

Page 1: Go from PHP engineers perspective

GO FROM PHP ENGINEER’S PERSPECTIVE

SOBIT AKHMEDOV

Page 2: Go from PHP engineers perspective

GO FROM PHP ENGINEER’S PERSPECTIVE

PHP FRAMEWORKS

▸ Symfony

▸ Laravel

▸ Zend Framework

Page 3: Go from PHP engineers perspective

GO FROM PHP ENGINEER’S PERSPECTIVE

PHP TOOLS AND COMMUNITY

▸ Composer

▸ Monolog

▸ PHP-FIG

Page 4: Go from PHP engineers perspective

GO FROM PHP ENGINEER’S PERSPECTIVE

THEY STARTED WITH PHP

▸ Facebook

▸ Yahoo!

▸ Wikipedia

▸ Wordpress

▸ Tumblr

Page 5: Go from PHP engineers perspective

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 ✗

Page 6: Go from PHP engineers perspective

MEET GO

Page 7: Go from PHP engineers perspective

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

Page 8: Go from PHP engineers perspective

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

Page 9: Go from PHP engineers perspective

GO FROM PHP ENGINEER’S PERSPECTIVE

BUILT WITH GO

▸ Docker

▸ Kubernetes

▸ etcd

▸ InfluxDb

Page 10: Go from PHP engineers perspective
Page 11: Go from PHP engineers perspective

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

Page 12: Go from PHP engineers perspective

MORE ABOUT GO

Page 13: Go from PHP engineers perspective

GO FROM PHP ENGINEER’S PERSPECTIVE

LANGUAGE

▸ Strictly typed

▸ Type inference

Page 14: Go from PHP engineers perspective

GO FROM PHP ENGINEER’S PERSPECTIVE

LANGUAGE

▸ Multiple return types

Page 15: Go from PHP engineers perspective

GO FROM PHP ENGINEER’S PERSPECTIVE

LANGUAGE

▸ Multiple return types

Page 16: Go from PHP engineers perspective

GO FROM PHP ENGINEER’S PERSPECTIVE

LANGUAGE

▸ No foreach, no while, no do-while

Page 17: Go from PHP engineers perspective

GO FROM PHP ENGINEER’S PERSPECTIVE

LANGUAGE

▸ No foreach, no while, no do-while

Page 18: Go from PHP engineers perspective

GO FROM PHP ENGINEER’S PERSPECTIVE

LANGUAGE

▸ No foreach, no while, no do-while

Page 19: Go from PHP engineers perspective

GO FROM PHP ENGINEER’S PERSPECTIVE

LANGUAGE

▸ No foreach, no while, no do-while

Page 20: Go from PHP engineers perspective

GO FROM PHP ENGINEER’S PERSPECTIVE

LANGUAGE

▸ No classes, only structs

Page 21: Go from PHP engineers perspective

GO FROM PHP ENGINEER’S PERSPECTIVE

LANGUAGE

▸ No classes, only structs

Page 22: Go from PHP engineers perspective

GO FROM PHP ENGINEER’S PERSPECTIVE

LANGUAGE

▸ Goroutine — a function executing concurrently with other goroutines in the same address space

▸ Exits silently on completion

Page 23: Go from PHP engineers perspective

GO FROM PHP ENGINEER’S PERSPECTIVE

LANGUAGE

▸ Goroutine are “fire-and-forget”

▸ Channels - if we need the result

Page 24: Go from PHP engineers perspective

GO FROM PHP ENGINEER’S PERSPECTIVE

TOOLS

▸ go fmt

▸ go doc

▸ go vet

▸ go test

▸ go get github.com/hoisie/redis

▸ … others

Page 25: Go from PHP engineers perspective

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

Page 26: Go from PHP engineers perspective

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

Page 27: Go from PHP engineers perspective

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

Page 28: Go from PHP engineers perspective

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!

Page 29: Go from PHP engineers perspective

CONCLUSION

Page 30: Go from PHP engineers perspective

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

Page 31: Go from PHP engineers perspective

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

Page 32: Go from PHP engineers perspective

QUESTIONS?

GO FROM PHP ENGINEER’S PERSPECTIVE

Page 33: Go from PHP engineers perspective

THANKS!

Sobit Akhmedov