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

Elixir dev to prod

Elixir dev to prod

A talk about the road taken by us at Xerpa using Elixir since day-0.

Guilherme de Maio, nirev

September 23, 2016
Tweet

More Decks by Guilherme de Maio, nirev

Other Decks in Technology

Transcript

  1. Elixir

    Dev to Prod
    Challenges starting from Zero
    @nirev
    Guilherme Nogueira

    View Slide

  2. nirev?
    whois

    View Slide

  3. nirev?
    whois

    View Slide

  4. nirev?
    whois

    View Slide

  5. ?

    View Slide

  6. View Slide

  7. Stack
    Elixir 1.3 + Phoenix
    ClojureScript + Reagent
    PostgreSQL
    ElasticSearch
    Cassandra
    Others: C#, Python, C, Bash, Jenkins
    (In Production)

    View Slide

  8. What was the
    road like?

    View Slide

  9. Easy steps
    1.gather a team
    2.code
    3.?????
    4.PROFIT

    View Slide

  10. Actually…
    1. Why Elixir?
    2. Assembling a team
    3. Starting to Code
    4. Going to production
    5. Feature Cycles
    6. Monitoring
    7. The Good, The Bad, and The Ugly

    View Slide

  11. Why Elixir?

    View Slide

  12. Why Elixir?
    Functional Programming; so what?

    View Slide

  13. Why Elixir?
    Functional Programming; so what?
    • CPUs are not getting faster for single-thread apps
    • Concurrency is the next major thing for development
    • NO MORE FREE LUNCH (2005):
    • Java5
    • WindowsXP
    • RoR launching on December

    View Slide

  14. Why Elixir?
    Functional Programming; so what?
    • What does it have to do with Functional Programming?
    • FP is easier for concurrency: 

    mainly because immutability + guarantees

    View Slide

  15. Why Elixir?
    Functional Programming; so what?
    • Actually, FP is a very old paradigm (even older than OOP):
    • 1960 → Lisp
    • 1973 → ML
    • 1980s → Lazy langs: Miranda, KRC, SASL, Orwell...
    • 1986 → Erlang
    • 1990 → Haskell 1.0

    View Slide

  16. Why Elixir?
    Functional Programming; so what?
    • Elixir embraces distributed computation and concurrency
    • Builds upon battle-tested Erlang
    • Enhances it with Metaprogramming and a arguably easier

    syntax
    • Created by the great VALINHO

    View Slide

  17. Assembling a
    Team

    View Slide

  18. Assembling a Team
    or, How I learned Elixir
    • Few Elixir programmers around (what a surprise!)
    • But increasingly number of people interested in it

    and coming from all kinds of background
    • No “competition”
    • The first one is the hardest (lol)

    View Slide

  19. "Os alquimistas
    estão chegando"
    Jorge Ben

    View Slide

  20. "Os alquimistas
    estão chegando"
    Jorge Ben
    George Guimarães

    View Slide

  21. Starting to
    Code

    View Slide

  22. Starting to Code
    Elixir first impressions
    • mix is awesome
    • plenty of editors: atom, vim, IntelliJ 

    Emacs + Alchemist = <3 <3 <3
    • Documentation is taken seriously
    • Quite easy to get acquainted to the language
    • OTP on the other hand….

    View Slide

  23. Starting to Code
    Elixir first impressions
    • Elixir takes the best ideas from a lot of languages:
    • |> from F#
    • Protocols e Metaprog from Clojure
    • the whole OTP from Erlang
    • Umbrella Apps from .NET
    • Ecto query DSL from LINQ
    • Doctest from Python …..

    View Slide

  24. Starting to Code
    Elixir first impressions
    • Everything is immutable.
    • There is a compiler
    • Elixir is pragmatic
    • Performance is great. GC is per-process
    • Documentation & tooling are take seriously
    • Macros
    • The runtime & OTP are AWESOME. 

    Every process is preempted. No bad neighbors.

    View Slide

  25. Going to
    Production

    View Slide

  26. Going to Production
    We got this (somewhat)
    • Quick first way: Heroku + Elixir build pack
    • works great
    • just one server though and 

    we only used PostgreSQL at the time

    View Slide

  27. Going to Production
    We got this (somewhat)
    • Delivery Pipeline:
    • SemaphoreCI embraced Elixir quite early

    works great, very easy to configure
    • But we just love Jenkins
    • Did not test any other

    View Slide

  28. Going to Production
    We got this (somewhat)
    • Delivery Pipeline:
    • SemaphoreCI embraced Elixir quite early

    works great, very easy to configure
    • But we just love Jenkins
    • Did not test any other

    View Slide

  29. • Deployment, part 2:
    • PITA to use GraphicsMagick in Heroku

    (we have a buildpack for it on github)
    • Needed:
    • ElasticSearch
    • More control
    Going to Production
    We got this (somewhat)

    View Slide

  30. • Deployment, current: AWS
    • everything managed by Terraform + Ansible
    • Phoenix app compiled and packaged in .deb
    • deb is a no-brainer for us
    • no hot-deploy
    Going to Production
    We got this (somewhat)

    View Slide

  31. • # TODO:
    • Deployment with distributed Erlang nodes
    • Better understand how Elixir releases
    should be done
    Going to Production
    We got this (somewhat)

    View Slide

  32. Feature
    Cycles
    AKA build stuff

    View Slide

  33. Feature Cycles
    Building Stuff with Elixir
    • Core libs (Ecto, Phoenix, Plug) are 

    incredibly reliable!
    • releases are hard and not 12factor
    • hot code reloads are not that simple
    • The Ecosystem is really young

    View Slide

  34. Feature Cycles
    Building Stuff with Elixir
    • The Ecosystem is really young
    • no usable ElasticSearch client
    • (at the time) no json-api library
    • (at the time) no good auth libs
    • nothing to handle images

    github.com/Xerpa/exmagick :)

    View Slide

  35. Feature Cycles
    Building Stuff with Elixir
    You gotta get your hands dirty!

    View Slide

  36. Feature Cycles
    Building Stuff with Elixir

    View Slide

  37. Feature Cycles
    Building Stuff with Elixir

    View Slide

  38. Feature Cycles
    Building Stuff with Elixir

    View Slide

  39. Feature Cycles
    Building Stuff with Elixir

    View Slide

  40. Feature Cycles
    Building Stuff with Elixir
    You gotta get your hands dirty!

    View Slide

  41. Monitoring

    View Slide

  42. Monitoring
    Everybody ships bugs
    • Suddenly, we were reminded that 

    writing software IS HARD
    • And when going too fast, 

    things are going to brake

    View Slide

  43. Monitoring
    Everybody ships bugs

    View Slide

  44. Monitoring
    Everybody ships bugs
    • Plug n Play solutions are not that common:

    Honeybadger officially supports it

    AppSignal in alpha testing
    • the BEAM is highly instrumentable
    • Great talk about it by Milhouse @ ElixirConf2016

    https://confreaks.tv/events/elixirconf2016

    View Slide

  45. Monitoring
    Everybody ships bugs
    • But we monitor machine states and so what with
    SENSU, which is great!

    View Slide

  46. The Good, The Bad

    and The Ugly
    Key takeaways

    View Slide

  47. Takeways
    Was it worth?
    • Starting with a new, evolving language is hard
    • We had to figure out a lot of stuff ourselves
    • And we got it wrong a few times:
    • Trying to Haskellize Enums to use with Ecto
    • No good cassandra client (lacks a lot of features)
    • Not using Ecto.Type correctly from the start
    • Dates

    View Slide

  48. Takeways
    Was it worth?
    • But we did get a lot of things right, and the platform is

    AMAZING
    ~3k commits, 700 PRs

    View Slide

  49. Takeways
    Was it worth?
    • Elixir is very promissing, and growing FAST
    • The community learns a lot from other languages
    • The community is helpful, open, inclusive and active
    • You have to be willing to deal with not-ready things and

    contribute yourself to the ecosystem
    • But even so, it’s highly recommended

    View Slide

  50. Thanks!
    https://xerpa.recruiterbox.com/
    Estamos contratando!
    @nirev
    Guilherme Nogueira

    View Slide