Exploring Terracotta

2,141 views
2,041 views

Published on

How Terracotta enables scaled Spring/Hibernate applications. Presented at Chicago JUG in March 2009 by Alex Miller (http://tech.puredanger.com / @puredanger)

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
2,141
On SlideShare
0
From Embeds
0
Number of Embeds
54
Actions
Shares
0
Downloads
84
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Exploring Terracotta

  1. 1. Exploring Terracotta Alex Miller (@puredanger)
  2. 2. Agenda • Architecture and scale • Examinator reference application • What do people use it for? • How does it work? • Terracotta 3.0
  3. 3. Applications in Three Tiers Client Server Database
  4. 4. How do we scale? Client Client Client Server Server Server Database
  5. 5. But what about failover?
  6. 6. Option 1: Servers share state Client Client Client Server Server Server Database
  7. 7. How? • RMI • JMS • Custom (JGroups, etc)
  8. 8. Option 2: Database (“stateless”) Client Client Client Server Server Server Database
  9. 9. Stateless == “State in the database” • Database load • Serialization to and from the database • Network bandwidth • Object / relational mapping due to impedance mismatch
  10. 10. Option 3: Terracotta! Client Client Client Server Server Server Terracotta Terracotta Terracotta Terracotta Terracotta Database Server Server Instance Instance
  11. 11. Why is this better? • Hub and spoke vs peer to peer • Avoid object / relational translation • Avoid serialization • Reduce database overload • Programming model you already know • Focus on your app, not scalability and high availability
  12. 12. Agenda • Architecture and scale • Examinator reference application • What do people use it for? • How does it work? • Terracotta 3.0
  13. 13. Examinator • Terracotta reference web application • Online exams • “Session” use case • http://reference.terracotta.org
  14. 14. Examinator stack • Spring-based stack • MVC View • Web Flow Spring Web Flow Model Spring MVC • Security Sitemesh Controller • Transactions Spring Security • Open source Service Freemarker • Tomcat / Jetty DAO • Hibernate / JPA JPA Hibernate Domain • Site Mesh • Freemarker
  15. 15. What state should go in Terracotta? Appropriateness Memory Terracotta Database Data Lifetime
  16. 16. Examinator Terracotta Usage • User registration codes • Password reset codes • Exam cache • Session clustering • Spring security (via session) • Spring web flow (via session) • Exam in progress session - answers, choice ordering, marked to review
  17. 17. Demo
  18. 18. Agenda • Architecture and scale • Examinator reference application • What do people use it for? • How does it work? • Terracotta 3.0
  19. 19. Business Use Cases • Distributed cache • Clustered HTTP sessions • Batch processing • Grid • Messaging and events
  20. 20. Terracotta Elements • Replicated sessions • Async processor • Cache evictor • ConcurrentStringMap • Queues • Master-worker • TC Cache
  21. 21. Who Uses It? • e-Commerce • Online gaming • Financial services • Travel & leisure • Social networking
  22. 22. Agenda • Architecture and scale • Examinator reference application • What do people use it for? • How does it work? • Terracotta 3.0
  23. 23. Core Concepts • Roots • Instrumented Classes • Locks • Integration Modules
  24. 24. Clustered Heap App App app = new App(); app.run();
  25. 25. Clustered Heap App EmployeeManager employeeMgr = new EmployeeManager(); Employee Manager Object lock Object lock = new Object(); Map<String,Employee> = new HashMap<String,Employee>(); HashMap employees
  26. 26. Clustered Heap App Employee quot;U99411quot; Manager Object lock Employee.ACT IVE == 1 Employee quot;Gandalfquot; HashMap employees Employee employee = new Employee( “U99411”, “Gandalf”, Employee.ACTIVE);
  27. 27. Clustered Heap App employeeMgr.addEmployee(employee); Employee quot;U99411quot; Manager Object lock Employee.ACT IVE == 1 quot;U99411quot; Employee quot;Gandalfquot; HashMap employees synchronized(lock) { employees.put(e.getId(), e); }
  28. 28. Clustered Heap App Employee quot;U99411quot; Manager Object lock Employee.ACT IVE == 1 quot;U99411quot; Employee quot;Gandalfquot; HashMap employees quot;U23526quot; Employee quot;U23526quot; Employee.ACT IVE = 1 quot;U99411quot;
  29. 29. Let’s look at how to do that...
  30. 30. Agenda • Architecture and scale • Examinator reference application • What do people use it for? • How does it work? • Terracotta 3.0
  31. 31. Terracotta 3.0 • Server Array Striping - server scalability • Operations Center / Developer Console - new dashboard, DGC stats • Cluster events API - topology, data locality • Application groups - sharing data across heterogeneous applications • Platform support - Oracle WebLogic 10.2, 10.3 and RHEL 5.0
  32. 32. Thanks! • Terracotta Open Source JVM clustering: • http://www.terracotta.org • Apress: “The Definitive Guide to Terracotta” • by Ari Zilka, Alex Miller, Geert Bevin, Jonas Boner, Orion Letizi, Taylor Gautier • Alex Miller • @puredanger • http://tech.puredanger.com

×