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

1M tickets, 50 lang and 35 currencies

Jose
November 22, 2015

1M tickets, 50 lang and 35 currencies

How we scaled-out our platform to serve 1M tickets in 50 lang and 35 different currencies without database hits

Jose

November 22, 2015
Tweet

More Decks by Jose

Other Decks in Technology

Transcript

  1. 1M tickets, 50 langs and
    35 currencies
    no database hits

    View full-size slide

  2. @jgargallo
    Jose Gargallo

    View full-size slide

  3. A marketplace
    where fans can buy
    and sell tickets

    View full-size slide

  4. Vendo boli, regalo entradas para los Rolling

    View full-size slide

  5. ~ 400 employees
    ~ 50 countries
    ~ 90 m€ in 2015

    View full-size slide

  6. #Tickets histogram

    View full-size slide

  7. ~ 1M tickets
    ~ 50 langs
    ~ 35 currencies
    scenario
    ~ legal res.
    ~ logistic res.
    ~ high traffic

    View full-size slide

  8. CAP theorem
    Consistency Availability
    Partition
    tolerance

    View full-size slide

  9. CAP theorem
    Consistency Availability
    Partition
    tolerance
    ¡you can’t have it all!

    View full-size slide

  10. CAP theorem
    Consistency Availability
    Partition
    tolerance

    View full-size slide

  11. Ticketbis architecture

    View full-size slide

  12. Python daemons
    .
    .
    . .
    .
    .

    View full-size slide

  13. Python daemons
    Getting context

    View full-size slide

  14. Python daemons
    Running daemon

    View full-size slide

  15. Redis queues

    View full-size slide

  16. Redis queues
    (1) A LUA script recovers all failed tickets

    View full-size slide

  17. Redis queues
    (2) Changed tickets are pushed to the queue (LPUSH).
    (3) Consumer process. RPOPLPUSH allows us to keep
    queues reliable, if the process fails, the script will
    recover unprocessed entities.
    (4) Items are removed from the processing queue.

    View full-size slide

  18. ~ 1M tickets
    ~ 50 langs
    ~ 35 currencies
    Denormalization
    ~ legal res.
    ~ logistic res.
    ~ Event stats

    View full-size slide

  19. ~ 1M tickets
    ~ 50 langs
    ~ 35 currencies
    Denormalization
    ~ legal res.
    ~ logistic res.
    ~ Event stats

    View full-size slide

  20. Decimal Arithmetic Benchmark
    float cdecimal decimal
    0.12s 0.27s 17s

    View full-size slide

  21. cdecimal in Python 2
    __init__.py
    ~ cdecimal has been integrated into CPython 3.3,
    where it supersedes the pure Python version
    ~ cdecimal shipped with CPython 3.3 is significantly
    faster for numerical workload than cdecimal-2.3

    View full-size slide

  22. There are only two hard
    things in Computer Science:
    cache invalidation and
    naming things
    -- Phil Karlton

    View full-size slide

  23. Project name: Ironman

    View full-size slide

  24. ~ Inverted indexing
    ~ TTL
    Cache invalidation

    View full-size slide

  25. Cache invalidation
    Inverted indexing
    ~ Categories
    ~ Countries
    ~ others

    View full-size slide

  26. Cache invalidation
    TTLs
    EXPIRE Redis command allows us to set
    timeouts on keys based on event’s date

    View full-size slide

  27. Ticketbis architecture

    View full-size slide

  28. Elasticsearch

    View full-size slide

  29. ~ A distributed RESTful search
    engine
    ~ Apache Lucene is the search
    engine lib behind ES
    Elasticsearch

    View full-size slide

  30. ~ public data: categories & events
    ~ private data: purchases, users, ...
    ~ Ticket prices log
    Elasticsearch: clusters

    View full-size slide

  31. Elasticsearch: Ticket log
    World cup semifinal 2014 average ticket prices
    BRA - GER
    qualified
    1day left

    View full-size slide

  32. Next steps
    ~ Use Redis as an LRU cache
    allkeys-lru, volatile-lru, ...
    ~ API hitting cached data

    View full-size slide

  33. Thank you!
    Jose Gargallo
    @jgargallo

    View full-size slide

  34. We are hiring!
    [email protected]
    @TicketbisEng
    ...and we are remote friendly!

    View full-size slide