SlideShare a Scribd company logo
Clustering in the wild Ugo Landini CTO, Sourcesense Sergio Bossa Software Architect, Sourcesense
Agenda Why Clustering? Clustering J(2)EE Terracotta in a nutshell. Jira clustering issues. Files and indexes. Stateful applications and home grown caches. Thread and services. HTTP Session. Summary.
Why clustering? Horizontal scalability: Scale out. More computers, to improve throughput when a single one is not enough or costs too much. High availability: More computers to improve uptime. If you unplug a network cable, the system should remain up and running. 24/7, or around. Usually more important than scalability.
Clustering J(2)EE In an ideal world <distributable />   tag in your web.xml Serializable objects in your HTTP session. True, if and only if is J(2)EE Compliant Basically, no arbitrary use of resources and state Files. Threads. Sockets. ... ?
Clustering J(2)EE What do I do with my files? java.io.tmpdir JNDI lookup What do I do with the state of my application (caches, conversational state, etc.)? Stateful Enterprise Java Beans Well established caching frameworks  EHCache,  OSCache, JbossCache JSR 107
Clustering J(2)EE What do I do with my thread/services? JMS (MDBs and topics, mostly) Commonj (Bea and IBM effort) What do I do with my HTTP Session? Serializable objects. Use a good Load Balancer.
Wake up! Almost all successful J(2)EE applications around won't pass the Sun AVK (Application Verification Kit). Most people go straight for the simple solution and that one could be a cluster antipattern home grown caches, lucene indexes, quartz jobs, singletons... add your favourite quickie here.
Enter Terracotta Transparent (Translucid? ...) Clustering. Very few changes to already existent code. Low development effort. Open Source, free for any use. Emerging (and cool!) technology. Did I mention that we are Terracotta partner? :)
The quest for antipatterns Jira is NOT easily clusterable, so it is a nice testbed. Jira is a bug tracking, issue tracking, and project management application developed to make this process easier. Jira is the leading issue tracker in the open source world (though it is not strictly open source). People is asking for a clustered Jira! http://jira.atlassian.com/browse/JRA-7330 Did I mention that we are Atlassian partner?
Terracotta magic
Terracotta magic
Terracotta magic
Terracotta magic
Terracotta magic
Terracotta magic
Terracotta magic
Terracotta magic Terracotta moves around the bytes changed in shared objects No serialization. superstatic objects! same semantic, only  new()  behaves differently Demarcation of transaction with guarded block essentially moves multi-thread application semantic to cluster level. For performance reasons, for certain objects it moves behaviour and not data (logicaly managed vs physically managed objects) you can do the same thing if you need to. (distributed methods)
Terracotta in a nutshell Features, part one: Transparent JVM-level clustering. Transparently works inside your JVM as an infrastructure service. Plugs into your code thanks to bytecode injection. No API, no code changes! Hub-and-Spoke architecture. Central server based architecture. All nodes talk only to the central server. Linear scalability. No split-brain problem.
Terracotta in a nutshell Features, part two: Active/Passive mode. One central active server, n passive servers. Network Attached Memory. Shares your objects graph with the central server. Virtual Heap (on disk, with Berkeley DB) Maintains your object graph in the memory heap. Preserved Java semantics. Object equality (equals, hashCode) Concurrency. (syncronized, java.util.concurrency) Thread communication. (wait, notify)
Terracotta in a nutshell Main concepts: Roots. Defines where your shared objects graph starts. Locks. Ensures data consistency. Enables Terracotta intra-node communication. All code changing parts of the shared objects graph must be guarded by locks. Distributed methods. Enables  plain old Java methods  to be simultaneously called in all cluster nodes.
Out in the wild How did we actually cluster the beast?
Clustering Lucene indexes :  Problems Lucene indexes are typically stored in files. Do you remember? clustering antipattern Used to improve data access speed. How to cluster them? Network based solution : SAN or NFS. Not a viable solution due to locks Messaging based solution : JMS Complicated! Indexes should improve performances, rather than make them worse!
Clustering Lucene indexes :  Solution Let's store indexes in memory! Lucene: Provides support for memory-based indexes. Just use  org.apache.lucene.store.RAMDirectory. Terracotta: Just a matter of configuration. And you can share your lucene indexes.
Clustering Jira caches :  Problems Guess what ... Jira uses home grown caches! Do you remember? clustering antipattern From bad to worse: No unified API! Just a lot of HashMaps and HashSets. Very poor locking policies. Makes configuration-only Terracotta clustering impossible! Unfeasible to use an already existent caching framework.
Clustering Jira caches :  Solution Write a new, ad-hoc, unified caching API. Goals: Simplicity. As simple as using an HashMap. Thread safety. Cache consistency. Terracotta ready. Efficiency. No bottlenecks. No liveness failures.
Caching API : Striving for simplicity. No strange methods. No cluster related configuration. Just the usual GET/PUT methods, and alike. Terracotta makes the clustering work! When choosing how to cluster the cache: Distribute behaviour, rather than data. Jira puts heavyweight objects in cache. Distribute cache invalidation, rather than cache updates. Lower hit ratio but ... Lower network traffic! Higher simplicity!
Caching API : Striving for thread safety. Carefully use Java locks (ok, this was obvious ...). Due to how Jira works: The caching API must be able to group more than one cache under the same lock. The caching API must be able to execute a code block atomically under the same lock. Not so obvious ... Use what we call “ owner  based locking.”
Caching API : Striving for efficiency. Choose the right balance between  too fine grained  and  too coarse grained  locks. Do not use complex lock constructs. Use plain synchronized blocks. Use  lock striping  techniques.
Threads and services Jira periodically triggers threads: Do you remember? clustering antipattern Threaded Jira services: Mail sending. Backup export. Index optimization
Clustering threads and services : Problems Threads cannot be clustered. We have to cluster the launched services. Some services must be shared among cluster nodes. Other services must be distributed. How to distinguish them?
Clustering threads and services : Solution Shared services. Clustered through Terracotta XML configuration. A shared service is executed only on a  single  node. The default. Distributed services. Distributed through Terracotta XML configuration. A distributed service is executed on  every  node. Just implement  com.atlassian.jira.service.JiraDistributedService
HTTP Session Two choices: Cluster it through Terracotta. Very hard. Again, Jira puts a lot of heavyweight objects into session. Leave it unclustered. Use a load balancer with sticky sessions enabled. Jira is not a mission critical application. More simplicity, less complexity. Guess what we chose ... Please give me that shiny new load balancer ...
Dealing with external code Applications are often pluggable. Jira has a rich plugin architecture. External plugins must fit and work into the cluster It is necessary to provide simple APIs or configuration options for making cluster-ready plugins. Practical example :  com.atlassian.jira.service.JiraDistributedService
Toward an end Conclusions
Summary Terracotta is a transparent clustering solution but ... You have to take a lot of decisions and trade-off. If you have to access files in a clustered environment: Slow access: network filesystem, database system. Fast access: use Terracotta network attached memory. If you have to cluster your application state: Carefully make it thread safe. Choose between distributing data or behaviour.
Summary If you have application services: Choose services to share. A shared service runs once per cluster. Choose services to distribute. A distributed service runs once per node. If you have to cluster the HTTP session state: Consider not to cluster it! If you have to deal with application plugins: Provide API hooks or configuration options.
Terracotta + Jira = Scarlet Scarlet. Clusters Jira through Terracotta. Published as a Jira extension. http://confluence.atlassian.com/x/woQuBg Open Source. We want you! Actively developed: November 06, 2007 : 1.0 Beta 1. Very soon : 1.0 Beta 2.
The end Q&A

