SlideShare a Scribd company logo
1 of 39
Download to read offline
Version 1.1
Your Audience. Your Story.
Scaling to 1,000,000 concurrent users on the JVMJavaOne 2015 - CON7220
Jo Voordeckers
Sr. Software Engineer - Livefyre platform
@jovoordeckers
jvoordeckers@livefyre.com
© LIVEFYRE 2015
Livefyre helps over 1,500 of the most influential 

brands & media companies build an engaged audience
© LIVEFYRE 2014
© LIVEFYRE 2015© LIVEFYRE 2015
COMMENTS REVIEWS
PPL WEARING
JERSEYS
2015 ALL-STAR
GAME
JUMP SHOTS
FAN PHOTOS
HASHTAG
CAMPAIGN
#TopicHub
CHAT LIVE BLOG
real-time streams of UGC 

to scale content creation
Collect
to quickly find and organize
the best social content
Organize
to your website with 

no coding required
Publish
audiences with best in class engagement tools
to increase time on site and build community
ENGAGE
SIDENOTES PHOTO UPLOAD
Privileged and Confidential© LIVEFYRE 2015
Real-TimeSocial Applications
Comments Sidenotes
Reviews
Chat
Media Wall
Live Blog
Polls Storify
Social Maps
Feed
Trending
Gallery
© LIVEFYRE 2015
1/ CHALLENGE
© LIVEFYRE 2015
Real-time challenge
• 1,000,000 concurrent users
• 150,000 per JVM
• 100,000 req/s
• 6-8x c3.2xlarge
• long-poll + ws
• 100s - 1,000s of listeners per stream
• up to 250,000 listeners
• read-heavy
• updates < 2s
© LIVEFYRE 2015
Real-time challenge
• Presidential Debate on Fox News
• from 50,000 req/s
• to 200,000 req/s
• 150,000+ listeners to the stream
© LIVEFYRE 2015
2/BE{TTER,ST}PRACTICES
© LIVEFYRE 2015
Don’t use the “tech stack du jour”
• use the right tools for your problem
• embrace polyglot
• Java, Scala, Jython
• Python
• NodeJS
• K I S S + Y A G N I
© LIVEFYRE 2015
Microservices, not your typical SOA
• well defined tasks
• horizontal scalability
• deploy often
• upstart & supervisord
• java main()
• docker?
• Kafka
• REST
© LIVEFYRE 2015
© LIVEFYRE 2015
Monitor all the things!
are we sad
• error vs success rates and timing
• queue depth or lag
• system resources
• sample high velocity
• /ping and /deep-ping
access patterns
• optimize scaling strategy
• anticipate events
© LIVEFYRE 2015
Mo services mo problems
Dashboards
• service vs system health
• correlate “strange events”
• capacity planning
• app specific
Tools
• statsd + graphite + grafana / gdash
• sentry log4j appender
• nagios + pagerduty
© LIVEFYRE 2015
Mo services mo problems
Dashboards
• service vs system health
• correlate “strange events”
• capacity planning
• app specific
Tools
• statsd + graphite + grafana / gdash
• sentry log4j appender
• nagios + pagerduty
© LIVEFYRE 2015
Request distribution or “data access pattern”
© LIVEFYRE 2015
Request distribution or “data access pattern”
Keep in memory (L1 cache)
© LIVEFYRE 2015
Request distribution or “data access pattern”
Keep in memory (L1 cache)
Get from S3
(L2 cache)
© LIVEFYRE 2015
Request distribution or “data access pattern”
Keep in memory (L1 cache)
Get from S3
(L2 cache)
Similar reqs
Partition users
© LIVEFYRE 2015
Forcing square pegs in a round hole
• choose the right data stores
• Database
• Queue
• sweet spot
• type of data
• type of queries
• some optimized for write
• some optimized for indexing
• trade off of speed and consistency
© LIVEFYRE 2015
https://aphyr.com/tags/Jepsen
Call me maybe - a story of unreliable communication
© LIVEFYRE 2015
3/BUILDINGBLOCKS
© LIVEFYRE 2015
Throttling - Leaky bucket algorithm
• capped output flow 

regardless of input flow
• accrue output allowance over time
• drop requests if insufficient allowance
• cost function

