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

Pycon Italia 2017: Planet Friendly Python

Pycon Italia 2017: Planet Friendly Python

My talk from Pycon Italia Europe about Planet friendly Web development with Python.

Chris Adams

April 07, 2017
Tweet

More Decks by Chris Adams

Other Decks in Technology

Transcript

  1. Planet friendly
    Web Development
    with Python
    Chris Adams
    Pycon Italia 2017

    View Slide

  2. Chris Adams:
    @mrchrisadams
    This guy
    Environmentally focussed
    web generalist

    View Slide

  3. A.M.E.E. (Avoid Mass
    Extinction Engine) - CO2
    calculation APIs
    Loco2 - Low CO2 travel
    in Europe by train
    TeaLight - Low CO2
    cups of tea, with
    demand response
    My Background:

    View Slide

  4. Pycon Italia 2017 - Planet Friendly Web Development
    @mrchrisadams

    View Slide

  5. Pycon Italia 2017 - Planet Friendly Web Development
    @mrchrisadams
    @mrchrisadams
    What can a technologist do about climate change: worrydream.com/climatechange

    View Slide

  6. Pycon Italia 2017 - Planet Friendly Web Development
    @mrchrisadams
    http://www.iea.org/media/news/2017/GlobalCarbonEmissions2.png
    http://www.iea.org/newsroom/news/2017/march/iea-finds-co2-emissions-flat-for-third-straight-year-even-as-global-
    economy-grew.html

    View Slide

  7. Pycon Italia 2017 - Planet Friendly Web Development
    @mrchrisadams
    http://folk.uio.no/roberan/t/global_mitigation_curves.shtml

    View Slide

  8. Pycon Italia 2017 - Planet Friendly Web Development
    @mrchrisadams
    @mrchrisadams
    World GHG Emissions in 2010 - Analysis by ECOFYS
    Source* Greenhouse gas
    Coal
    25%
    Natural Gas
    19%
    Oil
    21%
    Waste
    0.4%
    Sector
    Direct
    emissions
    34.6%
    * Greenhouse gases can arise from two sources
    N20
    7%
    CH4
    15%
    CO2
    76%
    HFCs & PFCs
    2%
    Transport
    15%
    Residential Buildings
    11%
    Commercial/Public Buildings & Services
    7%
    Land Use
    Change
    15%
    Industry
    29%
    7%
    6.0%
    4.8%
    4.3%
    1.4%
    1.1%
    1.0%
    10.5%
    1.5%
    2.6%
    10.5%
    5.5%
    1.4%
    1.8%
    3.1%
    4.4%
    10.3%
    Other industries
    Paper, pulp and printing
    Food and tobacco
    Non-ferrous metals
    Chemical and petrochemical
    Iron and steel
    Non-metallic minerals
    Aviation
    Others
    Road
    Livestock and manure
    Agricultural Energy Use
    Coal Mining
    Oil and gas extraction, refining and processing
    Deforestation/Afforestation and Land Use CO2
    Agricultural soils
    1.3%
    1.6%
    Landfills
    Waste water & others
    Waste 3%
    Agriculture
    Energy Supply
    13% 8.3%
    Energy industry own use & losses

    View Slide

  9. Pycon Italia 2017 - Planet Friendly Web Development
    @mrchrisadams
    © 2011-2012 GreenTouch Consortium
    2020 ICT Carbon Footprint
    820m tons CO2
    360m tons CO2
    260m tons CO2
    2007 Worldwide ICT

    carbon footprint:

    2% = 830 m tons CO2
    Comparable to the

    global aviation 

    industry
    Expected to grow 

    to 4% by 2020
    The Climate Group, GeSI
    Report “Smart 2020”, 2008
    Full report - https://www.slideshare.net/greentouch-org/intro-to-green-touch

    View Slide

  10. Pycon Italia 2017 - Planet Friendly Web Development
    @mrchrisadams
    A mental model for
    thinking about this

    View Slide

  11. Pycon Italia 2017 - Planet Friendly Web Development
    @mrchrisadams
    Your Servers
    Your Packets
    Your Process

    View Slide

  12. Your servers
    Provider
    Provisioning

    View Slide

  13. Your servers
    Provider:
    Where did the power your
    servers run on come from?

    View Slide

  14. Power quote
    From 2017 report - http://www.greenpeace.org/usa/global-warming/click-clean/

    View Slide

  15. Your servers
    Provision:
    How many server resources do
    you use? And when?

    View Slide

  16. The power of wireless cloud 2013 (CEET - http://www.ceet.unimelb.edu.au/publications)

    View Slide

  17. “many workloads are spiky or
    drop to zero for extended
    periods… applications used in
    the workplace may only be
    active for 40 of the 168 hours in
    a week.”
    Adrian Cockroft
    @adrianco: AWS, ex Netflix
    @mrchrisadams
    https://medium.com/@adrianco/evolution-of-business-logic-from-monoliths-through-microservices-to-functions-
    ff464b95a44d#.4ap421dwr

    View Slide

  18. PaaS:
    Higher unit cost in
    exchange for
    easier scaling

    View Slide

  19. FaaS / Serverless:
    Even higher unit
    cost, to not think
    about scaling*
    * You still need to obviously, but differently

    View Slide

  20. “the technical capabilities of
    serverless might not be that
    exciting, but the financial side
    sure is… Strong financial
    incentives for good design
    practices, and clear financial
    penalties for bad design”
    Gojko Adzic
    @mrchrisadamshttps://gojko.net/2016/08/27/serverless.html

    View Slide

  21. When your second biggest cost after
    staff is data centres, you have a very
    good incentive to care about saving
    energy.
    @mrchrisadams
    https://deepmind.com/blog/deepmind-ai-reduces-google-data-centre-cooling-bill-40

    View Slide

  22. Platform as a Service (PaaS) Functions as a Service
    Cloudfoundry: App Autoscaler chalice
    Heroku: Autoscaling & LightSwitch zappa
    In the Python toolbox

    View Slide

  23. Your packets
    Lossy changes
    Lossless changes

    View Slide

  24. http://www.electricitymap.org/

    View Slide

  25. “Wireless access network
    technologies account for 90% of
    total wireless cloud energy
    consumption. Data centres account
    for only about 9%. The energy
    consumption of wireless user
    devices is negligible.”
    The power of wireless cloud 2013 (CEET - http://www.ceet.unimelb.edu.au/publications)

    View Slide

  26. Power quote
    The power of wireless cloud 2013 (CEET - http://www.ceet.unimelb.edu.au/publications)

    View Slide

  27. https://www.soasta.com/blog/page-bloat-2015-web-performance-monitoring/

    View Slide

  28. Power quote
    https://performancebudget.io

    View Slide

  29. Power quote
    https://speedcurve.com (see also sitespeed.io for an OSS take)

    View Slide

  30. Your packets
    Lossy changes:
    How much of what you send is
    used by the client?

    View Slide

  31. Your packets
    Lossless changes:
    How efficiently are the bits
    sent?

    View Slide

  32. Dynamic Static Media
    compression
    Django middleware,
    Flask-Compress, etc.
    Whitenoise, CDNs,
    Nginx
    CDNs, Nginx
    caching
    Django middleware &
    decorators, Flask-Cache
    Whitenoise, CDNs CDNs, Nginx
    JS optimisation
    Webpack 2, Google
    Closure Compiler (JS)
    nginx mod_pagespeed
    Image Optimisation ImageOptim, Trimage
    easy-
    thumbnails.optimise,
    nginx mod_pagespeed
    Relevant in the Python toolbox

    View Slide

  33. There’s much, much more to do, but
    starting here can help

    View Slide

  34. Thanks!
    I’m around all week, and in the
    slack channel to chat. Say
    hello :)
    Chris Adams
    @mrchrisadams
    planetfriendly.productscience.co.uk
    speakerdeck.com/mrchrisadams

    View Slide

  35. Pycon Italia 2017 - Planet Friendly Web Development
    @mrchrisadams
    Bonus life-changing link:
    What can a technologist do about
    climate change? - Bret Viktor
    worrydream.com/climatechange

    View Slide