More Related Content

PPT
Breaking The Clustering Limits @ AlphaCSP JavaEdge 2007
PDF
REST and JAX-RS
PPTX
TheEdge10 : Big Data is Here - Hadoop to the Rescue
PPT
Persisting Your Objects In The Database World @ AlphaCSP Professional OSS Con...
PPTX
From I/O To RAM
PPTX
Smart Data Conference: DL4J and DataVec
PDF
Building stateful systems with akka cluster sharding
PPT
Spark and spark streaming internals
Breaking The Clustering Limits @ AlphaCSP JavaEdge 2007
REST and JAX-RS
TheEdge10 : Big Data is Here - Hadoop to the Rescue
Persisting Your Objects In The Database World @ AlphaCSP Professional OSS Con...
From I/O To RAM
Smart Data Conference: DL4J and DataVec
Building stateful systems with akka cluster sharding
Spark and spark streaming internals

What's hot (20)

PDF
Data Science
PPTX
Survey of Spark for Data Pre-Processing and Analytics
PDF
Real-time streams and logs with Storm and Kafka
PDF
Introduction to Spark ML Pipelines Workshop
PDF
Cassandra Summit 2014: Cyanite — Better Graphite Storage with Apache Cassandra
PPT
OGCE SciDAC2010 Tutorial
PDF
Apache Spark 2.0: Faster, Easier, and Smarter
PDF
Scaling Hibernate with Terracotta
PDF
Apache Spark Tutorial
PPTX
Anomaly Detection with Azure and .NET
PDF
Writing Continuous Applications with Structured Streaming Python APIs in Apac...
PPTX
Apache Storm
PDF
Distributed real time stream processing- why and how
PDF
Building a Database for the End of the World
PDF
Scala Days NYC 2016
PDF
Attacking Machine Learning used in AntiVirus with Reinforcement by Rubén Mart...
PDF
Ray and Its Growing Ecosystem
PPTX
Apache Spark
PDF
Integrating Deep Learning Libraries with Apache Spark
PPTX
Apache Storm 0.9 basic training - Verisign
Data Science
Survey of Spark for Data Pre-Processing and Analytics
Real-time streams and logs with Storm and Kafka
Introduction to Spark ML Pipelines Workshop
Cassandra Summit 2014: Cyanite — Better Graphite Storage with Apache Cassandra
OGCE SciDAC2010 Tutorial
Apache Spark 2.0: Faster, Easier, and Smarter
Scaling Hibernate with Terracotta
Apache Spark Tutorial
Anomaly Detection with Azure and .NET
Writing Continuous Applications with Structured Streaming Python APIs in Apac...
Apache Storm
Distributed real time stream processing- why and how
Building a Database for the End of the World
Scala Days NYC 2016
Attacking Machine Learning used in AntiVirus with Reinforcement by Rubén Mart...
Ray and Its Growing Ecosystem
Apache Spark
Integrating Deep Learning Libraries with Apache Spark
Apache Storm 0.9 basic training - Verisign
Ad

