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

Running PHP in Containers on Google Cloud Platform

Tom Walder
October 25, 2016

Running PHP in Containers on Google Cloud Platform

Google App Engine is a container-based, auto-scaling hosting environment (PaaS really), running PHP 5 in Google’s Cloud. It let’s you get off the ground quickly, for FREE – then grow to a much, much larger scale with very little effort. All maintained for you by Google. In 2015, PHP got an SLA, free and commercial support.

I’ll talk about Scaling and Performance options for your application, data storage, Databases, Background processing, Task queues, Crons, Memcache, Full text search, communication in and out of App Engine. A little on modules and how to use the provided SDK to build and develop locally. And we’ll look forward to what’s coming – PHP7 and Docker support! I’ll try and point out some of the pitfalls too. You should leave the talk knowing if App Engine is likely to help you save time and worth adding to your bulging toolkit!

Tom Walder

October 25, 2016
Tweet

More Decks by Tom Walder

Other Decks in Technology

Transcript

  1. Tom Walder CTO at Venditan Manchester, UK PHP, E-commerce (a

    developer at heart) Open source, App Engine @tom_walder venditan.com
  2. PHP in Containers • Who has used containers before? •

    Docker? • Kubernetes? • App Engine? • Something else?
  3. 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
  4. 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
  5. • Compute Engine (VM with Docker) • Container Engine /

    GKE (Kubernetes) • App Engine flex (Docker) • App Engine standard Container Options on GCP
  6. 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.)
  7. 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
  8. 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)
  9. App Engine - PaaS by Google • Worthwhile FREE tier

    • Documentation • Support (community & paid) • PAYG above free tier • SLA
  10. Big Names • Sony Music • Best Buy • Snapchat

    • Rovio (Angry Birds) • Khan Academy https://cloud.google.com/customers/
  11. 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
  12. 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
  13. Memcache • No connection details needed (IP/port) • Magic RPC

    (Protocol Buffers) • make_call() $memcache = new Memcache; return $memcache->get(‘key’);
  14. Cron jobs • cron.yaml • HTTP GET cron: - description:

    summary job url: /tasks/summary schedule: every 5 minutes
  15. Task queues • Magic RPC (Protocol Buffers) • HTTP POST

    • Named Queues, Delays, Processing Rates (new PushTask( ‘/some/worker', ['payload' => ‘data'] ))->add();
  16. 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
  17. User authentication • Any Google Account (or Admin only) •

    $_SERVER - url: .*
 script: main.php
 login: required
 secure: always
  18. Challenges • Read-only file system • PHP 5.5 (Standard Runtime)

    • MySQL costs money • PHP extensions limited • Gone in 60 seconds
  19. Scaling & Performance Options • Instance types - RAM, CPU

    • Idle instances • Scaling configurations • Auto, Basic, Manual • Rules, latencies etc.
  20. 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
  21. What’s next for App Engine? • Flexible Runtimes • in

    BETA • Runs Docker images • So ANYTHING you want • Including PHP 7
  22. 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