# 1 item per interval
allowance = rate = 1
# 10 sec interval
throttle_interval = 10
# 1req/10sec = 0.1 qps
qps = rate / throttle_interval
last_check = time()
def throttle(item):
current = time() # or item.created_at
size = cost(item) # [0..1]
time_passed = current - last_check
last_check = current
allowance += time_passed * qps
# Cap to rate
allowance = min(rate, allowance)
if allowance < size:
return True
allowance -= size
return False
© LIVEFYRE 2015
Counting ‘Heavy Hitters’ - Space Saving Algorithm
• unbounded stream
• TOP-K in constant space
• k * (item, count, error)
• overestimates on replace
• min(count)
• MIN Heap + HashMap
counts = { } # map of item to count
errors = { } # map of item to error count
for item in stream:
if len(counts) < k:
counts[item] += weight
else:
if item in counts:
counts[item] += 1
else:
prev_min = item_with_min_count(counts)
counts[item] = counts[prev_min] + 1 1
errors[item] = counts[prev_min]
counts.remove_key(prev_min)
© LIVEFYRE 2015
Partitioning - Consistent Hashing
• article_id % server_count
• what if hosts added/removed ?
• thundering herd!
• Hashing.consistentHash(item, server_count)
• minimizes shuffling
• ConsistentHashRing with virtual nodes
• TreeSet with 100 replicas per node
- hash(“node1:1”) .. hash(“node1:100”)
- hash(“node2:1”) .. (“node2:100”) ,…
• SortedMap.get(hash(item)) or
• SortedMap.tailMap(hash(item)).firstKey()
© LIVEFYRE 2015
Partitioning - Consistent Hashing
• article_id % server_count
• what if hosts added/removed ?
• thundering herd!
• Hashing.consistentHash(item, server_count)
• minimizes shuffling
• ConsistentHashRing with virtual nodes
• TreeSet with 100 replicas per node
- hash(“node1:1”) .. hash(“node1:100”)
- hash(“node2:1”) .. (“node2:100”) ,…
• SortedMap.get(hash(item)) or
• SortedMap.tailMap(hash(item)).firstKey()
© LIVEFYRE 2015
Partitioning - Consistent Hashing
• article_id % server_count
• what if hosts added/removed ?
• thundering herd!
• Hashing.consistentHash(item, server_count)
• minimizes shuffling
• ConsistentHashRing with virtual nodes
• TreeSet with 100 replicas per node
- hash(“node1:1”) .. hash(“node1:100”)
- hash(“node2:1”) .. (“node2:100”) ,…
• SortedMap.get(hash(item)) or
• SortedMap.tailMap(hash(item)).firstKey()
© LIVEFYRE 2015
Partitioning - Consistent Hashing
• article_id % server_count
• what if hosts added/removed ?
• thundering herd!
• Hashing.consistentHash(item, server_count)
• minimizes shuffling
• ConsistentHashRing with virtual nodes
• TreeSet with 100 replicas per node
- hash(“node1:1”) .. hash(“node1:100”)
- hash(“node2:1”) .. (“node2:100”) ,…
• SortedMap.get(hash(item)) or
• SortedMap.tailMap(hash(item)).firstKey()
© LIVEFYRE 2015
Partitioning - Consistent Hashing
• article_id % server_count
• what if hosts added/removed ?
• thundering herd!
• Hashing.consistentHash(item, server_count)
• minimizes shuffling
• ConsistentHashRing with virtual nodes
• TreeSet with 100 replicas per node
- hash(“node1:1”) .. hash(“node1:100”)
- hash(“node2:1”) .. (“node2:100”) ,…
• SortedMap.get(hash(item)) or
• SortedMap.tailMap(hash(item)).firstKey()
© LIVEFYRE 2015
Membership test - Bloom Filters
• very memory efficient
• almost as fast as CHM
• small % false pos
• ZERO false neg
• append only
• see Cuckoo Filter
• BloomFilter.create()
© LIVEFYRE 2015
Membership test - Bloom Filters
• very memory efficient
• almost as fast as CHM
• small % false pos
• ZERO false neg
• append only
• see Cuckoo Filter
• BloomFilter.create()
© LIVEFYRE 2015
Membership test - Bloom Filters
• very memory efficient
• almost as fast as CHM
• small % false pos
• ZERO false neg
• append only
• see Cuckoo Filter
• BloomFilter.create()
© LIVEFYRE 2015
Membership test - Bloom Filters
• very memory efficient
• almost as fast as CHM
• small % false pos
• ZERO false neg
• append only
• see Cuckoo Filter
• BloomFilter.create()
© LIVEFYRE 2015
• ConcurrentHashMap’s secret
• eg: ConcurrentBloomFilter
• up to n threads non-blocking
• n shards with a ReadWriteLock

and BloomFilter
• ConsistentHash index into shards
• Striped in Guava
Concurrency for shared resources - Striped Lock
© LIVEFYRE 2015
© LIVEFYRE 2015
Random Sampling
float sampleRate = 0.10f; // 10%
if (ThreadLocalRandom.current().nextFloat() < sampleRate) {
statsd.increment("high.velocity.request.success");
}
• for high velocity events
• NEVER for sparse events
© LIVEFYRE 2015
• metadata store
• set membership
• distributed lock
• leader election
• Netflix Curator
• DON’T TRY THIS AT HOME!
Distributed Consensus - Zookeeper
© LIVEFYRE 2015
Async IO
• Get up to 1M connections, capped by bandwidth
• Netty
• EPOLL on Linux
• (Composite)ByteBuf
• ChannelGroup
• HashedWheelTimer
• READ THE SOURCE!
• Others work as well:
• Vert.x, NodeJS, Python Gevent
© LIVEFYRE 2015
Data processing pipelines
• Kafka Queues with many partitions
• Auto-scale group of workers
• commit batches of work to ZK (restart, lag)
• Emit stats (success, error, timing)
• Custom dashboard
• sampled data from the stream
• inject data in the stream (debug)
• Future:
• Spark Streaming
• Mesos + Marathon + Chronos
© LIVEFYRE 2015
Mechanical Sympathy
• Disruptor, lock-free Queue
• BlockingQueue - backpressure!
• JCTools - Multi Prod Single Cons Queue
• CAS - Atomic* & Unsafe
• OpenHFT
• off-heap storage
• cpu affinity for JVM threads
• zero allocation hashing
• mechanical-sympathy.blogspot.com
THANKYOU
San Francisco, CA

New York, NY

London, UK
@livefyre.com
press.livefyre.com
blog.livefyre.com
Jo Voordeckers
SR.SOFTWAREENGINEER-LFPLATFORM
Email: jvoordeckers@livefyre.com
@jovoordeckers

More Related Content

What's hot

