SlideShare a Scribd company logo
1 of 33
Download to read offline
REAL TERRACOTTA
Real-world scalability patterns with Terracotta


        SERGIO BOSSA
    Pro-Netics / Sourcesense




         Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense
                                     Javaday Roma III Edizione – 24 gennaio 2009
About Me

    Software architect and engineer
✔

        http://www.pronetics.it
    ➔

        http://www.sourcesense.com
    ➔




    Blogger
✔

        http://sbtourist.blogspot.com
    ➔




    Open Source Enthusiast
✔

    ➔ Lead at Scarlet - Clustering for Jira

            http://scarlet.sf.net
        ➔


        Committer at Spring Modules
    ➔

            http://springmodules.dev.java.net
        ➔


        Committer at Terracotta Forge
    ➔

            http://forge.terracotta.org
        ➔



                          Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense
                                                      Javaday Roma III Edizione – 24 gennaio 2009
Agenda




    Do I need a cluster?
✔




    Terracotta concepts.
✔




    Scalability patterns with Terracotta.
✔




                    Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense
                                                Javaday Roma III Edizione – 24 gennaio 2009
Do I need a cluster?



    The old, dummy, question:
✔

    ➔ Do I need a clustered architecture?




    The correct one:
✔

    ➔ Do I need scalability?

    ➔ Do I need availability?

      ➔ Nowadays, the answer is: yes, you need.




                   Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense
                                               Javaday Roma III Edizione – 24 gennaio 2009
Why should I need a cluster?




    Several changes in the social and market landscape ...
✔




    In a few words:
✔

    ➔ More and more users surfing the web.

    ➔ More and more hardware at cheaper price.

    ➔ More and more processors ... even on a single machine.




                   Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense
                                               Javaday Roma III Edizione – 24 gennaio 2009
What should I use for my cluster?




  Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense
                              Javaday Roma III Edizione – 24 gennaio 2009
The Terracotta Revolution




Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense
                            Javaday Roma III Edizione – 24 gennaio 2009
The Terracotta Revolution


    Transparent clustering.
✔

    ➔ Everything happens under the hood.

    Easy to work with.
✔

    ➔ If you know Java, you can cluster your application with

      no-to-minimal code changes.
    ➔ Deep integration with common frameworks and patterns.

    Optimized for performance.
✔

    ➔ No cross-node communication.

    ➔ Built on the concept of diff.

    Open Source.
✔

    ➔ With a great community.




                   Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense
                                               Javaday Roma III Edizione – 24 gennaio 2009
Terracotta Technology
                               Overview


    Network Attached Memory
✔

    ➔ All cluster nodes share part of their memory heap: a

      shared object graph starting from one or more roots.
    ➔ Shared objects changes are propagated at the byte

      level: only the different bytes get propagated!
    ➔ Shared objects changes are delimited by lock-guarded

      transactions.
    ➔ Shared objects are backed by the cluster server

      filesystem.
    ➔ With preserved Java semantics (i.e. object identity)!




                   Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense
                                               Javaday Roma III Edizione – 24 gennaio 2009
Terracotta Technology
                                Overview



    Hub-and-Spoke network architecture
✔

    ➔ A central cluster server with one or more cluster client

      nodes.
    ➔ Clients talk only with the server.

    ➔ Server can be put in active-passive mode (no SPOF).

    ➔ For enterprise customers only: server can be put in

      active-active mode (no SPOB).




                    Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense
                                                Javaday Roma III Edizione – 24 gennaio 2009
Terracotta Technology
                               Details



    Bytecode instrumentation
✔

    ➔ Instrument classes in order to:

      ➔ Share classes among cluster nodes.

      ➔ Intercept and propagate changes.

      ➔ Apply transactions.

      ➔ Distribute method invocations.




                  Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense
                                              Javaday Roma III Edizione – 24 gennaio 2009
Terracotta Technology
                                 Details



    Roots
✔

    ➔ AKA super-static: created only for the first time, and then

      shared among all cluster nodes.
    ➔ Start of the shared object graph: all objects reachable

      from roots are shared among all cluster nodes.
      ➔ Except transient ones.




                    Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense
                                                Javaday Roma III Edizione – 24 gennaio 2009
Terracotta Technology
                                Details



    Locks
