Terracotta
Context – Database abuse <ul><li>Database used to store Durable and Temporary data
The database can become a bottleneck when too many requests </li></ul><ul><ul><ul><li>SPOB
SPOF </li></ul></ul></ul>
Goals <ul><li>High availability </li></ul><ul><li>High performances </li></ul><ul><li>Linear scalability </li></ul><ul><li...
Terracotta (Server) <ul><li>Clustering at the JVM level
1 active TC server
Server TC : </li><ul><li>Shared data
Clients list
Spread the updates
Manage locks
Garbage Collector </li></ul></ul>
Terracotta (Client) <ul><li>From the code </li><ul><li>No specific storage structure, only use Java classes
Recommanded to use &quot;synchronized&quot; keyword  </li></ul><li>Configuration file (XML) </li><ul><li>To configure the ...
To configure locks
To configure distributed methods
... </li></ul></ul>
Useful for <ul><li>Relieving Database Overload </li><ul><li>Distributed Caching
Hibernate second level cache
HTTP Session </li></ul></ul><ul><li>Simplifying Application Architecture and avoid clustering by hand </li><ul><li>Virtual...
Clustering OSS Frameworks
Master / Worker
POJO Clustering </li></ul></ul><ul><li>Linear Scalability by connected JVMs </li></ul>
HTTP Sessions
Demo Sample Terracotta application
Clustering a Wicket Application <ul><li>Wicket stores objects into the session </li><ul><li>Page, PageMap... </li></ul></u...
Upcoming SlideShare
Loading in …5
×

Terracotta Ch'ti Jug

1,259 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,259
On SlideShare
0
From Embeds
0
Number of Embeds
105
Actions
Shares
0
Downloads
29
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Terracotta Ch'ti Jug

  1. 1. Terracotta
  2. 2. Context – Database abuse <ul><li>Database used to store Durable and Temporary data
  3. 3. The database can become a bottleneck when too many requests </li></ul><ul><ul><ul><li>SPOB
  4. 4. SPOF </li></ul></ul></ul>
  5. 5. Goals <ul><li>High availability </li></ul><ul><li>High performances </li></ul><ul><li>Linear scalability </li></ul><ul><li>A possible solution : data grids </li></ul><ul><li>It is a cluster of machines that handles in memory a large quantity of shared data </li></ul>
  6. 6. Terracotta (Server) <ul><li>Clustering at the JVM level
  7. 7. 1 active TC server
  8. 8. Server TC : </li><ul><li>Shared data
  9. 9. Clients list
  10. 10. Spread the updates
  11. 11. Manage locks
  12. 12. Garbage Collector </li></ul></ul>
  13. 13. Terracotta (Client) <ul><li>From the code </li><ul><li>No specific storage structure, only use Java classes
  14. 14. Recommanded to use &quot;synchronized&quot; keyword </li></ul><li>Configuration file (XML) </li><ul><li>To configure the objects to share (roots)
  15. 15. To configure locks
  16. 16. To configure distributed methods
  17. 17. ... </li></ul></ul>
  18. 18. Useful for <ul><li>Relieving Database Overload </li><ul><li>Distributed Caching
  19. 19. Hibernate second level cache
  20. 20. HTTP Session </li></ul></ul><ul><li>Simplifying Application Architecture and avoid clustering by hand </li><ul><li>Virtual Heap for Large Datasets
  21. 21. Clustering OSS Frameworks
  22. 22. Master / Worker
  23. 23. POJO Clustering </li></ul></ul><ul><li>Linear Scalability by connected JVMs </li></ul>
  24. 24. HTTP Sessions
  25. 25. Demo Sample Terracotta application
  26. 26. Clustering a Wicket Application <ul><li>Wicket stores objects into the session </li><ul><li>Page, PageMap... </li></ul></ul><ul><li>These objects would need to be declared in the Terracotta configuration </li><ul><li>Already done in a wicket-module for Terracotta </li></ul></ul><clients> <modules> <module name= &quot;clustered-wicket-1.3&quot; version= &quot;2.6.2&quot; /> </modules> </clients> <instrumented-classes> <!--Include all classes for DSO instrumentation--> <include> <class-expression> *..* </class-expression> </include> </instrumented-classes> <!--Tell DSO which applications in your web container is using DSO--> <web-applications> <web-application> Gallery </web-application> </web-applications>
  27. 27. Sharing Data <ul><li>Wicket, as a Java application, will use objects for the business layer </li></ul><ul><li>Instead of coming from the database, those objects can be in memory </li></ul><ul><li>Should be declared in the tc-config file </li></ul><ul><li>Classes using it (Pages), should declare it in the tc-config file </li></ul>public class SharedAlbum extends Observable implements Serializable { private List<String> images; private String defaultImage; private String host; private String album; private boolean slideShow = false ; }
  28. 28. Demo Sharing information Wicket application vs Swing client
  29. 29. Ajax component <ul><li>Using of a checkbox to activate / deactivate a slideshow </li></ul><ul><li>Wicket has built in integration for Ajax behaviours </li></ul><ul><li>By clicking on the checkbox, The « Album » object state will be update on the server with the value of the checkbox </li><ul><li>The update object is shared / clustered via Terracotta </li></ul></ul>add( new AjaxCheckBox( &quot;slideshow&quot; , new PropertyModel( this , &quot;slideshow&quot; )) { @Override protected void onUpdate(AjaxRequestTarget target) { album.updateSlideShowStatus( slideshow ); } }); <input type= &quot;checkbox&quot; wicket:id= &quot;slideshow&quot; value= &quot;true&quot; > Slideshow </input>
  30. 30. Demo Sharing information -Ajax checkbox
  31. 32. <ul><li>Why a cache ? </li><ul><li>Temporal Locality
  32. 33. Non-uniform distribution </li></ul></ul><ul><li>EhCache </li></ul><ul><li>Hibernate 2 nd level cache </li></ul><ul><li>Terracotta </li></ul>
  33. 34. Temporal Locality
  34. 35. Non Uniform Distribution
  35. 36. Non Uniform Distribution top 4 pages account for >50% of total hits top 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
  36. 37. Cache limitations <ul><li>Amdahl' Law </li><ul><li>If the thing you’re caching is not your bottleneck, it won’t matter </li></ul></ul><ul><li>Memory </li><ul><li>cache uses memory which your app might need </li></ul></ul><ul><li>Concurrency </li><ul><li>access to cache can be a bottleneck </li></ul></ul>
  37. 38. Reduce LAtency
  38. 39. EhCache <ul><li>First created in 2003 by Greg Luck </li></ul><ul><li>Most widely used Java cache </li></ul><ul><li>Apache 2.0 licence </li></ul><ul><li>JSR 107 Java cach implementation </li></ul>
  39. 40. EhCache Architecture
  40. 41. Hibernate 2 nd Level Cache
  41. 42. Using Terracotta <ul><li>EhCache 1.7.0 can be as drop in replacement </li></ul><ul><li>Side effect on a single node, keeping state </li></ul><ul><li>Monitoring and profiling capabilities </li></ul><ul><li>Distributed transparently </li></ul>
  42. 43. Using Terracotta
  43. 44. Enhancement to Hibernate <ul><li>More efficient in-memory and total count eviction (3.1.1) </li></ul><ul><li>Better visibility of memory conditions </li></ul><ul><li>Improved Query Caching </li></ul><ul><li>Improved performance of core Terracotta (lock manager and memory manager) </li></ul>

×