Viewers also liked (9)

PPS
KLIMASKOLEN - 2. kurskveld
PPTX
Tackling Climate Change - Introduction to Teen Activism
PPS
Klimaskolen - 4. kurskveld
PPS
KLIMASKOLEN - 3. kurskveld
PPSX
Climate School Alanya HEP University lecture 1
PPTX
Climate Change Reality
PPTX
WHAT IS CLIMATE CHANGE? -
PPTX
Rotary Alanya: Lecture on Climate Change
PPTX
CLIMATE CHANGE LECTURE 061115 Alanya HEP University
KLIMASKOLEN - 2. kurskveld
Tackling Climate Change - Introduction to Teen Activism
Klimaskolen - 4. kurskveld
KLIMASKOLEN - 3. kurskveld
Climate School Alanya HEP University lecture 1
Climate Change Reality
WHAT IS CLIMATE CHANGE? -
Rotary Alanya: Lecture on Climate Change
CLIMATE CHANGE LECTURE 061115 Alanya HEP University
Ad

Similar to Clustering In The Wild (20)

PPTX
Low latency in java 8 v5
PDF
Monitoring&Logging - Stanislav Kolenkin
PDF
java.util.concurrent for Distributed Coordination, Riga DevDays 2019
PPT
Terracotta DSO
PDF
JCConf 2016 - Cloud Computing Applications - Hazelcast, Spark and Ignite
PPT
Hazelcast
PDF
Kafka internals
PDF
Oracle exalytics deployment for high availability
ODP
Low level java programming
PDF
Distributed Tracing
PPTX
Distributed tracing 101
PDF
Scarlet - Scalable, Redundant, Cloud Enabled JIRA
ODP
Terracotta Ch'ti Jug
PPTX
Apache ignite v1.3
PDF
Near Real time Indexing Kafka Messages to Apache Blur using Spark Streaming
PDF
BISSA: Empowering Web gadget Communication with Tuple Spaces
PDF
Performance Tuning - Memory leaks, Thread deadlocks, JDK tools
DOCX
Hibernate3 q&a
PDF
Building High Scalability Apps With Terracotta
PPTX
Low latency in java 8 by Peter Lawrey
Low latency in java 8 v5
Monitoring&Logging - Stanislav Kolenkin
java.util.concurrent for Distributed Coordination, Riga DevDays 2019
Terracotta DSO
JCConf 2016 - Cloud Computing Applications - Hazelcast, Spark and Ignite
Hazelcast
Kafka internals
Oracle exalytics deployment for high availability
Low level java programming
Distributed Tracing
Distributed tracing 101
Scarlet - Scalable, Redundant, Cloud Enabled JIRA
Terracotta Ch'ti Jug
Apache ignite v1.3
Near Real time Indexing Kafka Messages to Apache Blur using Spark Streaming
BISSA: Empowering Web gadget Communication with Tuple Spaces
Performance Tuning - Memory leaks, Thread deadlocks, JDK tools
Hibernate3 q&a
Building High Scalability Apps With Terracotta
Low latency in java 8 by Peter Lawrey