✔

    ➔ Every read or write operation on a shared object state

      must be guarded by locks.
      ➔ Synchronized blocks.

      ➔ java.util.concurrent.locks.ReentrantReadWriteLock

    ➔ Acting as a transaction boundary.

    ➔ Acting as a change propagation boundary.




                   Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense
                                               Javaday Roma III Edizione – 24 gennaio 2009
Terracotta Technology
                                 Details




    Distributed Method Invocation
✔

    ➔ Methods called on a shared object from a cluster node,

      are automatically fired on the same object instance of all
      other cluster nodes.




                    Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense
                                                Javaday Roma III Edizione – 24 gennaio 2009
Terracotta Technology
                               Details




    Declarative configuration:
✔

    ➔ XML file.

    ➔ Java annotations.




                  Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense
                                              Javaday Roma III Edizione – 24 gennaio 2009
Terracotta Quick Start
                                  Plan


    Identify roots and related shared object graphs.
✔

    Identify transactional methods.
✔

    Identify classes that need to be instrumented.
✔

    Identify distributed methods (optional).
✔

    Choose your cluster deployment configuration:
✔

    ➔ How many client nodes?

    ➔ How many server nodes?

    ➔ How much memory?

    ➔ ...




                   Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense
                                               Javaday Roma III Edizione – 24 gennaio 2009
Terracotta Quick Start
                                   Operate
    Configure the cluster.
✔




    Start the Terracotta cluster server:
✔



    sh tc_home/bin/start-tc-server.sh -f path/to/tc-conf.xml


    Start the Terracotta cluster client(s):
✔



    TC_INSTALL_DIR=...

    TC_CONFIG_PATH=...

    . $TC_INSTALL_DIR/bin/dso-env.sh -q

    export JAVA_OPTS=${TC_JAVA_OPTS}

    java ...

                      Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense
                                                  Javaday Roma III Edizione – 24 gennaio 2009
What about real world scalability?
    Feeling like lost at sea?




   Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense
                               Javaday Roma III Edizione – 24 gennaio 2009
Scalability in the real world
                     We need some patterns!

    Cache your data in a distributed fashion.
✔




    Partition your cached data and collocate with your
✔

    processing.

    Asynchronously write-behind to your back-end.
✔




    Asynchronously de-couple components communication.
✔




    Asynchronously de-couple components processing.
✔




                   Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense
                                               Javaday Roma III Edizione – 24 gennaio 2009
Data-affinity caching




Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense
                            Javaday Roma III Edizione – 24 gennaio 2009
Data-affinity caching
                              In a nutshell
    Key concepts:
✔

    ➔ Use a partition function for grouping related entries on

      the same distributed cache instance.
    ➔ Use the partition function to look up the cache instance

      and put/get related entries.
    ➔ Process the cached data on the same node it belongs

      to.

    Key features:
✔

    ➔ No network traffic between cache instances.

    ➔ Distributed load.

    ➔ Higher scalability.




                   Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense
                                               Javaday Roma III Edizione – 24 gennaio 2009
Data-affinity caching
                                   With Terracotta



    Use:
✔

    ➔ Tim-Tree-Map-Cache

            http://forge.terracotta.org/releases/projects/tim-tree-map-cache/
        ➔




    Key classes:
✔

        org.tc.cache.CacheFactory
    ➔

        org.tc.cache.ITerracottaCache
    ➔




                          Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense
                                                      Javaday Roma III Edizione – 24 gennaio 2009
Asynchronous write-behind




Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense
                            Javaday Roma III Edizione – 24 gennaio 2009
Asynchronous write-behind
                         In a nutshell


    Key concepts:
✔

    ➔ Always write and read from your (distributed) cache.

    ➔ Asynchronously schedule writes to the storage.




    Key features:
✔

    ➔ Higher throughput.

    ➔ Load throttling.




                   Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense
                                               Javaday Roma III Edizione – 24 gennaio 2009
Asynchronous write-behind
                               With Terracotta



    Use:
✔

    ➔ Tim-Async

            http://forge.terracotta.org/releases/projects/tim-async/
        ➔




    Key classes:
✔

        org.terracotta.modules.async.AsyncCoordinator
    ➔

        org.terracotta.modules.async.ItemProcessor
    ➔




                          Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense
                                                      Javaday Roma III Edizione – 24 gennaio 2009
Asynchronous messaging




Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense
                            Javaday Roma III Edizione – 24 gennaio 2009