KubeCon 2019 Recap (Parts 1-3)
KubeCon 2019 Recap (Parts 1-3)KubeCon 2019 Recap (Parts 1-3)
KubeCon 2019 Recap (Parts 1-3)Ford Prior
 
Ncku csie talk about Spark
Ncku csie talk about SparkNcku csie talk about Spark
Ncku csie talk about SparkGiivee The
 
Erlang factory SF 2011 "Erlang and the big switch in social games"
Erlang factory SF 2011 "Erlang and the big switch in social games"Erlang factory SF 2011 "Erlang and the big switch in social games"
Erlang factory SF 2011 "Erlang and the big switch in social games"Paolo Negri
 
Accumulo Nutch/GORA, Storm, and Pig
Accumulo Nutch/GORA, Storm, and PigAccumulo Nutch/GORA, Storm, and Pig
Accumulo Nutch/GORA, Storm, and PigJason Trost
 
Cloud Native Data Pipelines (in Eng & Japanese) - QCon Tokyo
Cloud Native Data Pipelines (in Eng & Japanese)  - QCon TokyoCloud Native Data Pipelines (in Eng & Japanese)  - QCon Tokyo
Cloud Native Data Pipelines (in Eng & Japanese) - QCon TokyoSid Anand
 
(GAM301) Real-Time Game Analytics with Amazon Kinesis, Amazon Redshift, and A...
(GAM301) Real-Time Game Analytics with Amazon Kinesis, Amazon Redshift, and A...(GAM301) Real-Time Game Analytics with Amazon Kinesis, Amazon Redshift, and A...
(GAM301) Real-Time Game Analytics with Amazon Kinesis, Amazon Redshift, and A...Amazon Web Services
 
The Evolution of Big Data at Spotify
The Evolution of Big Data at SpotifyThe Evolution of Big Data at Spotify
The Evolution of Big Data at SpotifyJosh Baer
 
How Parse Built a Mobile Backend as a Service on AWS (MBL307) | AWS re:Invent...
How Parse Built a Mobile Backend as a Service on AWS (MBL307) | AWS re:Invent...How Parse Built a Mobile Backend as a Service on AWS (MBL307) | AWS re:Invent...
How Parse Built a Mobile Backend as a Service on AWS (MBL307) | AWS re:Invent...Amazon Web Services
 
From Zero to Hadoop: a tutorial for getting started writing Hadoop jobs on Am...
From Zero to Hadoop: a tutorial for getting started writing Hadoop jobs on Am...From Zero to Hadoop: a tutorial for getting started writing Hadoop jobs on Am...
From Zero to Hadoop: a tutorial for getting started writing Hadoop jobs on Am...Alexander Dean
 
Erlang as a cloud citizen, a fractal approach to throughput
Erlang as a cloud citizen, a fractal approach to throughputErlang as a cloud citizen, a fractal approach to throughput
Erlang as a cloud citizen, a fractal approach to throughputPaolo Negri
 
TransAtlantic Networking using Cloud links
TransAtlantic Networking using Cloud linksTransAtlantic Networking using Cloud links
TransAtlantic Networking using Cloud linksIgor Sfiligoi
 
Cloud Native Data Pipelines (DataEngConf SF 2017)
Cloud Native Data Pipelines (DataEngConf SF 2017)Cloud Native Data Pipelines (DataEngConf SF 2017)
Cloud Native Data Pipelines (DataEngConf SF 2017)Sid Anand
 
Structure Data 2014: BIG DATA ANALYTICS RE-INVENTED, Ryan Waite
Structure Data 2014: BIG DATA ANALYTICS RE-INVENTED, Ryan WaiteStructure Data 2014: BIG DATA ANALYTICS RE-INVENTED, Ryan Waite
Structure Data 2014: BIG DATA ANALYTICS RE-INVENTED, Ryan WaiteGigaom
 
AWS vs Azure vs Google Cloud Storage Deep Dive
AWS vs Azure vs Google Cloud Storage Deep DiveAWS vs Azure vs Google Cloud Storage Deep Dive
AWS vs Azure vs Google Cloud Storage Deep DiveRightScale
 
Big Data Streaming processing using Apache Storm - FOSSCOMM 2016
Big Data Streaming processing using Apache Storm - FOSSCOMM 2016Big Data Streaming processing using Apache Storm - FOSSCOMM 2016
Big Data Streaming processing using Apache Storm - FOSSCOMM 2016Adrianos Dadis
 
Distributed and Fault Tolerant Realtime Computation with Apache Storm, Apache...
Distributed and Fault Tolerant Realtime Computation with Apache Storm, Apache...Distributed and Fault Tolerant Realtime Computation with Apache Storm, Apache...
Distributed and Fault Tolerant Realtime Computation with Apache Storm, Apache...Folio3 Software
 

What's hot (17)

KubeCon 2019 Recap (Parts 1-3)
KubeCon 2019 Recap (Parts 1-3)KubeCon 2019 Recap (Parts 1-3)
KubeCon 2019 Recap (Parts 1-3)
 
Ncku csie talk about Spark
Ncku csie talk about SparkNcku csie talk about Spark
Ncku csie talk about Spark
 
Erlang factory SF 2011 "Erlang and the big switch in social games"
Erlang factory SF 2011 "Erlang and the big switch in social games"Erlang factory SF 2011 "Erlang and the big switch in social games"
Erlang factory SF 2011 "Erlang and the big switch in social games"
 
Accumulo Nutch/GORA, Storm, and Pig
Accumulo Nutch/GORA, Storm, and PigAccumulo Nutch/GORA, Storm, and Pig
Accumulo Nutch/GORA, Storm, and Pig
 
