Slide 1

Slide 1 text

‹#› @tpryan Terry Ryan Developer Advocate PHP at Google Scale

Slide 2

Slide 2 text

@tpryan Who are you?

Slide 3

Slide 3 text

‹#› @tpryan 01 Introduction

Slide 4

Slide 4 text

@tpryan So you want to make an app…

Slide 5

Slide 5 text

// breakstring breaks a string into all substrings with a length // greater than min, returning ... private function breakString($str, $min){ $res = []; $len = strlen($str); for ($i = $min; $i <= $len; $i++){ for ($j = 0; $j<($len-$min); $j++){ $part = strtoupper(substr($str, $j, $i)); if (strlen($part) >= $i){ $res[$part] = 0; } } } return array_keys($res); }

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

@tpryan

Slide 9

Slide 9 text

@tpryan

Slide 10

Slide 10 text

@tpryan

Slide 11

Slide 11 text

@tpryan

Slide 12

Slide 12 text

@tpryan

Slide 13

Slide 13 text

@tpryan ‹#› Google Cloud Platform Compute Connectivity Big Data Storage Developer Tools Mobile Management

Slide 14

Slide 14 text

@tpryan Compute Engine App Engine Convenience Control

Slide 15

Slide 15 text

‹#› @tpryan I want to control all the things…

Slide 16

Slide 16 text

‹#› @tpryan 02 Compute Engine I want to control all the things…

Slide 17

Slide 17 text

‹#› @tpryan Compute Engine • Infrastructure as a Service • VM’s • SSH Access • Multiple performance options

Slide 18

Slide 18 text

@tpryan ‹#› Compute Engine

Slide 19

Slide 19 text

‹#› @tpryan Demo: Compute Engine

Slide 20

Slide 20 text

‹#› @tpryan Compute Engine Pros • Infinitely configurable • Manual scaling • Startup time: 10s of seconds • Many performance options Cons • Management is on you • Scale is on you (we can help)

Slide 21

Slide 21 text

@tpryan That seems like a lot of work…

Slide 22

Slide 22 text

‹#› @tpryan Cloud Launcher • Spawn prepackaged machines • Bitnami • Click to Deploy

Slide 23

Slide 23 text

‹#› @tpryan Demo: Cloud Launcher

Slide 24

Slide 24 text

‹#› @tpryan I’m dev not devops

Slide 25

Slide 25 text

‹#› @tpryan 03 App Engine I’m dev not devops

Slide 26

Slide 26 text

‹#› @tpryan App Engine • Platform as a Service • Built in services • Auto Scaling • Supports: • Java • Python •PHP • Go

Slide 27

Slide 27 text

@tpryan ‹#› App Engine yourapp.appspot.com

Slide 28

Slide 28 text

@tpryan ‹#› App Engine yourapp.appspot.com

Slide 29

Slide 29 text

‹#› @tpryan Demo: App Engine

Slide 30

Slide 30 text

‹#› @tpryan App Engine Pros • No use, no charge • Massively scalable • Start up time: milliseconds • Quota to prevent fiscal disaster Cons • Language choices • API’s • No third party executable

Slide 31

Slide 31 text

@tpryan I’ve tried PHP on App Engine before and…

Slide 32

Slide 32 text

‹#› @tpryan App Engine •PHP Support - Version 5.5 - cURL now supported - ImageMagick now supported - MongoDB now supported

Slide 33

Slide 33 text

‹#› @tpryan I want a middle option

Slide 34

Slide 34 text

‹#› @tpryan 04 Container Engine I want a middle option

Slide 35

Slide 35 text

‹#› @tpryan 04.1 Containers Have you met Containers?

Slide 36

Slide 36 text

‹#› @tpryan Matrix from Hell Dev 1 Laptop Dev 2 Laptop QA Stage Production OS ? ? ? ? ? Frontend ? ? ? ? ? Services ? ? ? ? ? Database ? ? ? ? ? Logs ? ? ? ? ?

Slide 37

Slide 37 text

‹#› @tpryan Matrix from Hell Dev 1 Laptop Dev 2 Laptop QA Stage Production OS OS X Windows Debian Debian Debian Frontend nginx (homebrew) nginx (download) nginx (apt-get) nginx (apt-get) nginx (apt-get) Services php (homebrew) php (download) php (apt-get) php (apt-get) php (apt-get) Database mysql (download) mysql (download) mysql (apt-get) mysql (apt-get) mysql (apt-get) Logs /usr/local/etc/nginx/logs/ C:\nginx-1.9.5\logs /var/log/nginx/ /var/log/nginx/ /var/log/nginx/

Slide 38

Slide 38 text

‹#› @tpryan Hypervisor Virtual Machine OS OS OS

Slide 39

Slide 39 text

‹#› @tpryan

Slide 40

Slide 40 text

‹#› @tpryan Container Host Containers OS

Slide 41

Slide 41 text