Asynchronous messaging
                          In a nutshell

    Key concepts:
✔

    ➔ Connects application components through pipes.

    ➔ Configure processing filters to elaborate messages and

      make them flow through pipes.

    Key features:
✔

    ➔ De-coupled application components.

    ➔ Higher reliability.

    ➔ Higher scalability.




                   Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense
                                               Javaday Roma III Edizione – 24 gennaio 2009
Asynchronous messaging
                               With Terracotta

    Use:
✔

    ➔ Tim-Pipes

            http://forge.terracotta.org/releases/projects/tim-messaging/
        ➔




    Key classes:
✔

        org.terracotta.message.topology.TopologyManager
    ➔

        org.terracotta.message.topology.Topology
    ➔

        org.terracotta.message.routing.Router
    ➔

        org.terracotta.message.pipe.Pipe
    ➔

        org.terracotta.message.pipe.PipeProcessor
    ➔

        org.terracotta.message.subscriber.Subscriber
    ➔

        org.terracotta.message.subscriber.SubscriberProcessor
    ➔




                          Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense
                                                      Javaday Roma III Edizione – 24 gennaio 2009
Asynchronous processing




Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense
                            Javaday Roma III Edizione – 24 gennaio 2009
Asynchronous processing
                          In a nutshell

    Key concepts:
✔

    ➔ Create a set of tasks.

    ➔ Submit tasks to a master.

    ➔ Tasks will be executed by workers.

    ➔ Eventually wait for tasks to be completed.




    Key features:
✔

    ➔ De-coupled execution of expensive tasks.

    ➔ Parallel execution of tasks.

    ➔ Customisable routing logic.

    ➔ Load distribution.




                   Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense
                                               Javaday Roma III Edizione – 24 gennaio 2009
Asynchronous processing
                               With Terracotta

    Use:
✔

    ➔ Tim-MasterWorker

            http://forge.terracotta.org/releases/projects/tim-messaging/
        ➔




    Key classes:
✔

        org.terracotta.executor.DistributedExecutorService
    ➔

        org.terracotta.executor.DistributedCompletionService
    ➔

        org.terracotta.workmanager.statik.StaticWorkManager
    ➔

        org.terracotta.workmanager.statik.StaticWorker
    ➔

        org.terracotta.workmanager.dynamic.DynamicWorkManager
    ➔

        org.terracotta.workmanager.dynamic.DynamicWorker
    ➔




                          Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense
                                                      Javaday Roma III Edizione – 24 gennaio 2009
Conclusion
                   Enjoy scalability challenges!



    Design your scalable architecture ...
✔




    Program in plain old Java ...
✔




    Run with Terracotta!
✔




                    Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense
                                                Javaday Roma III Edizione – 24 gennaio 2009
Q&A

Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense
                            Javaday Roma III Edizione – 24 gennaio 2009

More Related Content

Similar to Real Terracotta

The State of WebSockets in Django
The State of WebSockets in DjangoThe State of WebSockets in Django
The State of WebSockets in DjangoRami Sayar
 
Erik Skytthe - Monitoring Mesos, Docker, Containers with Zabbix | ZabConf2016
Erik Skytthe - Monitoring Mesos, Docker, Containers with Zabbix | ZabConf2016Erik Skytthe - Monitoring Mesos, Docker, Containers with Zabbix | ZabConf2016
Erik Skytthe - Monitoring Mesos, Docker, Containers with Zabbix | ZabConf2016Zabbix
 
Lightweight Grids With Terracotta
Lightweight Grids With TerracottaLightweight Grids With Terracotta
Lightweight Grids With TerracottaPT.JUG
 
Gridify your Spring application with Grid Gain @ Spring Italian Meeting 2008
Gridify your Spring application with Grid Gain @ Spring Italian Meeting 2008Gridify your Spring application with Grid Gain @ Spring Italian Meeting 2008
Gridify your Spring application with Grid Gain @ Spring Italian Meeting 2008Sergio Bossa
 
Microservices Application Tracing Standards and Simulators - Adrians at OSCON
Microservices Application Tracing Standards and Simulators - Adrians at OSCONMicroservices Application Tracing Standards and Simulators - Adrians at OSCON
Microservices Application Tracing Standards and Simulators - Adrians at OSCONAdrian Cockcroft
 
