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

Deploying a web app: the road less travelled

Deploying a web app: the road less travelled

Cosa significa fare il deploy di una web app? Che opzioni ho? La strada meno battuta: l’ecosistema uWSGI.

Riccardo Magliocchetti

January 18, 2016
Tweet

More Decks by Riccardo Magliocchetti

Other Decks in Programming

Transcript

  1. Deploying a web app: the road less
    travelled
    Riccardo Magliocchetti
    Torino Coding Society 18/01/16

    View full-size slide

  2. whoami
    Consultant
    Free software developer

    maintainer: django-admin-bootstrapped,
    uwsgitop, bootchart2

    contributor: uwsgi, LibreOffice

    View full-size slide

  3. What does it even mean?
    deploy
    to organize and send out (people or
    things) to be used for a particular
    purpose

    View full-size slide

  4. aka
    put stuff from my laptop to the Internet :)

    View full-size slide

  5. Building blocks
    Our Code
    Other people's software
    Automation

    View full-size slide

  6. Code
    SCM
    A build pipeline -> artifact

    View full-size slide

  7. Other people's software
    HTTP server / proxy
    Application server (or not)
    Database server
    In memory store
    Queue system

    View full-size slide

  8. all this stuff really?
    short answer: yes
    Plus monitoring :)

    View full-size slide

  9. Options: from more painful to more
    lame
    Bare metal (Github)
    Public Cloud (Netflix)
    PAAS <- sweet spot for most people?
    90s LAMP stack (hi PHP hosting!)

    View full-size slide

  10. automation
    provisioning
    deployment

    View full-size slide

  11. in other words
    DevOps Borat
    To make error is human. To
    propagate error to all server in
    automatic way is #devops

    View full-size slide

  12. mythical figures
    sysadmin
    devops

    View full-size slide

  13. uwsgi.it

    free software PAAS (MIT)

    C + perl + nginx + django + postgres

    linux containers based

    REST API

    based on uwsgi
    https://github.com/unbit/uwsgi.it

    View full-size slide

  14. Features

    Choose your own distribution for rootfs

    SSL is not a costly update (hey heroku)

    Clustering out of the box

    Third party alarms included

    View full-size slide

  15. Missing features

    No git integration / cool cli (as heroku)

    No marketplace

    View full-size slide

  16. uwsgi
    An application server container (GPL)
    A way to run and manage python, ruby, lua, mono,
    jvm, js and even php apps
    https://github.com/unbit/uwsgi
    https://github.com/unbit/uwsgi-docs

    View full-size slide

  17. uwsgi
    Created by an ISP
    PROs

    focus on low usage resources

    many different stacks support
    CONs

    every possible options possible to make customers
    app work

    View full-size slide

  18. options digression
    I meant for real:
    $ ./uwsgi ­­help | wc ­l
    937

    View full-size slide

  19. Features

    fastrouter: proxy / load balancer / router

    socket less workers aka mules

    async task spooler

    cron-like interface

    caching framework and caching cookbook

    external services management

    routing system

    metrics

    lot more stuff that doesn't fit here: native http, signals, rpc, ...

    lot of plugins

    View full-size slide

  20. some functionality exposed as APIs

    python, perl, lua

    ruby dsl
    API:

    cache, queue, spooler, mules, cron, timer, ...

    View full-size slide

  21. Fancy architecture

    View full-size slide

  22. overview
    emperor + vassals + http server + fastrouter + external
    daemon
    $ find .
    .
    ./emperor.ini
    ./vassals
    ./vassals/webserver.ini
    ./vassals/fastrouter.ini
    ./vassals/one.ini
    ./vassals/two.ini
    ./vassals/redis.ini

    View full-size slide

  23. emperor
    [uwsgi]
    emperor = %d/vassals

    View full-size slide

  24. http server
    [uwsgi]
    plugins = http
    master = true
    # listen for http
    http = 0.0.0.0:8080
    # forward requests via uwsgi
    protocol
    http­to = 127.0.0.1:3031
    logto = %d/webserver.log

    View full-size slide

  25. fastrouter
    [uwsgi]
    plugin = fastrouter
    ;create a shared socket (the webserver will
    connect to it)
    fastrouter = 127.0.0.1:3031
    ; our subscription server
    fastrouter­subscription­server =
    127.0.0.1:4040
    logto = %d/fastrouter.log

    View full-size slide

  26. workers: python
    [uwsgi]
    plugins = python
    master = true
    socket = 127.0.0.1:3041
    subscribe­to =
    127.0.0.1:4040:127.0.0.1:8080
    wsgi­file = %d/../app.wsgi
    processes = 1
    logto = %d/one.log

    View full-size slide

  27. workers: ruby
    [uwsgi]
    plugins = rack
    master = true
    socket = 127.0.0.1:3042
    subscribe­to =
    127.0.0.1:4040:127.0.0.1:8080
    rack = %d/../app.ru
    ; required by rack specification
    post­buffering = 4096
    processes = 1
    logto = %d/two.log

    View full-size slide

  28. redis
    [uwsgi]
    smart­attach­daemon = %d/redis.pid
    redis­server ­­unixsocket
    %d/redis.socket ­­port 0 ­­pidfile
    %d/redis.pid ­­daemonize yes

    View full-size slide

  29. Let's run it
    $ uwsgi emperor.ini

    View full-size slide

  30. Happy Hacking :)
    Riccardo Magliocchetti
    [email protected]
    @rmistaken
    http://menodizero.it
    https://github.com/xrmx

    View full-size slide

  31. Torino Hacknight
    Il modo più facile per iniziare a sviluppare
    software libero sotto la mole
    Ultimi biglietti
    @tohacknight - http://torino.hacknight.it

    View full-size slide