Terracotta Chiradip Mandal
What does terracotta do? • It makes boring subject clustering interesting.
Context • We develop application – don’t think about load in the beginning. Most of the times we don’t know about the load going to be. • We try to adjust application with new clustering needs. • Expensive hardware clustering – not functionally relevant most of the times. • Makeshift software clustering.
Concept - terracotta • Terracotta is an open source solution for enterprise Java Clustering that boasts near linear scalability and 100 percent reliability. Terracotta supports standard HTTP session clustering in Apache Tomcat and Oracle Weblogic, as well as open source projects such as Struts, Spring, and Hibernate.
Why clustering? Performance vs. scalability • Scalability • The concepts of performance and scalability are often interwoven, but they're • fail-over distinct. Performance measures whether an application can respond to a request within its defined service-level agreement (SLA). Scalability measures how well an application can maintain its performance under increasing load.
H. vs. V. Clustering • Horizontal clustering distributes load across multiple machines; you can think of it as "scaling out."
• You can think of vertical clustering as "scaling up," meaning that load is distributed to multiple application server instances running on the same physical server. Vertical clustering can sometimes better utilize all of a server's resources than a single JVM instance.
Fail-Over • Makes outages transparent to users while maintaining their state within the application. • Requires a strategy for replicating a user's state to one or more secondary servers and then, if the first server goes down, redirecting all subsequent requests to the secondary server(s). Deciding how, when, and where to send the data are fundamental challenges to implementing this strategy effectively.
Serialization for clustering
• Detects the change(s) in an object and transmits the whole object to the clustered servers. • “All or nothing” serialization. • In portal scenario – stateful information (object) can be measured in MB. So just a true/false change in that also needs full de/serialization. • It hinders “linear” scalability. – rejected.
A lil bit of terracotta in the Serialization context •
•
Terracotta uses bytecode instrumentation (BCI) in the Terracotta client to identify the exact properties within stateful objects that change and then replicate only those properties across the cluster. Did you start seeing the advantage?
• •
•
Bytecode instrumentation Bytecode is the format Java is compiled to and that the JVM knows how to interpret. The JVM provides "hooks" through which a process can examine and modify bytecode of objects before they are returned to the application that is using them. Terracotta uses BCI to intercept changes made to objects so that it can identify those changes and send them to the Terracotta server.
Coming back to Terracotta • • •
Network Attached Memory (NAM) As NAS is transparent under a filesystem NAM is transparent under the Java language. Objects in a multi-JVM application are created, manipulated, and kept consistent in NAM as files are in NAS.
•
Network-Attached Memory is analogically similar to Network-Attached Storage (NAS). Both have a server component. Both have a client layer that works transparently underneath system I/O. And both have a network protocol to move data between the clients and server, caching data locally for fast read and write access. That is the end of similarity…
Terracotta Promises • Significantly Reduced Costs for Enterprise Java Applications • A Simple Straightforward Operations Model • Highly Available Enterprise Java Applications • Highly Scalabile Enterprise Java Applications • No Single Point of Failure • No Single Point of Bottleneck
Remember • Clustering makes sense only in shared state(s). If your application does not need a shared state – you really don’t need clustering. But you may still need simple fail-over.
Hello Clustered World • public class HelloClusteredWorld • { private static int counter; • public static void main(String[] args) • { • counter++; • System.out.println("Counter is: " + counter); • } • • }
Terracotta config file tc-config.xml
HelloClusteredWorld.counter