Using Network Acceleration for an Optimized Edge Cloud Server Architecture
Using Network Acceleration for an Optimized Edge Cloud Server ArchitectureUsing Network Acceleration for an Optimized Edge Cloud Server Architecture
Using Network Acceleration for an Optimized Edge Cloud Server ArchitectureNetronome
 
Tech talk Introduction to containers
Tech talk Introduction to containersTech talk Introduction to containers
Tech talk Introduction to containersViliamPucik
 
State of the art: Server-Side JavaScript (ParisJS)
State of the art: Server-Side JavaScript  (ParisJS)State of the art: Server-Side JavaScript  (ParisJS)
State of the art: Server-Side JavaScript (ParisJS)Alexandre Morgaut
 
Genomic Computation at Scale with Serverless, StackStorm and Docker Swarm
Genomic Computation at Scale with Serverless, StackStorm and Docker SwarmGenomic Computation at Scale with Serverless, StackStorm and Docker Swarm
Genomic Computation at Scale with Serverless, StackStorm and Docker SwarmDmitri Zimine
 
State of the art: Server-Side JavaScript - dejeuner fulljs
State of the art: Server-Side JavaScript - dejeuner fulljsState of the art: Server-Side JavaScript - dejeuner fulljs
State of the art: Server-Side JavaScript - dejeuner fulljsAlexandre Morgaut
 
NiceCover: A Serverless Webapp for Crowdsourcing Data Extraction and Knowledg...
NiceCover: A Serverless Webapp for Crowdsourcing Data Extraction and Knowledg...NiceCover: A Serverless Webapp for Crowdsourcing Data Extraction and Knowledg...
NiceCover: A Serverless Webapp for Crowdsourcing Data Extraction and Knowledg...Tokyo University of Science
 
Javascript - The Stack and Beyond
Javascript - The Stack and BeyondJavascript - The Stack and Beyond
Javascript - The Stack and BeyondAll Things Open
 
Scala.io 2013 - Scala and ZeroMQ: Events beyond the JVM
Scala.io 2013 - Scala and ZeroMQ: Events beyond the JVMScala.io 2013 - Scala and ZeroMQ: Events beyond the JVM
Scala.io 2013 - Scala and ZeroMQ: Events beyond the JVMRUDDER
 
There's no magic... until you talk about databases
 There's no magic... until you talk about databases There's no magic... until you talk about databases
There's no magic... until you talk about databasesESUG
 
How to Build a High-Performance VM for Squeak/Smalltalk in Your Spare Time: A...
How to Build a High-Performance VM for Squeak/Smalltalk in Your Spare Time: A...How to Build a High-Performance VM for Squeak/Smalltalk in Your Spare Time: A...
How to Build a High-Performance VM for Squeak/Smalltalk in Your Spare Time: A...ESUG
 
State of the art: Server-Side JavaScript - WebWorkersCamp IV - Open World For...
State of the art: Server-Side JavaScript - WebWorkersCamp IV - Open World For...State of the art: Server-Side JavaScript - WebWorkersCamp IV - Open World For...
State of the art: Server-Side JavaScript - WebWorkersCamp IV - Open World For...Alexandre Morgaut
 
Practicing at the Cutting Edge: Learning and Unlearning about Java Performance
Practicing at the Cutting Edge: Learning and Unlearning about Java PerformancePracticing at the Cutting Edge: Learning and Unlearning about Java Performance
Practicing at the Cutting Edge: Learning and Unlearning about Java PerformanceC4Media
 

Similar to Real Terracotta (20)

The State of WebSockets in Django
The State of WebSockets in DjangoThe State of WebSockets in Django
The State of WebSockets in Django
 
Erik Skytthe - Monitoring Mesos, Docker, Containers with Zabbix | ZabConf2016
Erik Skytthe - Monitoring Mesos, Docker, Containers with Zabbix | ZabConf2016Erik Skytthe - Monitoring Mesos, Docker, Containers with Zabbix | ZabConf2016
Erik Skytthe - Monitoring Mesos, Docker, Containers with Zabbix | ZabConf2016
 
Lightweight Grids With Terracotta
Lightweight Grids With TerracottaLightweight Grids With Terracotta
Lightweight Grids With Terracotta
 
