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 Slide

  2. whoami
    Consultant
    Free software developer

    maintainer: django-admin-bootstrapped,
    uwsgitop, bootchart2

    contributor: uwsgi, LibreOffice

    View Slide

  3. Deploy

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  7. Code
    SCM
    A build pipeline -> artifact

    View Slide

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

    View Slide

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

    View Slide

  10. 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 Slide

  11. automation
    provisioning
    deployment

    View Slide

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

    View Slide

  13. mythical figures
    sysadmin
    devops

    View Slide

  14. uwsgi.it

    View Slide

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

  16. 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 Slide

  17. Missing features

    No git integration / cool cli (as heroku)

    No marketplace

    View Slide

  18. uwsgi

    View Slide

  19. 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 Slide

  20. 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 Slide

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

    View Slide

  22. 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 Slide

  23. some functionality exposed as APIs

    python, perl, lua

    ruby dsl
    API:

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

    View Slide

  24. Fancy architecture

    View Slide

  25. 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 Slide

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

    View Slide

  27. 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 Slide

  28. 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 Slide

  29. 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 Slide

  30. 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 Slide

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

    View Slide

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

    View Slide

  33. Demo time!

    View Slide

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

    View Slide

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

    View Slide