Slide 1

Slide 1 text

PHP w Google Cloud Sebastian Grodzicki @ PHPCon Poland 2022 @sebgrodzicki

Slide 2

Slide 2 text

phpinfo(); Sebastian Grodzicki 
 • Engineering Manager at • ex-Elastic/SHOWROOM/GoldenLine • PHP developer for 18+ years @sebgrodzicki

Slide 3

Slide 3 text

Compute platforms Compute Engine Kubernetes Engine Cloud Run App Engine Cloud Functions Abstraction Control

Slide 4

Slide 4 text

Cloud Functions

Slide 5

Slide 5 text

What is Cloud Functions? • A serverless environment to build and connect cloud services • Event driven - connect Cloud services 
 - via: Cloud Pub/Sub, Cloud Storage, HTTP requests & more • Serverless 
 - Fully managed execution environment 
 - Pay only for what you use 
 - Autoscales with usage

Slide 6

Slide 6 text

Good fi t? • Serverless • Using Pub/Sub and/or Cloud Storage • Don't want to think about runtime env • Data transformations (ETL) • HTTP glue

Slide 7

Slide 7 text

Constraints? • Function level granularity • Must interact via events • Speci fi c language runtimes (PHP 7.4 & 8.1)

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

App Engine

Slide 12

Slide 12 text

What is App Engine? • Managed app platform (with PHP 5/7/8 support) • No servers to manage, scale up fast, scale down to zero • No patches/updates • Versioning • Tra ffi c splitting • "Serverless" before it was cool ;)

Slide 13

Slide 13 text

Good fi t? • HTTP(S) request-response • Stateless serving applications • Scaling to high tra ffi c

Slide 14

Slide 14 text

Constraints? • Speci fi c language runtimes (standard environment) 
 
 - PHP 5.5 (1st gen) 
 - PHP 7.2 
 - PHP 7.3 
 - PHP 7.4 
 - PHP 8.1 • HTTP(S) only

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

No content

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

Cloud Run

Slide 25

Slide 25 text

Who uses Docker? ȱȱȱȱȱȱȱȱȱȱ

Slide 26

Slide 26 text

Who uses containers in production? ȱȱȱȱȱȱȱȱȱȱ

Slide 27

Slide 27 text

• Performance • Repeatability • Isolation • Portability • …and more! Why containers?

Slide 28

Slide 28 text

What is Cloud Run? • Container image with code listening on $PORT for HTTP • SSL termination • HTTP requests to running containers • 1-1000 concurrent requests • Autoscaling from zero to 1000s of instances • Pay only for actual CPU & memory used @ 100ms granularity

Slide 29

Slide 29 text

Good fi t? • Stateless • HTTP request-response workloads • Scale: way up, down to zero, bursty • Speci fi c runtime requirements (language, dependencies, etc.)

Slide 30

Slide 30 text

Constraints? • Must use containers • Decide on build process (Cloud Build, etc.) • Stateless: no persisted local state

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

No content

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

No content

Slide 36

Slide 36 text

App Engine fl exible environment

Slide 37

Slide 37 text

No content

Slide 38

Slide 38 text

No content

Slide 39

Slide 39 text

Kubernetes Engine

Slide 40

Slide 40 text

• Hosted and managed Kubernetes • Manages the cluster 
 
 - compute nodes 
 - software updates 
 - cluster autoscaling What is Kubernetes Engine?

Slide 41

Slide 41 text

• Run app in multiple environments (multi-cloud, hybrid, dev/ test/prod) • Take full advantage of containers • Have good team communication between dev, ops, security, etc. • Have or want CI/CD pipeline • Network protocols beyond HTTP(S) Good fi t?

Slide 42

Slide 42 text

• Must use containers • Licensing (ex: per-machine) • Some architectural constraints Constraints?

Slide 43

Slide 43 text

• Insulate from infrastructure • Enables high utilization == cost savings • Abstraction sweet spot for many • Choose tools for logging, monitoring, etc. Why Kubernetes?

Slide 44

Slide 44 text

• Managed cluster 
 
 - Focus on your application 
 - Quick start 
 - Automatic updates Why Kubernetes Engine?

Slide 45

Slide 45 text

No content