‹#› @tpryan Dockerfile FROM php:5.6-apache RUN apt-get update && apt-get -y install \ curl \ php5-mysqlnd \ php-pear \ zlib1g-dev RUN docker-php-ext-install mysqli COPY php.ini /usr/local/etc/php/ COPY startup.sh /usr/local/bin/ RUN chmod 755 /usr/local/bin/startup.sh ADD default /var/www/html CMD ["/usr/local/bin/startup.sh"]

Slide 42

Slide 42 text

‹#› @tpryan Matrix from Hell Dev 1 Laptop Dev 2 Laptop QA Stage Production OS Frontend Services Database Logs Matrix from Purgatory?

Slide 43

Slide 43 text

‹#› @tpryan Continuum of Computing Compute Engine App Engine Container Engine

Slide 44

Slide 44 text

‹#› @tpryan Container Engine •Containers as a Service ?? •Kubernetes •Declarative Configuration

Slide 45

Slide 45 text

‹#› @tpryan Cattle, not Pets

Slide 46

Slide 46 text

‹#› @tpryan Cattle • Has a number • One is much like any other • Run as a group • If it gets ill, you make hamburgers Pet • Has a name • Is unique or rare • Personal Attention • If it gets ill… you make it better

Slide 47

Slide 47 text

‹#› @tpryan Desired State

Slide 48

Slide 48 text

‹#› @tpryan Employees, not Children

Slide 49

Slide 49 text

‹#› @tpryan Child • Go upstairs • Get undressed • Put on pajamas • Brush your teeth • Pick out 2 stories Employee • “We had a tough day, go home and get some sleep”

Slide 50

Slide 50 text

‹#› @tpryan Build Script ./create_docker_images.sh ./launch_frontend.sh x 3 ./launch_services.sh x 2 ./launch_backend.sh x 1

Slide 51

Slide 51 text

‹#› @tpryan Build Script ./create_docker_images.sh ./launch_frontend.sh x 3 ./launch_services.sh x 2 ./launch_backend.sh x 1

Slide 52

Slide 52 text

‹#› @tpryan Desired State There should be: 3 Frontends 2 Services 1 Backend

Slide 53

Slide 53 text

‹#› @tpryan # FRONTEND AND SERVICES FROM nginx-php-fpm COPY nginx.conf /etc/nginx/nginx.conf ADD www /var/www/

Slide 54

Slide 54 text

‹#› @tpryan # BACKEND FROM ubuntu:12.04 ADD ./mysql-setup.sh /tmp/mysql-setup.sh RUN /bin/sh /tmp/mysql-setup.sh EXPOSE 3306 CMD ["/usr/sbin/mysqld"]

Slide 55

Slide 55 text

‹#› @tpryan

Slide 56

Slide 56 text

‹#› @tpryan # FRONTEND AND SERVICES FROM nginx-php-fpm COPY nginx.conf /etc/nginx/nginx.conf ADD www /var/www/ # JUST SERVICES FROM nginx-php-fpm COPY nginx.conf /etc/nginx/nginx.conf ADD www /var/www/

Slide 57

Slide 57 text

‹#› @tpryan # FRONTEND AND SERVICES FROM nginx-php-fpm COPY nginx.conf /etc/nginx/nginx.conf ADD www /var/www/ # FRONTEND FROM nginx COPY nginx.conf /etc/nginx/nginx.conf ADD www /var/www/

Slide 58

Slide 58 text

‹#› @tpryan

Slide 59

Slide 59 text

‹#› @tpryan # BACKEND FROM ubuntu:12.04 ADD ./mysql-setup.sh /tmp/mysql-setup.sh RUN /bin/sh /tmp/mysql-setup.sh EXPOSE 3306 CMD ["/usr/sbin/mysqld"] # BACKEND FROM ubuntu:12.04 ADD ./mysql-setup.sh /tmp/mysql-setup.sh RUN /bin/sh /tmp/mysql-setup.sh EXPOSE 3306 VOLUME ["/etc/mysql", "/var/lib/mysql"] CMD ["/usr/sbin/mysqld"]

Slide 60

Slide 60 text

‹#› @tpryan

Slide 61

Slide 61 text

‹#› @tpryan

Slide 62

Slide 62 text

‹#› @tpryan

Slide 63

Slide 63 text

‹#› @tpryan

Slide 64

Slide 64 text

‹#› @tpryan

Slide 65

Slide 65 text

‹#› @tpryan That’s a lot to manage.

Slide 66

Slide 66 text

‹#› @tpryan 4 3 2

Slide 67

Slide 67 text

‹#› @tpryan Demo: Container Engine

Slide 68

Slide 68 text

‹#› @tpryan 06 Conclusions Bring it home

Slide 69

Slide 69 text

‹#› @tpryan Continuum of Computing Compute Engine App Engine Managed VMs Auto Scaling Deployment Manager Preemptible VM Click to Deploy Container Engine Load Balancing

Slide 70

Slide 70 text

‹#› @tpryan Control If you want to control everything. You can. Three takeaways Convenience If you would prefer to let us be your sysadmin. You can. Continuum Most realistic scenarios will require combinations

Slide 71

Slide 71 text

‹#› @tpryan Thank You terrenceryan.com @tpryan Feedback: https://joind.in/14811 This preso: http://bit.ly/tpryan-php