Gridify your Spring application with Grid Gain @ Spring Italian Meeting 2008
Gridify your Spring application with Grid Gain @ Spring Italian Meeting 2008Gridify your Spring application with Grid Gain @ Spring Italian Meeting 2008
Gridify your Spring application with Grid Gain @ Spring Italian Meeting 2008
 
Open stack@ebay
Open stack@ebayOpen stack@ebay
Open stack@ebay
 
Microservices Application Tracing Standards and Simulators - Adrians at OSCON
Microservices Application Tracing Standards and Simulators - Adrians at OSCONMicroservices Application Tracing Standards and Simulators - Adrians at OSCON
Microservices Application Tracing Standards and Simulators - Adrians at OSCON
 
Using Network Acceleration for an Optimized Edge Cloud Server Architecture
Using Network Acceleration for an Optimized Edge Cloud Server ArchitectureUsing Network Acceleration for an Optimized Edge Cloud Server Architecture
Using Network Acceleration for an Optimized Edge Cloud Server Architecture
 
Tech talk Introduction to containers
Tech talk Introduction to containersTech talk Introduction to containers
Tech talk Introduction to containers
 
W3 C Intro And Beyond - Eyal Sela
W3 C Intro And Beyond - Eyal SelaW3 C Intro And Beyond - Eyal Sela
W3 C Intro And Beyond - Eyal Sela
 
State of the art: Server-Side JavaScript (ParisJS)
State of the art: Server-Side JavaScript  (ParisJS)State of the art: Server-Side JavaScript  (ParisJS)
State of the art: Server-Side JavaScript (ParisJS)
 
Genomic Computation at Scale with Serverless, StackStorm and Docker Swarm
Genomic Computation at Scale with Serverless, StackStorm and Docker SwarmGenomic Computation at Scale with Serverless, StackStorm and Docker Swarm
Genomic Computation at Scale with Serverless, StackStorm and Docker Swarm
 
Java script the-stack-revisited
Java script the-stack-revisitedJava script the-stack-revisited
Java script the-stack-revisited
 
State of the art: Server-Side JavaScript - dejeuner fulljs
State of the art: Server-Side JavaScript - dejeuner fulljsState of the art: Server-Side JavaScript - dejeuner fulljs
State of the art: Server-Side JavaScript - dejeuner fulljs
 
NiceCover: A Serverless Webapp for Crowdsourcing Data Extraction and Knowledg...
NiceCover: A Serverless Webapp for Crowdsourcing Data Extraction and Knowledg...NiceCover: A Serverless Webapp for Crowdsourcing Data Extraction and Knowledg...
NiceCover: A Serverless Webapp for Crowdsourcing Data Extraction and Knowledg...
 
Javascript - The Stack and Beyond
Javascript - The Stack and BeyondJavascript - The Stack and Beyond
Javascript - The Stack and Beyond
 
Scala.io 2013 - Scala and ZeroMQ: Events beyond the JVM
Scala.io 2013 - Scala and ZeroMQ: Events beyond the JVMScala.io 2013 - Scala and ZeroMQ: Events beyond the JVM
Scala.io 2013 - Scala and ZeroMQ: Events beyond the JVM
 
There's no magic... until you talk about databases
 There's no magic... until you talk about databases There's no magic... until you talk about databases
There's no magic... until you talk about databases
 
How to Build a High-Performance VM for Squeak/Smalltalk in Your Spare Time: A...
How to Build a High-Performance VM for Squeak/Smalltalk in Your Spare Time: A...How to Build a High-Performance VM for Squeak/Smalltalk in Your Spare Time: A...
How to Build a High-Performance VM for Squeak/Smalltalk in Your Spare Time: A...
 
State of the art: Server-Side JavaScript - WebWorkersCamp IV - Open World For...
State of the art: Server-Side JavaScript - WebWorkersCamp IV - Open World For...State of the art: Server-Side JavaScript - WebWorkersCamp IV - Open World For...
State of the art: Server-Side JavaScript - WebWorkersCamp IV - Open World For...
 
Practicing at the Cutting Edge: Learning and Unlearning about Java Performance
Practicing at the Cutting Edge: Learning and Unlearning about Java PerformancePracticing at the Cutting Edge: Learning and Unlearning about Java Performance
Practicing at the Cutting Edge: Learning and Unlearning about Java Performance
 

More from Sergio Bossa

