SlideShare une entreprise Scribd logo
1  sur  37
Télécharger pour lire hors ligne
Garbage, Garbage Everywhere
GC Strategies for Event Processing Systems on the JVM

C. Scott Andreas
Pizza, Beer, and Tech Talks
November 17, 2011
What’s ESP / CEP?

•   Event Stream Processing
    Selecting events on dimensions among a stream of moving
    data, maintaining them for a brief period, emitting aggregations.

•   Complex Event Processing
    Identifying correlations between events, predicting trends,
    and programmatically reacting to emergent trends.
ESP and Network Analytics

•   Packet flows are event streams with many dimensions.

•   Blast them into the engine, select over the stream,
    emit aggregations based on queries.

•   Ipfix data flows in, JSON comes out.
Back of the Envelope

•   500 Mbps / sec data comes into the JVM
    xxx Mbps / sec data goes out of the JVM

•   This memory must be allocated, retained
    for processing, freed, and collected.

•   Actual allocation rates far higher than data in / out
    (Memory also used for deserializing, aggregations, etc).
Opening the Grimoire

•   GC Tuning to the rescue

•   Oracle guide with 84 -XX: options

•   Stas’s guide: 830 options (OpenJDK debug builds)

    http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html

    http://stas-blogspot.blogspot.com/2011/07/most-complete-list-of-xx-options-for.html
Moment of Pause

•   Don’t touch the knobs unless you need to

•   Server defaults are a decent place to start for local development

•   Defaults shipped with Cassandra decent for bimodal GC profiles

•   Basic rule of thumb: if you’re aggressively tuning garbage
    collection, you can trade hours of frustration for ~10% gain
Generational Garbage Collection

•   Modern JVMs divide heap space up into multiple “generations.”

•   Most applications have a lot of objects which live for a very short
    time, and a lot which live (nearly) forever.

•   Generational collection enables the JVM to collect unused
    memory more efficiently by avoiding unnecessarily scanning
    heap / object graphs for references or free regions.
first attempt: “deploy the g1”
Low-Pause Collector: The G1




  v% => threshold violations. lower is better.
G1 Collector

•   Hundreds of tiny 1ms collections / second rather than
    ParNew’s ~100 - 200ms larger collections.

•   Capable of meeting ambitious pause targets.

•   Powered by a gang of threads working in parallel

    •   ...cooperating to chew through CPU like it’s free.
second attempt:
you’re gonna laugh
the unsafe
Unsafe

•   A OpenJDK/HotSpot class exposing direct access to the
    underlying VM, OS, and memory.

•   This includes the ability to allocate, manage, and free memory.

•   Perhaps we can outsmart the JVM and do a better job than it!
Learned While Astray
•   Finalization occurs in a single thread.

•   Jumping from native finalization back into Java is expensive.

•   Attempting to outsmart the garbage collector by creating
    hundreds of thousands of tiny ByteBuffers is...a thing.

•   Java’s collectors are very good at collecting garbage.
    Your home-grown in-app GC go-kart is probably not.
returning to earth ::
attempt 3[a]
Lessons from Science
•   Your rate of “freeing” must be equal to or exceed your rate of
    object allocation on the heap.

•   High rates of allocation speed up heap fragmentation,
    which compounds the problem.

•   Creating less garbage reduces your rate of allocation
    (and freeing).

•   This means less work for the garbage collector.
best way to help out the gc ::
PRODUCE LESS
  GARBAGE
Breaking out YourKit
attempt 3[b]:
responsible tuning of the old hat
Optimizing for Infant Mortality
                                                      default newgen ratios in java 6




•   Java 6 AMD64 (server) defaults to allocating
    1/3 of heap to the new gen, 2/3 to the old gen.

•   ESP/CEP workloads place tremendous pressure on the newgen.
    The vast majority of objects survive less than five seconds.

•   Experiment: Allocate 80% of heap to the new gen, set a higher
    tenuring threshold, and lean hard on the ParNew collector.
CMS Collector

•   Guardian of the tenured generation, favorite workhorse for years.

•   Primarily parallel, easier on the CPU than the G1.

•   ...But contains a significant pause phase, is less suited to
    meeting low pause targets.
ParNew Collector

•   Designed for the small, but works great in the large.
    Excellent throughput, parallel collection.

•   Can collect ~5GB in ~200ms on a quad-core Xeon w/HT.

•   200ms pause every several seconds favorable compared to
    less frequent multi-second pauses and promotion failures.
Explosions in the Barrel
“real-time” and the jvm
Real Time and the JVM

•   Real Time
    Ability to meet specific targets with low variance is critical to the
    bare minimum functionality of the product (e.g., air bags).

•   “Soft” Real Time
    Ability to meet targets important but not critical. Value of
    system’s functionality is diminished but not eliminated by delay.
Real Time and “The Pause”

•   To what extent can a system which can endure pauses of
    unpredictable duration be considered “real-time”?

•   Is it sufficient to mitigate the frequency and duration of pauses
    for a system to still deliver value as “soft real-time”?

•   Is the alternative worth the cost?
what does your app sound like?
Garbage, Garbage Everywhere
GC Strategies for Event Processing Systems on the JVM