Cloud Native Data Pipelines (in Eng & Japanese) - QCon Tokyo
Cloud Native Data Pipelines (in Eng & Japanese)  - QCon TokyoCloud Native Data Pipelines (in Eng & Japanese)  - QCon Tokyo
Cloud Native Data Pipelines (in Eng & Japanese) - QCon Tokyo
 
(GAM301) Real-Time Game Analytics with Amazon Kinesis, Amazon Redshift, and A...
(GAM301) Real-Time Game Analytics with Amazon Kinesis, Amazon Redshift, and A...(GAM301) Real-Time Game Analytics with Amazon Kinesis, Amazon Redshift, and A...
(GAM301) Real-Time Game Analytics with Amazon Kinesis, Amazon Redshift, and A...
 
The Evolution of Big Data at Spotify
The Evolution of Big Data at SpotifyThe Evolution of Big Data at Spotify
The Evolution of Big Data at Spotify
 
How Parse Built a Mobile Backend as a Service on AWS (MBL307) | AWS re:Invent...
How Parse Built a Mobile Backend as a Service on AWS (MBL307) | AWS re:Invent...How Parse Built a Mobile Backend as a Service on AWS (MBL307) | AWS re:Invent...
How Parse Built a Mobile Backend as a Service on AWS (MBL307) | AWS re:Invent...
 
From Zero to Hadoop: a tutorial for getting started writing Hadoop jobs on Am...
From Zero to Hadoop: a tutorial for getting started writing Hadoop jobs on Am...From Zero to Hadoop: a tutorial for getting started writing Hadoop jobs on Am...
From Zero to Hadoop: a tutorial for getting started writing Hadoop jobs on Am...
 
Introduction to Storm
Introduction to StormIntroduction to Storm
Introduction to Storm
 
Erlang as a cloud citizen, a fractal approach to throughput
Erlang as a cloud citizen, a fractal approach to throughputErlang as a cloud citizen, a fractal approach to throughput
Erlang as a cloud citizen, a fractal approach to throughput
 
TransAtlantic Networking using Cloud links
TransAtlantic Networking using Cloud linksTransAtlantic Networking using Cloud links
TransAtlantic Networking using Cloud links
 
Cloud Native Data Pipelines (DataEngConf SF 2017)
Cloud Native Data Pipelines (DataEngConf SF 2017)Cloud Native Data Pipelines (DataEngConf SF 2017)
Cloud Native Data Pipelines (DataEngConf SF 2017)
 
Structure Data 2014: BIG DATA ANALYTICS RE-INVENTED, Ryan Waite
Structure Data 2014: BIG DATA ANALYTICS RE-INVENTED, Ryan WaiteStructure Data 2014: BIG DATA ANALYTICS RE-INVENTED, Ryan Waite
Structure Data 2014: BIG DATA ANALYTICS RE-INVENTED, Ryan Waite
 
AWS vs Azure vs Google Cloud Storage Deep Dive
AWS vs Azure vs Google Cloud Storage Deep DiveAWS vs Azure vs Google Cloud Storage Deep Dive
AWS vs Azure vs Google Cloud Storage Deep Dive
 
Big Data Streaming processing using Apache Storm - FOSSCOMM 2016
Big Data Streaming processing using Apache Storm - FOSSCOMM 2016Big Data Streaming processing using Apache Storm - FOSSCOMM 2016
Big Data Streaming processing using Apache Storm - FOSSCOMM 2016
 
Distributed and Fault Tolerant Realtime Computation with Apache Storm, Apache...
Distributed and Fault Tolerant Realtime Computation with Apache Storm, Apache...Distributed and Fault Tolerant Realtime Computation with Apache Storm, Apache...
Distributed and Fault Tolerant Realtime Computation with Apache Storm, Apache...
 

Viewers also liked

How Top Brands Unify Social Measurement Across the Marketing Stack
How Top Brands Unify Social Measurement Across the Marketing StackHow Top Brands Unify Social Measurement Across the Marketing Stack
How Top Brands Unify Social Measurement Across the Marketing StackOrigami Logic
 
Time-Saving Tools for Social Media Management
Time-Saving Tools for Social Media ManagementTime-Saving Tools for Social Media Management
Time-Saving Tools for Social Media ManagementKristie Wells
 
Spredfast talk at #DSManchester on "Monetising Social"
Spredfast talk at #DSManchester on "Monetising Social"Spredfast talk at #DSManchester on "Monetising Social"
Spredfast talk at #DSManchester on "Monetising Social"CASTdigital
 
10 Reasons You Should Invest in User-Generated Content
10 Reasons You Should Invest in User-Generated Content10 Reasons You Should Invest in User-Generated Content
10 Reasons You Should Invest in User-Generated ContentArtifacia
 
Spredfast 2.0 Overview
Spredfast 2.0 OverviewSpredfast 2.0 Overview
Spredfast 2.0 OverviewSpredfast
 
Build it before you need it -Social@Scale: Crisis Management
Build it before you need it -Social@Scale: Crisis ManagementBuild it before you need it -Social@Scale: Crisis Management
Build it before you need it -Social@Scale: Crisis ManagementSprinklr
 
core_deck_updated.pptx
core_deck_updated.pptxcore_deck_updated.pptx
core_deck_updated.pptxAcme Co.
 
Social media engagement Tools
Social media engagement ToolsSocial media engagement Tools
Social media engagement ToolsDML Srl
 
