scala - experiences
TRANSCRIPT
Scala - ExperiencesLeon Maia@leonmaia
CPH Scala Meetup3.11.16
About me
● HP, Hotel Urbano, Globo.com and now Tradeshift.● Scala for the last 4 years.● Interests: Distributed Systems, highly available and fault tolerant systems.
2
Agenda
● Globo?● Challenges - Goals.● Geofencing - how we solved it?● Finagle - Filters.● Scalaz - Either.● The Extractor Pattern.● Readers.● Rio 2016 Olympics.● Metrics, Metrics, Everywhere.● DEMO.
3
Globo?
4
$4.83 billion in media revenue
Our stack
● Scala.● Finagle.● Twitter Server.● Guava Cache.● Zipkin.
5
Challenges - Goals
● Be able to handle absurd spikes on the API during the beginning of the events.
● Make it super simple to adjust settings live.● ZERO DOWNTIME.
○ HA + FT!
● High-throughput and low-latency!● Non-disruptive background loading.● Geofencing.
6
Geofencing
7
The geofencing problem
● Geofences extensively used for geo-based transmissions.● MySQL Geometry functions.● 3 decimal places - 110m.● Not able to cache.
8
Numbers..?
● The response time was < 5 ms at 95th percentile, and < 50 ms at the 99th percentile.
● Was able to handle 64000 req/s with 7 machines running at 40% CPU usage.
9
10
Using Either
11
Using Either - Part 2
12
Filters
13
Clients
14
The extractor pattern
● Decompose various kinds of data structures using pattern matching.● Constructor: creates an object from a given list of parameters.● Extractor: extracts the parameters from which an object passed to it was
created.
15
Besides all that, it must be simple.
16
What we achieved
● Good maintainability.● Absurdly low response times.● Robust error handling and recovery.● Smart caching.● Able to handle huge traffic spikes.
17
Rio 2016 Olympics.
18
19
Audience during the game BRA x SWE.
“We used around 5.5 TB of memory with 1056 CPUs across two PoPs located in the southeast of the country.
20
DEMO
21
Thanks!
22