C. Scott Andreas
Pizza, Beer, and Tech Talks
November 17, 2011

Contenu connexe

Dernier

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKJago de Vreede
 

Dernier (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 

En vedette

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

En vedette (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Scott Andreas - Garbage, Garbage Everywhere: GC Strategies for Event Processing Systems on the JVM, Boundary Tech Talks 11/17/11

  • 1. Garbage, Garbage Everywhere GC Strategies for Event Processing Systems on the JVM C. Scott Andreas Pizza, Beer, and Tech Talks November 17, 2011
  • 2. What’s ESP / CEP? • Event Stream Processing Selecting events on dimensions among a stream of moving data, maintaining them for a brief period, emitting aggregations. • Complex Event Processing Identifying correlations between events, predicting trends, and programmatically reacting to emergent trends.
  • 3. ESP and Network Analytics • Packet flows are event streams with many dimensions. • Blast them into the engine, select over the stream, emit aggregations based on queries. • Ipfix data flows in, JSON comes out.
  • 4. Back of the Envelope • 500 Mbps / sec data comes into the JVM xxx Mbps / sec data goes out of the JVM • This memory must be allocated, retained for processing, freed, and collected. • Actual allocation rates far higher than data in / out (Memory also used for deserializing, aggregations, etc).
  • 5.
  • 6.
  • 7. Opening the Grimoire • GC Tuning to the rescue • Oracle guide with 84 -XX: options • Stas’s guide: 830 options (OpenJDK debug builds) http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html http://stas-blogspot.blogspot.com/2011/07/most-complete-list-of-xx-options-for.html
  • 8. Moment of Pause • Don’t touch the knobs unless you need to • Server defaults are a decent place to start for local development • Defaults shipped with Cassandra decent for bimodal GC profiles • Basic rule of thumb: if you’re aggressively tuning garbage collection, you can trade hours of frustration for ~10% gain
  • 9. Generational Garbage Collection • Modern JVMs divide heap space up into multiple “generations.” • Most applications have a lot of objects which live for a very short time, and a lot which live (nearly) forever. • Generational collection enables the JVM to collect unused memory more efficiently by avoiding unnecessarily scanning heap / object graphs for references or free regions.
  • 11. Low-Pause Collector: The G1 v% => threshold violations. lower is better.
  • 12.
  • 13. G1 Collector • Hundreds of tiny 1ms collections / second rather than ParNew’s ~100 - 200ms larger collections. • Capable of meeting ambitious pause targets. • Powered by a gang of threads working in parallel • ...cooperating to chew through CPU like it’s free.
  • 16. Unsafe • A OpenJDK/HotSpot class exposing direct access to the underlying VM, OS, and memory. • This includes the ability to allocate, manage, and free memory. • Perhaps we can outsmart the JVM and do a better job than it!
  • 17.
  • 18.
  • 19.
  • 20. Learned While Astray • Finalization occurs in a single thread. • Jumping from native finalization back into Java is expensive. • Attempting to outsmart the garbage collector by creating hundreds of thousands of tiny ByteBuffers is...a thing. • Java’s collectors are very good at collecting garbage. Your home-grown in-app GC go-kart is probably not.
  • 21. returning to earth :: attempt 3[a]
  • 22. Lessons from Science • Your rate of “freeing” must be equal to or exceed your rate of object allocation on the heap. • High rates of allocation speed up heap fragmentation, which compounds the problem. • Creating less garbage reduces your rate of allocation (and freeing). • This means less work for the garbage collector.
  • 23. best way to help out the gc ::
  • 24. PRODUCE LESS GARBAGE
  • 27. Optimizing for Infant Mortality default newgen ratios in java 6 • Java 6 AMD64 (server) defaults to allocating 1/3 of heap to the new gen, 2/3 to the old gen. • ESP/CEP workloads place tremendous pressure on the newgen. The vast majority of objects survive less than five seconds. • Experiment: Allocate 80% of heap to the new gen, set a higher tenuring threshold, and lean hard on the ParNew collector.
  • 28. CMS Collector • Guardian of the tenured generation, favorite workhorse for years. • Primarily parallel, easier on the CPU than the G1. • ...But contains a significant pause phase, is less suited to meeting low pause targets.
  • 29. ParNew Collector • Designed for the small, but works great in the large. Excellent throughput, parallel collection. • Can collect ~5GB in ~200ms on a quad-core Xeon w/HT. • 200ms pause every several seconds favorable compared to less frequent multi-second pauses and promotion failures.
  • 31.
  • 32.
  • 34. Real Time and the JVM • Real Time Ability to meet specific targets with low variance is critical to the bare minimum functionality of the product (e.g., air bags). • “Soft” Real Time Ability to meet targets important but not critical. Value of system’s functionality is diminished but not eliminated by delay.
  • 35. Real Time and “The Pause” • To what extent can a system which can endure pauses of unpredictable duration be considered “real-time”? • Is it sufficient to mitigate the frequency and duration of pauses for a system to still deliver value as “soft real-time”? • Is the alternative worth the cost?
  • 36. what does your app sound like?
  • 37. Garbage, Garbage Everywhere GC Strategies for Event Processing Systems on the JVM C. Scott Andreas Pizza, Beer, and Tech Talks November 17, 2011