Slide 46

Slide 46 text

No content

Slide 47

Slide 47 text

Compute Engine

Slide 48

Slide 48 text

• Virtual machines and networking • Per VM max: • 224 vCPUs, 1,792 GB of RAM, 64 TB of disk, 8 GPUs, TPUs 
 - Independently con fi gurable, including disk! • Specialized machine types: 
 - up to 416 vCPU and 12 TB RAM 
 - Shared core small machines What is Compute Engine?

Slide 49

Slide 49 text

• Virtual machines and networking • Start quickly, ~20 seconds to user code running • Pre-built images, or create your own 
 
 - Debian, CentOS, CoreOS, Ubuntu, RHEL, SUSE 
 - Windows Server Datacenter What is Compute Engine?

Slide 50

Slide 50 text

• Persistent Disk • Network based • Con fi gure size (to 64 TB) • HDD or SSD • Independent of VM • Global Snapshots • Multi-VM RO mount • Local SSD • Lowest latency • 375 GB per disk (up to 8) • Tied to VM lifecycle Disk

Slide 51

Slide 51 text

• Run Docker containers directly on container-optimized OS • Managed Instance Groups • template/image based • autoscaling • regional groups (multi-zone) • rolling updates and canaries • Load Balancer More than just VMs

Slide 52

Slide 52 text

• Existing systems (lift and shift) • 1:1 container:VM mapping • Speci fi c OS/kernel required • License requirements • Running databases • Network protocols beyond HTTP(S) Good fi t?

Slide 53

Slide 53 text

• Scaling speed fl oor 
 ~20s per VM, 1000s in ~60s • Decide how to handle software updates Constraints?

Slide 54

Slide 54 text

No content

Slide 55

Slide 55 text

No content

Slide 56

Slide 56 text

No content

Slide 57

Slide 57 text

Compute platforms Compute Engine Kubernetes Engine Cloud Run App Engine Cloud Functions event driven web apps events/web + containers containerized apps existing systems your code your containers { {

Slide 58

Slide 58 text

Abstraction Compute Engine Kubernetes Engine Cloud Run App Engine Cloud Functions Events, function de nitions Code, HTTP Requests Container Runtime Contract, Any language Applications, not computers Your software/operating system Abstraction

Slide 59

Slide 59 text

Control Requirements Compute Engine Kubernetes Engine Cloud Run App Engine Cloud Functions URL routing, tra c splitting Support any language, run in containers GPUs, TPUs, Hybrid, beyond HTTP(S) GPUs, TPUs, speci c kernel, Windows

Slide 60

Slide 60 text

Billing model Compute Engine Kubernetes Engine Cloud Run App Engine Cloud Functions Usage Usage / Resources Resources Resources Usage

Slide 61

Slide 61 text

Teams Compute Engine Kubernetes Engine Cloud Run App Engine Cloud Functions Team is mostly dev focused Team is mostly dev focused Team is mostly dev focused Owns build tool and deployment decisions Dev, Ops, Security work together Org is open to app architecture updates Adaptable to various team structures and tool preferences

Slide 62

Slide 62 text

Project stage Compute Engine Kubernetes Engine Cloud Run App Engine Cloud Functions Migration New project

Slide 63

Slide 63 text

Most systems use multiple services together

Slide 64

Slide 64 text

Cloud 
 Pub/Sub Cloud 
 Storage Cloud 
 Tasks Cloud 
 Scheduler Cloud 
 Datastore Cloud 
 SQL Cloud 
 Spanner Cloud 
 Bigtable BigQuery Cloud 
 Functions App 
 Engine Cloud 
 Run Kubernetes 
 Engine Compute 
 Engine Translation 
 API Natural 
 Language API Speech 
 API Vision 
 API

Slide 65

Slide 65 text

Move up or down abstraction levels Compute Engine Kubernetes Engine Cloud Run App Engine Cloud Functions Abstraction Control

Slide 66

Slide 66 text

Compute platforms Compute Engine Kubernetes Engine Cloud Run App Engine Cloud Functions event driven web apps events/web + containers containerized apps existing systems your code your containers { {

Slide 67

Slide 67 text

Thank you!

Slide 68

Slide 68 text

Questions?