To be relational, or not to be relational? That's NOT the question!
To be relational, or not to be relational? That's NOT the question!To be relational, or not to be relational? That's NOT the question!
To be relational, or not to be relational? That's NOT the question!Sergio Bossa
 
Three Languages in Thirty Minutes
Three Languages in Thirty MinutesThree Languages in Thirty Minutes
Three Languages in Thirty MinutesSergio Bossa
 
Terrastore - A document database for developers
Terrastore - A document database for developersTerrastore - A document database for developers
Terrastore - A document database for developersSergio Bossa
 
Actor concurrency for the JVM: a case study
Actor concurrency for the JVM: a case studyActor concurrency for the JVM: a case study
Actor concurrency for the JVM: a case studySergio Bossa
 
Scalable Databases - From Relational Databases To Polyglot Persistence
Scalable Databases - From Relational Databases To Polyglot PersistenceScalable Databases - From Relational Databases To Polyglot Persistence
Scalable Databases - From Relational Databases To Polyglot PersistenceSergio Bossa
 
Scale Your Database And Be Happy
Scale Your Database And Be HappyScale Your Database And Be Happy
Scale Your Database And Be HappySergio Bossa
 
Clustering In The Wild
Clustering In The WildClustering In The Wild
Clustering In The WildSergio Bossa
 

More from Sergio Bossa (7)

To be relational, or not to be relational? That's NOT the question!
To be relational, or not to be relational? That's NOT the question!To be relational, or not to be relational? That's NOT the question!
To be relational, or not to be relational? That's NOT the question!
 
Three Languages in Thirty Minutes
Three Languages in Thirty MinutesThree Languages in Thirty Minutes
Three Languages in Thirty Minutes
 
Terrastore - A document database for developers
Terrastore - A document database for developersTerrastore - A document database for developers
Terrastore - A document database for developers
 
Actor concurrency for the JVM: a case study
Actor concurrency for the JVM: a case studyActor concurrency for the JVM: a case study
Actor concurrency for the JVM: a case study
 
Scalable Databases - From Relational Databases To Polyglot Persistence
Scalable Databases - From Relational Databases To Polyglot PersistenceScalable Databases - From Relational Databases To Polyglot Persistence
Scalable Databases - From Relational Databases To Polyglot Persistence
 
Scale Your Database And Be Happy
Scale Your Database And Be HappyScale Your Database And Be Happy
Scale Your Database And Be Happy
 
Clustering In The Wild
Clustering In The WildClustering In The Wild
Clustering In The Wild
 

Recently uploaded

AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
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
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
"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
 
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
 
"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
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 

Recently uploaded (20)

AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
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
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
"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
 
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
 
"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
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 