Social Media Management Platform Benchmark Review
Social Media Management Platform Benchmark ReviewSocial Media Management Platform Benchmark Review
Social Media Management Platform Benchmark ReviewWhite Horse
 

Viewers also liked (10)

Diana Walker 2015 CV
Diana Walker  2015 CVDiana Walker  2015 CV
Diana Walker 2015 CV
 
How Top Brands Unify Social Measurement Across the Marketing Stack
How Top Brands Unify Social Measurement Across the Marketing StackHow Top Brands Unify Social Measurement Across the Marketing Stack
How Top Brands Unify Social Measurement Across the Marketing Stack
 
Time-Saving Tools for Social Media Management
Time-Saving Tools for Social Media ManagementTime-Saving Tools for Social Media Management
Time-Saving Tools for Social Media Management
 
Spredfast talk at #DSManchester on "Monetising Social"
Spredfast talk at #DSManchester on "Monetising Social"Spredfast talk at #DSManchester on "Monetising Social"
Spredfast talk at #DSManchester on "Monetising Social"
 
10 Reasons You Should Invest in User-Generated Content
10 Reasons You Should Invest in User-Generated Content10 Reasons You Should Invest in User-Generated Content
10 Reasons You Should Invest in User-Generated Content
 
Spredfast 2.0 Overview
Spredfast 2.0 OverviewSpredfast 2.0 Overview
Spredfast 2.0 Overview
 
Build it before you need it -Social@Scale: Crisis Management
Build it before you need it -Social@Scale: Crisis ManagementBuild it before you need it -Social@Scale: Crisis Management
Build it before you need it -Social@Scale: Crisis Management
 
core_deck_updated.pptx
core_deck_updated.pptxcore_deck_updated.pptx
core_deck_updated.pptx
 
Social media engagement Tools
Social media engagement ToolsSocial media engagement Tools
Social media engagement Tools
 
Social Media Management Platform Benchmark Review
Social Media Management Platform Benchmark ReviewSocial Media Management Platform Benchmark Review
Social Media Management Platform Benchmark Review
 

Similar to Scaling to 1 million concurrent users on the JVM

Data Platform at Twitter: Enabling Real-time & Batch Analytics at Scale
Data Platform at Twitter: Enabling Real-time & Batch Analytics at ScaleData Platform at Twitter: Enabling Real-time & Batch Analytics at Scale
Data Platform at Twitter: Enabling Real-time & Batch Analytics at ScaleSriram Krishnan
 
IMCSummit 2015 - Day 2 Developer Track - A Reference Architecture for the Int...
IMCSummit 2015 - Day 2 Developer Track - A Reference Architecture for the Int...IMCSummit 2015 - Day 2 Developer Track - A Reference Architecture for the Int...
IMCSummit 2015 - Day 2 Developer Track - A Reference Architecture for the Int...In-Memory Computing Summit
 
Reference architecture for Internet of Things
Reference architecture for Internet of ThingsReference architecture for Internet of Things
Reference architecture for Internet of ThingsSujee Maniyam
 
Reference architecture for Internet Of Things
Reference architecture for Internet Of ThingsReference architecture for Internet Of Things
Reference architecture for Internet Of Thingselephantscale
 
Stateful Stream Processing at In-Memory Speed
Stateful Stream Processing at In-Memory SpeedStateful Stream Processing at In-Memory Speed
Stateful Stream Processing at In-Memory SpeedJamie Grier
 
Building a system for machine and event-oriented data - Velocity, Santa Clara...
Building a system for machine and event-oriented data - Velocity, Santa Clara...Building a system for machine and event-oriented data - Velocity, Santa Clara...
Building a system for machine and event-oriented data - Velocity, Santa Clara...Eric Sammer
 
Fast SQL on Hadoop, really?
Fast SQL on Hadoop, really?Fast SQL on Hadoop, really?
Fast SQL on Hadoop, really?DataWorks Summit
 
Building a system for machine and event-oriented data - Data Day Seattle 2015
Building a system for machine and event-oriented data - Data Day Seattle 2015Building a system for machine and event-oriented data - Data Day Seattle 2015
Building a system for machine and event-oriented data - Data Day Seattle 2015Eric Sammer
 
Understanding apache-druid
Understanding apache-druidUnderstanding apache-druid
Understanding apache-druidSuman Banerjee
 
First Hive Meetup London 2012-07-10 - Tomas Cervenka - VisualDNA
First Hive Meetup London 2012-07-10 - Tomas Cervenka - VisualDNAFirst Hive Meetup London 2012-07-10 - Tomas Cervenka - VisualDNA
First Hive Meetup London 2012-07-10 - Tomas Cervenka - VisualDNATomas Cervenka
 
Building a system for machine and event-oriented data with Rocana
Building a system for machine and event-oriented data with RocanaBuilding a system for machine and event-oriented data with Rocana
Building a system for machine and event-oriented data with RocanaTreasure Data, Inc.
 
Building an Event-oriented Data Platform with Kafka, Eric Sammer
Building an Event-oriented Data Platform with Kafka, Eric Sammer Building an Event-oriented Data Platform with Kafka, Eric Sammer
Building an Event-oriented Data Platform with Kafka, Eric Sammer confluent
 
Jeff Lindsay: Building Public Infrastructure with Autosustainable Services
Jeff Lindsay: Building Public Infrastructure with Autosustainable ServicesJeff Lindsay: Building Public Infrastructure with Autosustainable Services
Jeff Lindsay: Building Public Infrastructure with Autosustainable Servicesit-people
 