More from Sergio Bossa (8)

PDF
To be relational, or not to be relational? That's NOT the question!
PDF
Three Languages in Thirty Minutes
PDF
Terrastore - A document database for developers
PDF
Actor concurrency for the JVM: a case study
PDF
Scalable Databases - From Relational Databases To Polyglot Persistence
PDF
Scale Your Database And Be Happy
PDF
Real Terracotta
PDF
Gridify your Spring application with Grid Gain @ Spring Italian Meeting 2008
To be relational, or not to be relational? That's NOT the question!
Three Languages in Thirty Minutes
Terrastore - A document database for developers
Actor concurrency for the JVM: a case study
Scalable Databases - From Relational Databases To Polyglot Persistence
Scale Your Database And Be Happy
Real Terracotta
Gridify your Spring application with Grid Gain @ Spring Italian Meeting 2008

Recently uploaded (20)

PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Empathic Computing: Creating Shared Understanding
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
August Patch Tuesday
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Machine learning based COVID-19 study performance prediction
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
cloud_computing_Infrastucture_as_cloud_p
PPTX
Spectroscopy.pptx food analysis technology
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PPTX
A Presentation on Artificial Intelligence
PPTX
1. Introduction to Computer Programming.pptx
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Mushroom cultivation and it's methods.pdf
Encapsulation_ Review paper, used for researhc scholars
Empathic Computing: Creating Shared Understanding
Unlocking AI with Model Context Protocol (MCP)
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
NewMind AI Weekly Chronicles - August'25-Week II
August Patch Tuesday
Programs and apps: productivity, graphics, security and other tools
Machine learning based COVID-19 study performance prediction
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
cloud_computing_Infrastucture_as_cloud_p
Spectroscopy.pptx food analysis technology
Diabetes mellitus diagnosis method based random forest with bat algorithm
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Assigned Numbers - 2025 - Bluetooth® Document
A Presentation on Artificial Intelligence
1. Introduction to Computer Programming.pptx
Advanced methodologies resolving dimensionality complications for autism neur...
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Mushroom cultivation and it's methods.pdf

