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

12 [Anti] Factors

12 [Anti] Factors

Vamos falar sobre os 12-Factor, mas sob uma ótica diferente: o que não fazer. A ideia desta talk é expor algumas práticas que podem ajudar nossas aplicações a rodar em ambientes distintos seguindo alguns conceitos simples definidos pelos 12 Factors.

More Decks by Gabriel Leopoldo Ferreira

Other Decks in Technology

Transcript

  1. 90.02% apps em EOL 1.9,3 2011-2015 2.0.0 2013-2016 2.1.0 2013-2017

    2.2.0 2014-2018 2.3.0 2015-2019 2.4.0 2016-2020 2.5.0 2017-2021 2.6.0 2018-2022 2.7.0 2019-2023 2014 tecnologia de
  2. 88.17% de 93 apps ruby em EOL 1.8.X 1.9.X 2.0.X

    2.1.X 2.2.X 2.3.X 2.4.X 2.5.X 2.6.X 2.7.X 18% 24% 30% 36% 42% 19.35% 8.6% 10.75% 3.23% 39.78% 6.45% 11.83% 0% 0% 0% ruby <= 2.4 https://www.ruby-lang.org/en/downloads/branches/
  3. 73.08% de 78 apps rails em EOL * 3.X 4.0.X

    4.1.X 4.2.X 5.X 18% 24% 30% 36% 42% 29.49% 2,56% 6.41% 34.62% 26.92% rails <= 4.2 * 6.X 0% * https://guides.rubyonrails.org/maintenance_policy.html
  4. 63.64% apps em debian no EOL * 6 (squeeze) 7

    (wheezy) 8 (jessie) 9 (stretch) 10 (buster) 18% 24% 30% 36% 42% 11.57% 28,09% 23.96% 36.36% debian LTS <= 8 debian <= 9 (EOL em 06/07) * 0% * https://wiki.debian.org/DebianReleases
  5. The Milter Project Bounces Milter Sender Milter one project per

    repo SEND! BOUNCE! s.o.: debian A python: X.X.X s.o.: debian B python: Y.Y.Y The Bounces-Milter Project
  6. The Milter Project no bundler, no Pipfile python-redis python milter

    pycrypto pymilter deps management done in PROD \o/ package with only source code, no deps here... all deps loaded magically in the application probably running dev with different versions of deps
  7. The Milter Project Pipfile + pipenv python-redis python pymilter milter

    pycrypto deps management done in Pipfile.lock package vendoring dependencies in CI all deps loaded through PYTHONPATH env var probably running dev with same versions of deps
  8. Different background processes spawning several processes for fun: A young

    application server Can run in one host (VM) or multiple containers
  9. File doesn’t exist error :( what happens when your app...

    Important customer’s file ...uses local filesystem to save stuff... WTF?!?!?!
  10. File doesn’t exist error :( what happens when your app...

    Important customer’s file ...uses local filesystem to save stuff... WTF?!?!?!
  11. what happens when your app... Important customer’s file ...uses object

    storage to save stuff... External FileSystem HTTP request [POST] Found! :D HTTP request [GET] Temporary file saved in host
  12. socket port 3000 3000 6379 socket port 5432 5432 exposing

    app ports 7474 socket port 6379 socket port 9999 NO! port is closed
  13. Scale-up Adding + processing power Scale-out Keep same amount of

    hosts The “internetz” Adding more instances of your application Distributed processing The cheaper way
  14. HOST B: Splitting Critical Sidekiq Queues in different hosts ‘high’

    priority ‘low’ priority ‘default’ priority HOST A: ‘high’ priority ‘low’ priority ‘default’ priority
  15. HOST B: Splitting Critical Sidekiq Queues in different processes ‘high’

    priority ‘low’ priority ‘default’ priority HOST A: ‘high’ priority ‘low’ priority ‘default’ priority
  16. Idempotent Workers ...or mathematically: f(x) = X f(f(x)) = X

    “input” “output” your function / worker always returns the same output, given an input
  17. Reentrant Workers “input” atomicity guarantee your function / worker share-nothing

    scenario “input” in-memory “output” in-memory “output” thread-safe consistent shutdown
  18. Reentrant Workers “input” your function / worker with one side-effect

    scenario “input” writing to same file (side-effect) first write wins strategy atomicity guarantee thread-safe consistent shutdown
  19. Reentrant Workers “input” your function / worker with multiple side-effects

    scenario “input” writing to same file (side-effect) No all-or-nothing guarantee (not atomic) send SPAM (side-effect) atomicity guarantee thread-safe consistent shutdown
  20. Reentrant Workers “input” your function / worker using single-database transactions

    scenario “input” several write queries in a transaction (side-effect) atomicity guarantee thread-safe consistent shutdown
  21. Reentrant Workers “input” your function / worker using multi-database transactions

    scenario “input” PG transaction (side-effect) atomicity guarantee thread-safe consistent shutdown Push job to Sidekiq (side-effect)