Real Terracotta

  • 1. REAL TERRACOTTA Real-world scalability patterns with Terracotta SERGIO BOSSA Pro-Netics / Sourcesense Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense Javaday Roma III Edizione – 24 gennaio 2009
  • 2. About Me Software architect and engineer ✔ http://www.pronetics.it ➔ http://www.sourcesense.com ➔ Blogger ✔ http://sbtourist.blogspot.com ➔ Open Source Enthusiast ✔ ➔ Lead at Scarlet - Clustering for Jira http://scarlet.sf.net ➔ Committer at Spring Modules ➔ http://springmodules.dev.java.net ➔ Committer at Terracotta Forge ➔ http://forge.terracotta.org ➔ Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense Javaday Roma III Edizione – 24 gennaio 2009
  • 3. Agenda Do I need a cluster? ✔ Terracotta concepts. ✔ Scalability patterns with Terracotta. ✔ Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense Javaday Roma III Edizione – 24 gennaio 2009
  • 4. Do I need a cluster? The old, dummy, question: ✔ ➔ Do I need a clustered architecture? The correct one: ✔ ➔ Do I need scalability? ➔ Do I need availability? ➔ Nowadays, the answer is: yes, you need. Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense Javaday Roma III Edizione – 24 gennaio 2009
  • 5. Why should I need a cluster? Several changes in the social and market landscape ... ✔ In a few words: ✔ ➔ More and more users surfing the web. ➔ More and more hardware at cheaper price. ➔ More and more processors ... even on a single machine. Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense Javaday Roma III Edizione – 24 gennaio 2009
  • 6. What should I use for my cluster? Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense Javaday Roma III Edizione – 24 gennaio 2009
  • 7. The Terracotta Revolution Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense Javaday Roma III Edizione – 24 gennaio 2009
  • 8. The Terracotta Revolution Transparent clustering. ✔ ➔ Everything happens under the hood. Easy to work with. ✔ ➔ If you know Java, you can cluster your application with no-to-minimal code changes. ➔ Deep integration with common frameworks and patterns. Optimized for performance. ✔ ➔ No cross-node communication. ➔ Built on the concept of diff. Open Source. ✔ ➔ With a great community. Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense Javaday Roma III Edizione – 24 gennaio 2009
  • 9. Terracotta Technology Overview Network Attached Memory ✔ ➔ All cluster nodes share part of their memory heap: a shared object graph starting from one or more roots. ➔ Shared objects changes are propagated at the byte level: only the different bytes get propagated! ➔ Shared objects changes are delimited by lock-guarded transactions. ➔ Shared objects are backed by the cluster server filesystem. ➔ With preserved Java semantics (i.e. object identity)! Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense Javaday Roma III Edizione – 24 gennaio 2009
  • 10. Terracotta Technology Overview Hub-and-Spoke network architecture ✔ ➔ A central cluster server with one or more cluster client nodes. ➔ Clients talk only with the server. ➔ Server can be put in active-passive mode (no SPOF). ➔ For enterprise customers only: server can be put in active-active mode (no SPOB). Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense Javaday Roma III Edizione – 24 gennaio 2009
  • 11. Terracotta Technology Details Bytecode instrumentation ✔ ➔ Instrument classes in order to: ➔ Share classes among cluster nodes. ➔ Intercept and propagate changes. ➔ Apply transactions. ➔ Distribute method invocations. Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense Javaday Roma III Edizione – 24 gennaio 2009
  • 12. Terracotta Technology Details Roots ✔ ➔ AKA super-static: created only for the first time, and then shared among all cluster nodes. ➔ Start of the shared object graph: all objects reachable from roots are shared among all cluster nodes. ➔ Except transient ones. Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense Javaday Roma III Edizione – 24 gennaio 2009
  • 13. Terracotta Technology Details Locks ✔ ➔ Every read or write operation on a shared object state must be guarded by locks. ➔ Synchronized blocks. ➔ java.util.concurrent.locks.ReentrantReadWriteLock ➔ Acting as a transaction boundary. ➔ Acting as a change propagation boundary. Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense Javaday Roma III Edizione – 24 gennaio 2009
  • 14. Terracotta Technology Details Distributed Method Invocation ✔ ➔ Methods called on a shared object from a cluster node, are automatically fired on the same object instance of all other cluster nodes. Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense Javaday Roma III Edizione – 24 gennaio 2009
  • 15. Terracotta Technology Details Declarative configuration: ✔ ➔ XML file. ➔ Java annotations. Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense Javaday Roma III Edizione – 24 gennaio 2009
  • 16. Terracotta Quick Start Plan Identify roots and related shared object graphs. ✔ Identify transactional methods. ✔ Identify classes that need to be instrumented. ✔ Identify distributed methods (optional). ✔ Choose your cluster deployment configuration: ✔ ➔ How many client nodes? ➔ How many server nodes? ➔ How much memory? ➔ ... Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense Javaday Roma III Edizione – 24 gennaio 2009
  • 17. Terracotta Quick Start Operate Configure the cluster. ✔ Start the Terracotta cluster server: ✔ sh tc_home/bin/start-tc-server.sh -f path/to/tc-conf.xml Start the Terracotta cluster client(s): ✔ TC_INSTALL_DIR=... TC_CONFIG_PATH=... . $TC_INSTALL_DIR/bin/dso-env.sh -q export JAVA_OPTS=${TC_JAVA_OPTS} java ... Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense Javaday Roma III Edizione – 24 gennaio 2009
  • 18. What about real world scalability? Feeling like lost at sea? Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense Javaday Roma III Edizione – 24 gennaio 2009
  • 19. Scalability in the real world We need some patterns! Cache your data in a distributed fashion. ✔ Partition your cached data and collocate with your ✔ processing. Asynchronously write-behind to your back-end. ✔ Asynchronously de-couple components communication. ✔ Asynchronously de-couple components processing. ✔ Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense Javaday Roma III Edizione – 24 gennaio 2009
  • 20. Data-affinity caching Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense Javaday Roma III Edizione – 24 gennaio 2009
  • 21. Data-affinity caching In a nutshell Key concepts: ✔ ➔ Use a partition function for grouping related entries on the same distributed cache instance. ➔ Use the partition function to look up the cache instance and put/get related entries. ➔ Process the cached data on the same node it belongs to. Key features: ✔ ➔ No network traffic between cache instances. ➔ Distributed load. ➔ Higher scalability. Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense Javaday Roma III Edizione – 24 gennaio 2009
  • 22. Data-affinity caching With Terracotta Use: ✔ ➔ Tim-Tree-Map-Cache http://forge.terracotta.org/releases/projects/tim-tree-map-cache/ ➔ Key classes: ✔ org.tc.cache.CacheFactory ➔ org.tc.cache.ITerracottaCache ➔ Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense Javaday Roma III Edizione – 24 gennaio 2009
  • 23. Asynchronous write-behind Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense Javaday Roma III Edizione – 24 gennaio 2009
  • 24. Asynchronous write-behind In a nutshell Key concepts: ✔ ➔ Always write and read from your (distributed) cache. ➔ Asynchronously schedule writes to the storage. Key features: ✔ ➔ Higher throughput. ➔ Load throttling. Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense Javaday Roma III Edizione – 24 gennaio 2009
  • 25. Asynchronous write-behind With Terracotta Use: ✔ ➔ Tim-Async http://forge.terracotta.org/releases/projects/tim-async/ ➔ Key classes: ✔ org.terracotta.modules.async.AsyncCoordinator ➔ org.terracotta.modules.async.ItemProcessor ➔ Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense Javaday Roma III Edizione – 24 gennaio 2009
  • 26. Asynchronous messaging Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense Javaday Roma III Edizione – 24 gennaio 2009
  • 27. Asynchronous messaging In a nutshell Key concepts: ✔ ➔ Connects application components through pipes. ➔ Configure processing filters to elaborate messages and make them flow through pipes. Key features: ✔ ➔ De-coupled application components. ➔ Higher reliability. ➔ Higher scalability. Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense Javaday Roma III Edizione – 24 gennaio 2009
  • 28. Asynchronous messaging With Terracotta Use: ✔ ➔ Tim-Pipes http://forge.terracotta.org/releases/projects/tim-messaging/ ➔ Key classes: ✔ org.terracotta.message.topology.TopologyManager ➔ org.terracotta.message.topology.Topology ➔ org.terracotta.message.routing.Router ➔ org.terracotta.message.pipe.Pipe ➔ org.terracotta.message.pipe.PipeProcessor ➔ org.terracotta.message.subscriber.Subscriber ➔ org.terracotta.message.subscriber.SubscriberProcessor ➔ Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense Javaday Roma III Edizione – 24 gennaio 2009
  • 29. Asynchronous processing Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense Javaday Roma III Edizione – 24 gennaio 2009
  • 30. Asynchronous processing In a nutshell Key concepts: ✔ ➔ Create a set of tasks. ➔ Submit tasks to a master. ➔ Tasks will be executed by workers. ➔ Eventually wait for tasks to be completed. Key features: ✔ ➔ De-coupled execution of expensive tasks. ➔ Parallel execution of tasks. ➔ Customisable routing logic. ➔ Load distribution. Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense Javaday Roma III Edizione – 24 gennaio 2009
  • 31. Asynchronous processing With Terracotta Use: ✔ ➔ Tim-MasterWorker http://forge.terracotta.org/releases/projects/tim-messaging/ ➔ Key classes: ✔ org.terracotta.executor.DistributedExecutorService ➔ org.terracotta.executor.DistributedCompletionService ➔ org.terracotta.workmanager.statik.StaticWorkManager ➔ org.terracotta.workmanager.statik.StaticWorker ➔ org.terracotta.workmanager.dynamic.DynamicWorkManager ➔ org.terracotta.workmanager.dynamic.DynamicWorker ➔ Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense Javaday Roma III Edizione – 24 gennaio 2009
  • 32. Conclusion Enjoy scalability challenges! Design your scalable architecture ... ✔ Program in plain old Java ... ✔ Run with Terracotta! ✔ Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense Javaday Roma III Edizione – 24 gennaio 2009
  • 33. Q&A Sergio Bossa - sergio.bossa@pronetics.it - Pro-Netics / Sourcesense Javaday Roma III Edizione – 24 gennaio 2009