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

Practical Elixir

Practical Elixir

Arnaud Wetzel, co-founder Shopping Adventure presented us the usage of Elixir inside of his company.

erlang.paris

June 29, 2015
Tweet

More Decks by erlang.paris

Other Decks in Technology

Transcript

  1. PRACTICAL ELIXIR
    PRACTICAL ELIXIR
    PRACTICAL ELIXIR
    PRACTICAL ELIXIR
    PRACTICAL ELIXIR
    PRACTICAL ELIXIR
    PRACTICAL ELIXIR
    PRACTICAL ELIXIR
    PRACTICAL ELIXIR
    PRACTICAL ELIXIR
    PRACTICAL ELIXIR
    PRACTICAL ELIXIR
    PRACTICAL ELIXIR
    PRACTICAL ELIXIR
    PRACTICAL ELIXIR
    PRACTICAL ELIXIR
    Arnaud Wetzel, co-founder Shopping Adventure

    View full-size slide

  2. INTRODUCTION
    Shopping Adventure connects physical shops
    Microservices Java/C/Python/Ruby/Clojure/Erlang/Elixir
    Erlang : stateful services, microservices inside, simple and
    available
    Elixir additions ?
    Syntax ? really ?
    Macros ? `parse_transform`
    Tools ? Erlang ecosystem is more mature and stable
    Feedback : productivity, flexibility, the whole experience
    This presentation is a feeback

    View full-size slide

  3. PROJECT
    Mall e-commerce website : nice UI to quickly fill a cart with
    mall shops products and buy them, then organize pick up or
    delivery.
    Backend Magic: construct data set from nothing, or very
    bad inputs
    Backend magic: handle heterogeneous processes, connect
    retailer software, synchronize teams

    View full-size slide

  4. PROJECT
    Bad input dataset
    Format / Augment / Filter / Merge / Join
    Heterogeneous providers
    Local micro services
    Heterogeneous order workflows
    Transactional order changes
    Connect non technical partners
    APIfy websites and emails
    UI == eternal nightmare
    Small team == well partitioned jobs

    View full-size slide

  5. OUR OWN ECOSYSTEM
    Hex.pm: Open repository is the future (before the chaos)
    HTTP DSL: Ewebmachine
    Data Mashup: ADAP
    Service Aggregation:
    EXOS/node_erlastic/python_erlastic/clojure_erlastic
    Mail destructuring/structuring: Mailibex
    State Distribution: Supervisorring
    FSM definition: ExFSM
    Rules as matches: ExRules
    Dev env: neovim-elixir

    View full-size slide

  6. UI
    UI : Webflow (0LOC)
    UI state/cache : reaxt/jsxz (900LOC)
    HTTP API : Ewebmachine (350LOC)
    Cache : ets/riak (50LOC)
    Service clients : httpc (300LOC)

    View full-size slide

  7. ORDER MANAGEMENT
    DHT distributed order transactions as FSM
    Core: transactors and models (350LOC)
    Order adapter for incomplete order (70LOC)
    FSM Selector rules (20LOC)
    Processes specification as FSM (500LOC)
    Service clients/adapters : clojure/python/http (500LOC)

    View full-size slide

  8. WEBSITE AUTOMATION
    Distributed Selenium sessions
    Clojure Port/GenServer to talk to selenium
    Elixir is used to maintain and supervise sessions, and route
    then to free browsers

    View full-size slide

  9. DATA MANAGEMENT
    Ruby workflows / python / c / etc.
    Our new approach, Elixir to pipe them all
    Distribute multi-language services and state : image caches
    / RDBS / machine learning models on dedicated nodes
    Query your entire dataset to create a new one
    Stream data entities accross the cluster hoping from one
    node to another when remote data is needed
    Data sink node will reorder and join entities with a buffer
    queue
    Augmentation rules (1000LOC)

    View full-size slide

  10. LESSONS: MICRO SERVICES READY
    BERT Binary Format
    GenServer are services
    Communicate with protocols

    View full-size slide

  11. ELIXIR: FOCUS ON API
    Sweet_JS API vs xmerl
    dbg:p ? dbg:c ?

    View full-size slide

  12. ELIXIR: COMMAND LINE
    Copy paste friendly
    Partial execution friendly

    View full-size slide

  13. ELIXIR: FLEXIBLE MODULE
    Organize your code
    Generate your functions (ex: riak_search stop words)
    Compile your spec (ex: mailibex mime type)

    View full-size slide

  14. ELIXIR: FLEXIBLE DSL
    Make code matches your business if it does not match
    functionnal abstractions
    ex: Rule system, HTTP, FSM system

    View full-size slide

  15. ELIXIR: CODE CACHE OPTIMIZATION
    Compile your getter (erlang mochiglobal)
    Templates

    View full-size slide

  16. CONCLUSION
    Overall Elixir productivity seems to beat erlang in our
    experience
    Language is now stable
    The community is very active
    Library are more up to date
    Diversity of developers using it
    in France ?

    View full-size slide

  17. QUESTIONS ?
    QUESTIONS ?
    QUESTIONS ?
    QUESTIONS ?
    QUESTIONS ?
    QUESTIONS ?
    QUESTIONS ?
    QUESTIONS ?
    QUESTIONS ?
    QUESTIONS ?
    QUESTIONS ?
    QUESTIONS ?
    QUESTIONS ?
    QUESTIONS ?
    QUESTIONS ?
    QUESTIONS ?

    View full-size slide