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

PHP at Google Scale

Terrence Ryan
November 20, 2015

PHP at Google Scale

An overview of all of the ways that PHP developers can use Google Cloud Platform.

Terrence Ryan

November 20, 2015
Tweet

More Decks by Terrence Ryan

Other Decks in Technology

Transcript

  1. // 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); }
  2. ‹#› @tpryan Compute Engine • Infrastructure as a Service •

    VM’s • SSH Access • Multiple performance options
  3. ‹#› @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)
  4. ‹#› @tpryan App Engine • Platform as a Service •

    Built in services • Auto Scaling • Supports: • Java • Python •PHP • Go
  5. ‹#› @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
  6. ‹#› @tpryan App Engine •PHP Support - Version 5.5 -

    cURL now supported - ImageMagick now supported - MongoDB now supported
  7. ‹#› @tpryan Matrix from Hell Dev 1 Laptop Dev 2

    Laptop QA Stage Production OS ? ? ? ? ? Frontend ? ? ? ? ? Services ? ? ? ? ? Database ? ? ? ? ? Logs ? ? ? ? ?
  8. ‹#› @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/
  9. ‹#› @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"]
  10. ‹#› @tpryan Matrix from Hell Dev 1 Laptop Dev 2

    Laptop QA Stage Production OS Frontend Services Database Logs Matrix from Purgatory?
  11. ‹#› @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
  12. ‹#› @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”
  13. ‹#› @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"]
  14. ‹#› @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/
  15. ‹#› @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/
  16. ‹#› @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"]
  17. ‹#› @tpryan Continuum of Computing Compute Engine App Engine Managed

    VMs Auto Scaling Deployment Manager Preemptible VM Click to Deploy Container Engine Load Balancing
  18. ‹#› @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