Slide 1

Slide 1 text

ELIXIR IN PRODUCTION: THE EXPERIENCE AT XERPA Renan Ranelli

Slide 2

Slide 2 text

Milhouse (@renanranelli)

Slide 3

Slide 3 text

Software Engineer @ Milhouse (@renanranelli)

Slide 4

Slide 4 text

(former) Software Engineer @ Milhouse (@renanranelli)

Slide 5

Slide 5 text

Milhouse (@renanranelli)

Slide 6

Slide 6 text

AGENDA • Why the heck are people talking so much about FP ? • What the heck is “Xerpa” ? • What the heck is “Elixir” ? • A little bit about our experience and main struggles. • Discussion, questions and things like that.

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

WHAT'S HAPPENING ON HARDWARE­LAND • You must google “no more free lunch”. • The takeaway is: – CPUs are not getting faster for single threaded applications. – Concurrency is the next major revolution in how we write software

Slide 9

Slide 9 text

This was written in March 2005.

Slide 10

Slide 10 text

2005

Slide 11

Slide 11 text

In 2005: – Java 5 was hot news. – Windows XP. Vista only in 2007. – No AWS, Twitter, Netflix. – Ruby on Rails launching in December. – Youtube was just founded. – You've never heard of Justin Bieber

Slide 12

Slide 12 text

This was written in March 2005

Slide 13

Slide 13 text

FUNCTIONAL PROGRAMMING (!)

Slide 14

Slide 14 text

FUNCTIONAL PROGRAMMING • Every* language built after that has concurrency as a main concern to be adressed – Scala, Clojure. – Elixir. – Go, Rust. – Erlang & Haskell's rediscovery. – Kotlin, Nim, Pony, Crystal, etc...

Slide 15

Slide 15 text

FUNCTIONAL PROGRAMMING • Actually, functional programming 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

Slide 16

Slide 16 text

https://www.youtube.com/watch?v=njAMVB02Ag0 https://www.youtube.com/watch?v=kiaZd8dmbtI THERES LIFE BEYOND OOP IF YOU WANT TO KNOW MORE, I HAVE TWO TALKS FOR YOU

Slide 17

Slide 17 text

ELIXIR @ XERPA

Slide 18

Slide 18 text

ELIXIR @ XERPA

Slide 19

Slide 19 text

• Our tech-stack today is something like this: – Elixir backend (!!) [Phoenix] – Clojurescript frontend (!!!!!) [Reagent/React] – Postgresql 9.4, (Cassandra soon) – ElasticSearch, Redis, C#/Mono (!?) – InfluxDB, Sensu & Grafana – Jenkins, Mailgun, Ansible, Terraform, AWS and *a lot* of shell scripting :D – No Docker, microservices, no service discovery.

Slide 20

Slide 20 text

• Elixir in production for 7 months: 2k commits, 300 PRs, +- 21k lines of code, 4 devs ~ 150 modules

Slide 21

Slide 21 text

• Elixir – Based on the Erlang VM. Can handle a lot of punching. – Erlang's runtime is extremely mature and battle-hardened. – Fault tolerance is a first class citizen. Hot-code reloads are possible. Many versions of the same module can coexist. – Erlang is built to yield uptimes up to 99.9999999% (really) – Communication is “shared nothing” and “default asynchronous”. – This is also called the “Actor System”.

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

WHAT ELIXIR DOES REALLY WELL? • 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.

Slide 26

Slide 26 text

PHOENIX >> RAILS • Where Phoenix excels over Rails ? – SUPER DUPPER FAST (!?) – Much easier to setup for high concurrency – Much less magic. Mostly everything is based on simple function calls. – Channels (!) – Views vs Templates. – It feels like “Rails done right”.

Slide 27

Slide 27 text

Now to the not-fun part.

Slide 28

Slide 28 text

PROBLEMS WE ENCOUNTERED SO FAR • The ecosystem is still very small (and somewhat buggy). – No options for monitoring apps (like new relic, appsignal, honeybadger). – Nothing as mature as Sidekiq (we have Exq and verk, but still...). – ExMachina (elixir's factory girl) is so broken. Ecto 2.0 will solve this. – No Monads. (we don't actually need them.)

Slide 29

Slide 29 text

PROBLEMS WE ENCOUNTERED SO FAR • The ecosystem is still very small (and buggy). – No usable client for elastic search (*) – No usable (at the time?) library for exposing jsonapi (*) – No usable (at the time) library to handle auth (*) – No usable bindings for GraphicsMagick (*) – Releases are so damn hard and un-12factor (*) – Hot code reloads are much much harder than people say – Almost no problems with core libs like Ecto, Plug & Phoenix though.

Slide 30

Slide 30 text

YOU GOTTA GET YOUR HANDS DIRTY

Slide 31

Slide 31 text

YOU GOTTA GET YOUR HANDS DIRTY

Slide 32

Slide 32 text

YOU GOTTA GET YOUR HANDS DIRTY

Slide 33

Slide 33 text

YOU GOTTA GET YOUR HANDS DIRTY

Slide 34

Slide 34 text

YOU GOTTA GET YOUR HANDS DIRTY

Slide 35

Slide 35 text

YOU GOTTA GET YOUR HANDS DIRTY

Slide 36

Slide 36 text

PROBLEMS WE ENCOUNTERED SO FAR • The ecosystem is still very small (and buggy). – No usable client for elastic search (*) – No usable (at the time?) library for exposing jsonapi (*) – No usable (at the time) library to handle auth (*) – No usable bindings for GraphicsMagick (*) – Releases are so damn hard and un-12factor (*) – Hot code reloads are much much harder than people say – Almost no problems with core libs like Ecto, Plug & Phoenix though.

Slide 37

Slide 37 text

A SMALL COMPARISON WITH CLOJURE: – Clojure can tap into the JVM. – A *big* and mature ecosystem (erlang is mature, but not big) – A lot (?) of developers willing to work with it – Although Elixir can tap into Erlang-land's libraries and tools, they are much harder to use (less googlability, bad/incomplete docs) – Clojure offers absolutely nothing in terms of distribution and fault tolerance. There is no competition really...

Slide 38

Slide 38 text

Conclusion:

Slide 39

Slide 39 text

On Elixir • Elixir is *very promissing*, and has learned a lot from other communities. (e.g. Queryable is an idea from .Net's Linq) • You can see that it evolves and taps into the learning experiences of other languages & communities. It still lacks a mature ecosystem but it is gaining traction fast. • If you truly aim to invest yourself in it, you must be ready to get your hands dirty and write a lot of infrastructure you take for granted in other ecosystems. • Do *not* underestimate the complexity of managing library code + tests + docs + versioning + bug tracking.

Slide 40

Slide 40 text

OBRIGADO !

Slide 41

Slide 41 text

@renanranelli /rranelli Renan Ranelli (Milhouse) milhouseonsofware.com

Slide 42

Slide 42 text

• https://www.youtube.com/watch?v=njAMVB02Ag0 • https://www.youtube.com/watch?v=kiaZd8dmbtI