Clustering In The Wild

  • 1. Clustering in the wild Ugo Landini CTO, Sourcesense Sergio Bossa Software Architect, Sourcesense
  • 2. Agenda Why Clustering? Clustering J(2)EE Terracotta in a nutshell. Jira clustering issues. Files and indexes. Stateful applications and home grown caches. Thread and services. HTTP Session. Summary.
  • 3. Why clustering? Horizontal scalability: Scale out. More computers, to improve throughput when a single one is not enough or costs too much. High availability: More computers to improve uptime. If you unplug a network cable, the system should remain up and running. 24/7, or around. Usually more important than scalability.
  • 4. Clustering J(2)EE In an ideal world <distributable /> tag in your web.xml Serializable objects in your HTTP session. True, if and only if is J(2)EE Compliant Basically, no arbitrary use of resources and state Files. Threads. Sockets. ... ?
  • 5. Clustering J(2)EE What do I do with my files? java.io.tmpdir JNDI lookup What do I do with the state of my application (caches, conversational state, etc.)? Stateful Enterprise Java Beans Well established caching frameworks EHCache, OSCache, JbossCache JSR 107
  • 6. Clustering J(2)EE What do I do with my thread/services? JMS (MDBs and topics, mostly) Commonj (Bea and IBM effort) What do I do with my HTTP Session? Serializable objects. Use a good Load Balancer.
  • 7. Wake up! Almost all successful J(2)EE applications around won't pass the Sun AVK (Application Verification Kit). Most people go straight for the simple solution and that one could be a cluster antipattern home grown caches, lucene indexes, quartz jobs, singletons... add your favourite quickie here.
  • 8. Enter Terracotta Transparent (Translucid? ...) Clustering. Very few changes to already existent code. Low development effort. Open Source, free for any use. Emerging (and cool!) technology. Did I mention that we are Terracotta partner? :)
  • 9. The quest for antipatterns Jira is NOT easily clusterable, so it is a nice testbed. Jira is a bug tracking, issue tracking, and project management application developed to make this process easier. Jira is the leading issue tracker in the open source world (though it is not strictly open source). People is asking for a clustered Jira! http://jira.atlassian.com/browse/JRA-7330 Did I mention that we are Atlassian partner?
  • 17. Terracotta magic Terracotta moves around the bytes changed in shared objects No serialization. superstatic objects! same semantic, only new() behaves differently Demarcation of transaction with guarded block essentially moves multi-thread application semantic to cluster level. For performance reasons, for certain objects it moves behaviour and not data (logicaly managed vs physically managed objects) you can do the same thing if you need to. (distributed methods)
  • 18. Terracotta in a nutshell Features, part one: Transparent JVM-level clustering. Transparently works inside your JVM as an infrastructure service. Plugs into your code thanks to bytecode injection. No API, no code changes! Hub-and-Spoke architecture. Central server based architecture. All nodes talk only to the central server. Linear scalability. No split-brain problem.
  • 19. Terracotta in a nutshell Features, part two: Active/Passive mode. One central active server, n passive servers. Network Attached Memory. Shares your objects graph with the central server. Virtual Heap (on disk, with Berkeley DB) Maintains your object graph in the memory heap. Preserved Java semantics. Object equality (equals, hashCode) Concurrency. (syncronized, java.util.concurrency) Thread communication. (wait, notify)
  • 20. Terracotta in a nutshell Main concepts: Roots. Defines where your shared objects graph starts. Locks. Ensures data consistency. Enables Terracotta intra-node communication. All code changing parts of the shared objects graph must be guarded by locks. Distributed methods. Enables plain old Java methods to be simultaneously called in all cluster nodes.
  • 21. Out in the wild How did we actually cluster the beast?
  • 22. Clustering Lucene indexes : Problems Lucene indexes are typically stored in files. Do you remember? clustering antipattern Used to improve data access speed. How to cluster them? Network based solution : SAN or NFS. Not a viable solution due to locks Messaging based solution : JMS Complicated! Indexes should improve performances, rather than make them worse!
  • 23. Clustering Lucene indexes : Solution Let's store indexes in memory! Lucene: Provides support for memory-based indexes. Just use org.apache.lucene.store.RAMDirectory. Terracotta: Just a matter of configuration. And you can share your lucene indexes.
  • 24. Clustering Jira caches : Problems Guess what ... Jira uses home grown caches! Do you remember? clustering antipattern From bad to worse: No unified API! Just a lot of HashMaps and HashSets. Very poor locking policies. Makes configuration-only Terracotta clustering impossible! Unfeasible to use an already existent caching framework.
  • 25. Clustering Jira caches : Solution Write a new, ad-hoc, unified caching API. Goals: Simplicity. As simple as using an HashMap. Thread safety. Cache consistency. Terracotta ready. Efficiency. No bottlenecks. No liveness failures.
  • 26. Caching API : Striving for simplicity. No strange methods. No cluster related configuration. Just the usual GET/PUT methods, and alike. Terracotta makes the clustering work! When choosing how to cluster the cache: Distribute behaviour, rather than data. Jira puts heavyweight objects in cache. Distribute cache invalidation, rather than cache updates. Lower hit ratio but ... Lower network traffic! Higher simplicity!
  • 27. Caching API : Striving for thread safety. Carefully use Java locks (ok, this was obvious ...). Due to how Jira works: The caching API must be able to group more than one cache under the same lock. The caching API must be able to execute a code block atomically under the same lock. Not so obvious ... Use what we call “ owner based locking.”
  • 28. Caching API : Striving for efficiency. Choose the right balance between too fine grained and too coarse grained locks. Do not use complex lock constructs. Use plain synchronized blocks. Use lock striping techniques.
  • 29. Threads and services Jira periodically triggers threads: Do you remember? clustering antipattern Threaded Jira services: Mail sending. Backup export. Index optimization
  • 30. Clustering threads and services : Problems Threads cannot be clustered. We have to cluster the launched services. Some services must be shared among cluster nodes. Other services must be distributed. How to distinguish them?
  • 31. Clustering threads and services : Solution Shared services. Clustered through Terracotta XML configuration. A shared service is executed only on a single node. The default. Distributed services. Distributed through Terracotta XML configuration. A distributed service is executed on every node. Just implement com.atlassian.jira.service.JiraDistributedService
  • 32. HTTP Session Two choices: Cluster it through Terracotta. Very hard. Again, Jira puts a lot of heavyweight objects into session. Leave it unclustered. Use a load balancer with sticky sessions enabled. Jira is not a mission critical application. More simplicity, less complexity. Guess what we chose ... Please give me that shiny new load balancer ...
  • 33. Dealing with external code Applications are often pluggable. Jira has a rich plugin architecture. External plugins must fit and work into the cluster It is necessary to provide simple APIs or configuration options for making cluster-ready plugins. Practical example : com.atlassian.jira.service.JiraDistributedService
  • 34. Toward an end Conclusions
  • 35. Summary Terracotta is a transparent clustering solution but ... You have to take a lot of decisions and trade-off. If you have to access files in a clustered environment: Slow access: network filesystem, database system. Fast access: use Terracotta network attached memory. If you have to cluster your application state: Carefully make it thread safe. Choose between distributing data or behaviour.
  • 36. Summary If you have application services: Choose services to share. A shared service runs once per cluster. Choose services to distribute. A distributed service runs once per node. If you have to cluster the HTTP session state: Consider not to cluster it! If you have to deal with application plugins: Provide API hooks or configuration options.
  • 37. Terracotta + Jira = Scarlet Scarlet. Clusters Jira through Terracotta. Published as a Jira extension. http://confluence.atlassian.com/x/woQuBg Open Source. We want you! Actively developed: November 06, 2007 : 1.0 Beta 1. Very soon : 1.0 Beta 2.