Apache Eagle at Hadoop Summit 2016 San Jose
Apache Eagle at Hadoop Summit 2016 San JoseApache Eagle at Hadoop Summit 2016 San Jose
Apache Eagle at Hadoop Summit 2016 San JoseHao Chen
 
Stress Testing at Twitter: a tale of New Year Eves
Stress Testing at Twitter: a tale of New Year EvesStress Testing at Twitter: a tale of New Year Eves
Stress Testing at Twitter: a tale of New Year EvesHerval Freire
 
Building a system for machine and event-oriented data - SF HUG Nov 2015
Building a system for machine and event-oriented data - SF HUG Nov 2015Building a system for machine and event-oriented data - SF HUG Nov 2015
Building a system for machine and event-oriented data - SF HUG Nov 2015Felicia Haggarty
 
Building Sexy Real-Time Analytics Systems - Erlang Factory NYC / Toronto 2013
Building Sexy Real-Time Analytics Systems - Erlang Factory NYC / Toronto 2013Building Sexy Real-Time Analytics Systems - Erlang Factory NYC / Toronto 2013
Building Sexy Real-Time Analytics Systems - Erlang Factory NYC / Toronto 2013lpgauth
 

Similar to Scaling to 1 million concurrent users on the JVM (20)

Data Platform at Twitter: Enabling Real-time & Batch Analytics at Scale
Data Platform at Twitter: Enabling Real-time & Batch Analytics at ScaleData Platform at Twitter: Enabling Real-time & Batch Analytics at Scale
Data Platform at Twitter: Enabling Real-time & Batch Analytics at Scale
 
IMCSummit 2015 - Day 2 Developer Track - A Reference Architecture for the Int...
IMCSummit 2015 - Day 2 Developer Track - A Reference Architecture for the Int...IMCSummit 2015 - Day 2 Developer Track - A Reference Architecture for the Int...
IMCSummit 2015 - Day 2 Developer Track - A Reference Architecture for the Int...
 
Reference architecture for Internet of Things
Reference architecture for Internet of ThingsReference architecture for Internet of Things
Reference architecture for Internet of Things
 
Reference architecture for Internet Of Things
Reference architecture for Internet Of ThingsReference architecture for Internet Of Things
Reference architecture for Internet Of Things
 
Stateful Stream Processing at In-Memory Speed
Stateful Stream Processing at In-Memory SpeedStateful Stream Processing at In-Memory Speed
Stateful Stream Processing at In-Memory Speed
 
Building a system for machine and event-oriented data - Velocity, Santa Clara...
Building a system for machine and event-oriented data - Velocity, Santa Clara...Building a system for machine and event-oriented data - Velocity, Santa Clara...
Building a system for machine and event-oriented data - Velocity, Santa Clara...
 
Fast SQL on Hadoop, really?
Fast SQL on Hadoop, really?Fast SQL on Hadoop, really?
Fast SQL on Hadoop, really?
 
Building a system for machine and event-oriented data - Data Day Seattle 2015
Building a system for machine and event-oriented data - Data Day Seattle 2015Building a system for machine and event-oriented data - Data Day Seattle 2015
Building a system for machine and event-oriented data - Data Day Seattle 2015
 
Understanding apache-druid
Understanding apache-druidUnderstanding apache-druid
Understanding apache-druid
 
First Hive Meetup London 2012-07-10 - Tomas Cervenka - VisualDNA
First Hive Meetup London 2012-07-10 - Tomas Cervenka - VisualDNAFirst Hive Meetup London 2012-07-10 - Tomas Cervenka - VisualDNA
First Hive Meetup London 2012-07-10 - Tomas Cervenka - VisualDNA
 
Building a system for machine and event-oriented data with Rocana
Building a system for machine and event-oriented data with RocanaBuilding a system for machine and event-oriented data with Rocana
Building a system for machine and event-oriented data with Rocana
 
Building an Event-oriented Data Platform with Kafka, Eric Sammer
Building an Event-oriented Data Platform with Kafka, Eric Sammer Building an Event-oriented Data Platform with Kafka, Eric Sammer
Building an Event-oriented Data Platform with Kafka, Eric Sammer
 
Apache Eagle - Monitor Hadoop in Real Time
Apache Eagle - Monitor Hadoop in Real TimeApache Eagle - Monitor Hadoop in Real Time
Apache Eagle - Monitor Hadoop in Real Time
 
Jeff Lindsay: Building Public Infrastructure with Autosustainable Services
Jeff Lindsay: Building Public Infrastructure with Autosustainable ServicesJeff Lindsay: Building Public Infrastructure with Autosustainable Services
Jeff Lindsay: Building Public Infrastructure with Autosustainable Services
 
Apache Eagle: Secure Hadoop in Real Time
Apache Eagle: Secure Hadoop in Real TimeApache Eagle: Secure Hadoop in Real Time
Apache Eagle: Secure Hadoop in Real Time
 
Apache Eagle at Hadoop Summit 2016 San Jose
Apache Eagle at Hadoop Summit 2016 San JoseApache Eagle at Hadoop Summit 2016 San Jose
Apache Eagle at Hadoop Summit 2016 San Jose
 
Stress Testing at Twitter: a tale of New Year Eves
Stress Testing at Twitter: a tale of New Year EvesStress Testing at Twitter: a tale of New Year Eves
Stress Testing at Twitter: a tale of New Year Eves
 
Building a system for machine and event-oriented data - SF HUG Nov 2015
Building a system for machine and event-oriented data - SF HUG Nov 2015Building a system for machine and event-oriented data - SF HUG Nov 2015
Building a system for machine and event-oriented data - SF HUG Nov 2015
 
