Slide 1

Slide 1 text

Tom Walder | Venditan Commerce Running PHP in Containers on Google Cloud Platform

Slide 2

Slide 2 text

Tom Walder CTO at Venditan Manchester, UK PHP, E-commerce (a developer at heart) Open source, App Engine @tom_walder venditan.com

Slide 3

Slide 3 text

PHP in Containers • Who has used containers before? • Docker? • Kubernetes? • App Engine? • Something else?

Slide 4

Slide 4 text

PHP in Containers on GCP • Build, deploy and test an auto-scaling live demo • Overview of container options for PHP on GCP • What is a PaaS? Google App Engine? • Who uses it, where is the value? • Feature overview • Challenges, pit falls • Scaling & performance • What’s next for App Engine? • Q&A

Slide 5

Slide 5 text

Build, deploy and test an auto-scaling live demo 1. app.yaml 2. main.php 3. Package and deploy to GCP 4. Auto-scale with Firebase + ab

Slide 6

Slide 6 text

Demo

Slide 7

Slide 7 text

• Compute Engine (VM with Docker) • Container Engine / GKE (Kubernetes) • App Engine flex (Docker) • App Engine standard Container Options on GCP

Slide 8

Slide 8 text

App Engine - PaaS by Google

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

A full stack application What might a traditional full stack application look like?

Slide 11

Slide 11 text

A full stack application Application server (PHP) Database server (MySQL) Load Balancers Memcached Server/Daemon Your Code Deploy tool (e.g. Capistrano) Provision (e.g. Puppet) Hardware (or VMs) Apache/nginx Security, users, patching Firewall logrotate Monitoring Centralised logging crontab Queue system (Rabbit?) Search (Elastic/Solr/etc.)

Slide 12

Slide 12 text

A PaaS application Your Code

Slide 13

Slide 13 text

With a PaaS… • You write code, deploy applications • Without researching, selecting, provisioning, maintaining, supporting or updating the infrastructure • You have to work with some (pretty acceptable) limitations

Slide 14

Slide 14 text

App Engine - PaaS by Google • Around since 2008 • Your Code runs in containers • Google servers, data centres (EU/US) • PHP, Python, Java, Go (Standard runtimes)

Slide 15

Slide 15 text

App Engine - PaaS by Google • Worthwhile FREE tier • Documentation • Support (community & paid) • PAYG above free tier • SLA

Slide 16

Slide 16 text

Big Names • Sony Music • Best Buy • Snapchat • Rovio (Angry Birds) • Khan Academy https://cloud.google.com/customers/

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

What is Google App Engine? • Hosting Platform (in Google’s cloud) • Removes (DevOps) headaches • Makes scaling trivial • Prototype/alpha/beta/production • Helps you develop applications faster

Slide 19

Slide 19 text

Some of what you get • Memcache • Cron jobs • Task queues • Load balancing • Auto-scaling • Versions • Traffic splitting • Services (was modules) • HTTP/2 • 28 instance hours FREE • Cloud console • IAM

Slide 20

Slide 20 text

Memcache • No connection details needed (IP/port) • Magic RPC (Protocol Buffers) • make_call() $memcache = new Memcache; return $memcache->get(‘key’);

Slide 21

Slide 21 text

Cron jobs • cron.yaml • HTTP GET cron: - description: summary job url: /tasks/summary schedule: every 5 minutes

Slide 22

Slide 22 text

Task queues • Magic RPC (Protocol Buffers) • HTTP POST • Named Queues, Delays, Processing Rates (new PushTask( ‘/some/worker', ['payload' => ‘data'] ))->add();

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

Cloud Console

Slide 25

Slide 25 text

More of what you get • Geo location headers • Centralised logging • Inbound email (POST) • Traces • Local development SDK • Custom domains • SNI SSL • User authentication • GCS stream handler • Free private git • Security Scanner • Decent documentation

Slide 26

Slide 26 text

Geo headers

Slide 27

Slide 27 text

Traces

Slide 28

Slide 28 text

Traces

Slide 29

Slide 29 text

User authentication • Any Google Account (or Admin only) • $_SERVER - url: .*
 script: main.php
 login: required
 secure: always

Slide 30

Slide 30 text

And more… • Datastore (NoSQL) https://github.com/tomwalder/php-gds • Full text search https://github.com/tomwalder/php-appengine-search

Slide 31

Slide 31 text

Challenges • Read-only file system • PHP 5.5 (Standard Runtime) • MySQL costs money • PHP extensions limited • Gone in 60 seconds

Slide 32

Slide 32 text

Scaling & Performance Options • Instance types - RAM, CPU • Idle instances • Scaling configurations • Auto, Basic, Manual • Rules, latencies etc.

Slide 33

Slide 33 text

Pit falls Avoid vendor lock-in Inject your dependencies

Slide 34

Slide 34 text

Summary

Slide 35

Slide 35 text

No content

Slide 36

Slide 36 text

Recap • Hosting platform (in Google’s cloud) • With extras (queues, crons, inbound mail) • Google do the heavy lifting (DevOps) • Lets you develop applications faster • Worthwhile free tier

Slide 37

Slide 37 text

What’s next for App Engine? • Flexible Runtimes • in BETA • Runs Docker images • So ANYTHING you want • Including PHP 7

Slide 38

Slide 38 text

Questions?

Slide 39

Slide 39 text

Running PHP in Containers on Google Cloud Platform • Code https://github.com/tomwalder • Slides https://speakerdeck.com/tomwalder • Twitter @tom_walder • Email [email protected] • Feedback on the IPC mobile app