terracotta ch'ti jug
TRANSCRIPT
Terracotta
Context Database abuse
Database used to store Durable and Temporary data
The database can become a bottleneck when too many requests
SPOB
SPOF
Goals
High availability
High performances
Linear scalability
A possible solution : data grids
It is a cluster of machines that handles in memory a large quantity of shared data
Terracotta (Server)
Clustering at the JVM level
1 active TC server
Server TC :Shared data
Clients list
Spread the updates
Manage locks
Garbage Collector
Terracotta (Client)
From the codeNo specific storage structure, only use Java classes
Recommanded to use "synchronized" keyword
Configuration file (XML)To configure the objects to share (roots)
To configure locks
To configure distributed methods
...
Useful for
Relieving Database OverloadDistributed Caching
Hibernate second level cache
HTTP Session
Simplifying Application Architecture and avoid clustering by handVirtual Heap for Large Datasets
Clustering OSS Frameworks
Master / Worker
POJO Clustering
Linear Scalability by connected JVMs
HTTP Sessions
Demo
Sample Terracotta application
Clustering a Wicket Application
Wicket stores objects into the sessionPage, PageMap...
These objects would need to be declared in the Terracotta configurationAlready done in a wicket-module for Terracotta
*..*
Gallery
Sharing Data
Wicket, as a Java application, will use objects for the business layer
Instead of coming from the database, those objects can be in memory
Should be declared in the tc-config file
Classes using it (Pages), should declare it in the tc-config file
public class SharedAlbum extends Observable implements Serializable { private List images;private String defaultImage;private String host;private String album;private boolean slideShow = false;}
Demo
Sharing information
Wicket application vs Swing client
Ajax component
Using of a checkbox to activate / deactivate a slideshow
Wicket has built in integration for Ajax behaviours
By clicking on the checkbox, The Album object state will be update on the server with the value of the checkboxThe update object is shared / clustered via Terracotta
add(new AjaxCheckBox("slideshow", new PropertyModel(this, "slideshow")) {
@Overrideprotected void onUpdate(AjaxRequestTarget target) {album.updateSlideShowStatus(slideshow);}});
Slideshow
Demo
Sharing information -Ajax checkbox
Why a cache ?Temporal Locality
Non-uniform distribution
EhCache
Hibernate 2nd level cache
Terracotta
Temporal Locality
Non Uniform Distribution
Non Uniform Distribution
top 4 pages account for >50% of total hitstop 17 pages account for >80% of total hits (14% of total pages)spend small amount of memory to cache top 14% of pages -> remove 80% of load
Cache limitations
Amdahl' LawIf the thing youre caching is not your bottleneck, it wont matter
Memorycache uses memory which your app might need
Concurrencyaccess to cache can be a bottleneck
Reduce LAtency
EhCache
First created in 2003 by Greg Luck
Most widely used Java cache
Apache 2.0 licence
JSR 107 Java cach implementation
EhCache Architecture
Hibernate 2nd Level Cache
Using Terracotta
EhCache 1.7.0 can be as drop in replacement
Side effect on a single node, keeping state
Monitoring and profiling capabilities
Distributed transparently
Using Terracotta
Enhancement to Hibernate
More efficient in-memory and total count eviction (3.1.1)
Better visibility of memory conditions
Improved Query Caching
Improved performance of core Terracotta (lock manager and memory manager)
Cliquez pour diter le format du texte-titre
Cliquez pour diter le format du plan de texteSecond niveau de plan
Troisime niveau de planQuatrime niveau de planCinquime niveau de planSixime niveau de planSeptime niveau de planHuitime niveau de planNeuvime niveau de plan
Zenika 2008