HDP2 and YARN operations point
HDP2 and YARN operations pointHDP2 and YARN operations point
HDP2 and YARN operations point
 
Building Sexy Real-Time Analytics Systems - Erlang Factory NYC / Toronto 2013
Building Sexy Real-Time Analytics Systems - Erlang Factory NYC / Toronto 2013Building Sexy Real-Time Analytics Systems - Erlang Factory NYC / Toronto 2013
Building Sexy Real-Time Analytics Systems - Erlang Factory NYC / Toronto 2013
 

Recently uploaded

Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 

Recently uploaded (20)

Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 

Scaling to 1 million concurrent users on the JVM

  • 1. Version 1.1 Your Audience. Your Story. Scaling to 1,000,000 concurrent users on the JVMJavaOne 2015 - CON7220 Jo Voordeckers Sr. Software Engineer - Livefyre platform @jovoordeckers jvoordeckers@livefyre.com
  • 2. © LIVEFYRE 2015 Livefyre helps over 1,500 of the most influential 
 brands & media companies build an engaged audience © LIVEFYRE 2014
  • 3. © LIVEFYRE 2015© LIVEFYRE 2015 COMMENTS REVIEWS PPL WEARING JERSEYS 2015 ALL-STAR GAME JUMP SHOTS FAN PHOTOS HASHTAG CAMPAIGN #TopicHub CHAT LIVE BLOG real-time streams of UGC 
 to scale content creation Collect to quickly find and organize the best social content Organize to your website with 
 no coding required Publish audiences with best in class engagement tools to increase time on site and build community ENGAGE SIDENOTES PHOTO UPLOAD
  • 4. Privileged and Confidential© LIVEFYRE 2015 Real-TimeSocial Applications Comments Sidenotes Reviews Chat Media Wall Live Blog Polls Storify Social Maps Feed Trending Gallery
  • 6. © LIVEFYRE 2015 Real-time challenge • 1,000,000 concurrent users • 150,000 per JVM • 100,000 req/s • 6-8x c3.2xlarge • long-poll + ws • 100s - 1,000s of listeners per stream • up to 250,000 listeners • read-heavy • updates < 2s
  • 7. © LIVEFYRE 2015 Real-time challenge • Presidential Debate on Fox News • from 50,000 req/s • to 200,000 req/s • 150,000+ listeners to the stream
  • 9. © LIVEFYRE 2015 Don’t use the “tech stack du jour” • use the right tools for your problem • embrace polyglot • Java, Scala, Jython • Python • NodeJS • K I S S + Y A G N I
  • 10. © LIVEFYRE 2015 Microservices, not your typical SOA • well defined tasks • horizontal scalability • deploy often • upstart & supervisord • java main() • docker? • Kafka • REST
  • 12. © LIVEFYRE 2015 Monitor all the things! are we sad • error vs success rates and timing • queue depth or lag • system resources • sample high velocity • /ping and /deep-ping access patterns • optimize scaling strategy • anticipate events
  • 13. © LIVEFYRE 2015 Mo services mo problems Dashboards • service vs system health • correlate “strange events” • capacity planning • app specific Tools • statsd + graphite + grafana / gdash • sentry log4j appender • nagios + pagerduty
  • 14. © LIVEFYRE 2015 Mo services mo problems Dashboards • service vs system health • correlate “strange events” • capacity planning • app specific Tools • statsd + graphite + grafana / gdash • sentry log4j appender • nagios + pagerduty
  • 15. © LIVEFYRE 2015 Request distribution or “data access pattern”
  • 16. © LIVEFYRE 2015 Request distribution or “data access pattern” Keep in memory (L1 cache)
  • 17. © LIVEFYRE 2015 Request distribution or “data access pattern” Keep in memory (L1 cache) Get from S3 (L2 cache)
  • 18. © LIVEFYRE 2015 Request distribution or “data access pattern” Keep in memory (L1 cache) Get from S3 (L2 cache) Similar reqs Partition users
  • 19. © LIVEFYRE 2015 Forcing square pegs in a round hole • choose the right data stores • Database • Queue • sweet spot • type of data • type of queries • some optimized for write • some optimized for indexing • trade off of speed and consistency
  • 20. © LIVEFYRE 2015 https://aphyr.com/tags/Jepsen Call me maybe - a story of unreliable communication
  • 22. © LIVEFYRE 2015 Throttling - Leaky bucket algorithm • capped output flow 
 regardless of input flow • accrue output allowance over time • drop requests if insufficient allowance • cost function
 # 1 item per interval allowance = rate = 1 # 10 sec interval throttle_interval = 10 # 1req/10sec = 0.1 qps qps = rate / throttle_interval last_check = time() def throttle(item): current = time() # or item.created_at size = cost(item) # [0..1] time_passed = current - last_check last_check = current allowance += time_passed * qps # Cap to rate allowance = min(rate, allowance) if allowance < size: return True allowance -= size return False
  • 23. © LIVEFYRE 2015 Counting ‘Heavy Hitters’ - Space Saving Algorithm • unbounded stream • TOP-K in constant space • k * (item, count, error) • overestimates on replace • min(count) • MIN Heap + HashMap counts = { } # map of item to count errors = { } # map of item to error count for item in stream: if len(counts) < k: counts[item] += weight else: if item in counts: counts[item] += 1 else: prev_min = item_with_min_count(counts) counts[item] = counts[prev_min] + 1 1 errors[item] = counts[prev_min] counts.remove_key(prev_min)
  • 24. © LIVEFYRE 2015 Partitioning - Consistent Hashing • article_id % server_count • what if hosts added/removed ? • thundering herd! • Hashing.consistentHash(item, server_count) • minimizes shuffling • ConsistentHashRing with virtual nodes • TreeSet with 100 replicas per node - hash(“node1:1”) .. hash(“node1:100”) - hash(“node2:1”) .. (“node2:100”) ,… • SortedMap.get(hash(item)) or • SortedMap.tailMap(hash(item)).firstKey()
  • 25. © LIVEFYRE 2015 Partitioning - Consistent Hashing • article_id % server_count • what if hosts added/removed ? • thundering herd! • Hashing.consistentHash(item, server_count) • minimizes shuffling • ConsistentHashRing with virtual nodes • TreeSet with 100 replicas per node - hash(“node1:1”) .. hash(“node1:100”) - hash(“node2:1”) .. (“node2:100”) ,… • SortedMap.get(hash(item)) or • SortedMap.tailMap(hash(item)).firstKey()
  • 26. © LIVEFYRE 2015 Partitioning - Consistent Hashing • article_id % server_count • what if hosts added/removed ? • thundering herd! • Hashing.consistentHash(item, server_count) • minimizes shuffling • ConsistentHashRing with virtual nodes • TreeSet with 100 replicas per node - hash(“node1:1”) .. hash(“node1:100”) - hash(“node2:1”) .. (“node2:100”) ,… • SortedMap.get(hash(item)) or • SortedMap.tailMap(hash(item)).firstKey()
  • 27. © LIVEFYRE 2015 Partitioning - Consistent Hashing • article_id % server_count • what if hosts added/removed ? • thundering herd! • Hashing.consistentHash(item, server_count) • minimizes shuffling • ConsistentHashRing with virtual nodes • TreeSet with 100 replicas per node - hash(“node1:1”) .. hash(“node1:100”) - hash(“node2:1”) .. (“node2:100”) ,… • SortedMap.get(hash(item)) or • SortedMap.tailMap(hash(item)).firstKey()
  • 28. © LIVEFYRE 2015 Partitioning - Consistent Hashing • article_id % server_count • what if hosts added/removed ? • thundering herd! • Hashing.consistentHash(item, server_count) • minimizes shuffling • ConsistentHashRing with virtual nodes • TreeSet with 100 replicas per node - hash(“node1:1”) .. hash(“node1:100”) - hash(“node2:1”) .. (“node2:100”) ,… • SortedMap.get(hash(item)) or • SortedMap.tailMap(hash(item)).firstKey()
  • 29. © LIVEFYRE 2015 Membership test - Bloom Filters • very memory efficient • almost as fast as CHM • small % false pos • ZERO false neg • append only • see Cuckoo Filter • BloomFilter.create()
  • 30. © LIVEFYRE 2015 Membership test - Bloom Filters • very memory efficient • almost as fast as CHM • small % false pos • ZERO false neg • append only • see Cuckoo Filter • BloomFilter.create()
  • 31. © LIVEFYRE 2015 Membership test - Bloom Filters • very memory efficient • almost as fast as CHM • small % false pos • ZERO false neg • append only • see Cuckoo Filter • BloomFilter.create()
  • 32. © LIVEFYRE 2015 Membership test - Bloom Filters • very memory efficient • almost as fast as CHM • small % false pos • ZERO false neg • append only • see Cuckoo Filter • BloomFilter.create()
  • 33. © LIVEFYRE 2015 • ConcurrentHashMap’s secret • eg: ConcurrentBloomFilter • up to n threads non-blocking • n shards with a ReadWriteLock
 and BloomFilter • ConsistentHash index into shards • Striped in Guava Concurrency for shared resources - Striped Lock © LIVEFYRE 2015
  • 34. © LIVEFYRE 2015 Random Sampling float sampleRate = 0.10f; // 10% if (ThreadLocalRandom.current().nextFloat() < sampleRate) { statsd.increment("high.velocity.request.success"); } • for high velocity events • NEVER for sparse events
  • 35. © LIVEFYRE 2015 • metadata store • set membership • distributed lock • leader election • Netflix Curator • DON’T TRY THIS AT HOME! Distributed Consensus - Zookeeper
  • 36. © LIVEFYRE 2015 Async IO • Get up to 1M connections, capped by bandwidth • Netty • EPOLL on Linux • (Composite)ByteBuf • ChannelGroup • HashedWheelTimer • READ THE SOURCE! • Others work as well: • Vert.x, NodeJS, Python Gevent
  • 37. © LIVEFYRE 2015 Data processing pipelines • Kafka Queues with many partitions • Auto-scale group of workers • commit batches of work to ZK (restart, lag) • Emit stats (success, error, timing) • Custom dashboard • sampled data from the stream • inject data in the stream (debug) • Future: • Spark Streaming • Mesos + Marathon + Chronos
  • 38. © LIVEFYRE 2015 Mechanical Sympathy • Disruptor, lock-free Queue • BlockingQueue - backpressure! • JCTools - Multi Prod Single Cons Queue • CAS - Atomic* & Unsafe • OpenHFT • off-heap storage • cpu affinity for JVM threads • zero allocation hashing • mechanical-sympathy.blogspot.com
  • 39. THANKYOU San Francisco, CA
 New York, NY
 London, UK @livefyre.com press.livefyre.com blog.livefyre.com Jo Voordeckers SR.SOFTWAREENGINEER-LFPLATFORM Email: jvoordeckers@livefyre.com @jovoordeckers