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

Google App Engine - a PHP PaaS from Prototyping to Production

Google App Engine - a PHP PaaS from Prototyping to Production

App Engine is a container-based, auto-scaling hosting environment (PaaS really), running PHP.

It let’s you get off the ground quickly, for FREE - then grow to a much, much larger scale with little or no effort.

It went “Generally Available” in 2015, so has both free and commercial support from Google.

I'll talk about Scaling and Performance options for your application. What’s free and what’s not, Data storage, Databases, Background processing, Task queues, Crons, Memcache, Full text search, communication in & out of App Engine, Community & Commercial support and Deployments. Maybe a bit on modules and how to use the Google-provided SDK to build and develop locally.

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 money or add something useful to your already bulging toolkit!

Tom Walder

June 01, 2016
Tweet

More Decks by Tom Walder

Other Decks in Technology

Transcript

  1. Tom Walder | @tom_walder
    Google App Engine - a PHP PaaS
    from Prototyping to Production

    View Slide

  2. Tom Walder
    CTO at Docnet+Venditan
    in Manchester, UK
    PHP, E-commerce
    (a developer at heart)
    Open source, App Engine
    @tom_walder
    docnet.nu | venditan.com Compulsory (old) Holiday Photo

    View Slide

  3. I am going to talk about…
    • What I have learned using
    Google App Engine from
    Prototyping to Production
    • What is a PaaS, Google
    App Engine?
    • Who uses it, where is the
    value?
    • Feature overview
    • Some key features in more
    detail
    • Challenges, pit falls
    • Scaling & performance
    • Live scaling demo*
    • What’s next for App
    Engine?

    View Slide

  4. View Slide

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

    View Slide

  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.)

    View Slide

  7. A PaaS application?
    Your Code

    View Slide

  8. 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

    View Slide

  9. 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)

    View Slide

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

    View Slide

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

    View Slide

  12. Where’s the value?
    “If we didn't have App Engine, we'd be spending a lot more time
    figuring out server setup and working on routers” Khan Academy
    “Developing apps on App Engine takes one-fourth to one-tenth
    of the resources and one-fourth of the time compared to
    building something ourselves” Best Buy
    “App Engine allows us to launch games very quickly with teams of
    one or two developers. Because Google manages all the servers,
    there is little required of us in terms of maintenance” Rovio
    “It's hard to imagine that this app would have been possible, so
    quickly, working with anything except App Engine” Sony

    View Slide

  13. View Slide

  14. 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

    View Slide

  15. 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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  19. View Slide

  20. Cloud Console

    View Slide

  21. 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

    View Slide

  22. Geo headers

    View Slide

  23. Traces

    View Slide

  24. Traces

    View Slide

  25. User authentication
    - url: .*

    script: main.php

    login: required

    secure: always
    • Any Google Account (or Admin only)
    • $_SERVER

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  29. Scaling Demo
    application: conf-demo

    version: alpha1

    runtime: php55

    api_version: 1

    threadsafe: yes


    handlers:


    - url: .*

    script: main.php
    app.yaml
    file_get_contents(
    ‘https://firebase..//request.json‘,
    false,
    stream_context_create([
    'http' => [

    'method' => 'PUT',

    'header' => 'Content-type: application/json',

    'content' => json_encode($_SERVER)

    ]])
    );
    main.php

    View Slide

  30. Live Demo*

    View Slide

  31. Pit falls
    Avoid vendor lock-in
    Inject your
    dependencies

    View Slide

  32. Summary

    View Slide

  33. View Slide

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

    View Slide

  35. Questions?

    View Slide

  36. Google App Engine - a PHP PaaS
    from Prototyping to Production
    • Feedback IPC app or https://joind.in/talk/ce88a
    • Projects https://github.com/tomwalder
    • Twitter @tom_walder
    • Email [email protected]
    • Thanks to IPC for having me and to
    Docnet/Venditan for letting me out!
    • Slides here: *RECURSION*

    View Slide