Sunteți pe pagina 1din 14

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?
• Scalability • The
Performance vs. scalability
concepts of performance
and scalability are often
• fail-over interwoven, but they're
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 • You can think of vertical
distributes load across clustering as "scaling up,"
multiple machines; you can meaning that load is
think of it as "scaling out." 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 • Bytecode instrumentation
instrumentation (BCI) in the • Bytecode is the format Java
Terracotta client to identify is compiled to and that the
the exact properties within JVM knows how to interpret.
stateful objects that change The JVM provides "hooks"
and then replicate only those through which a process can
properties across the cluster. examine and modify bytecode
• Did you start seeing the of objects before they are
advantage? 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 • Network-Attached Memory is
(NAM) analogically similar to
• As NAS is transparent under Network-Attached Storage
a filesystem (NAS). Both have a server
component. Both have a client
• NAM is transparent under the layer that works
Java language. Objects in a transparently underneath
multi-JVM application are system I/O. And both have a
created, manipulated, and network protocol to move
kept consistent in NAM as data between the clients and
files are in NAS. 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
<tc:tc-config xmlns:tc="http://www.terracotta.org/config">
<application>
<dso>
<roots>
<root>
<field-name>HelloClusteredWorld.counter</field-name>
</root>
</roots>
</dso>
</application>
</tc:tc-config>

S-ar putea să vă placă și