Stateful Applications in a Stateless World

                                  How to write stateful web
                  ...
Open Source Clustering for Java


  The Innocent Web Application

                   Within every innocent web applicatio...
Open Source Clustering for Java


  The State Monster




Copyright Terracotta 2007
Open Source Clustering for Java


  The State Monster




                              Conversational state across reque...
Open Source Clustering for Java


  The Stateless Convention

                   Push state out of your application serve...
Open Source Clustering for Java


  The Stateless Convention: Push State to the Database




Copyright Terracotta 2007
Open Source Clustering for Java


  The Stateless Convention: Push State to the Database




                             ...
Open Source Clustering for Java


  The Stateless Convention: Push State to Peers




Copyright Terracotta 2007
Open Source Clustering for Java


  The Stateless Convention: Push State to Peers




            Push state everywhere g...
Open Source Clustering for Java


  The Stateless Convention: Push State to Client

                   Highly scalable fo...
Open Source Clustering for Java


  Stateless Convention: The Real Problem



                 quot;With a little ingenuit...
Open Source Clustering for Java


  The Stateless Convention: Eats Developer Brains




Copyright Terracotta 2007
Open Source Clustering for Java


  The Stateless Convention: Eats Developer Brains

                              Pushin...
Open Source Clustering for Java


  Changing the Assumptions: JVM-level Clustering




Copyright Terracotta 2007
Open Source Clustering for Java


  Performance + Reliability + Simplicity

                   10X throughput over conven...
Open Source Clustering for Java


             Demo: Session Clustering




Copyright Terracotta 2007
Open Source Clustering for Java


  Demo: CoordinationWithQueues (from our Apress book)




Copyright Terracotta 2007
Open Source Clustering for Java


  QueueReader

            private static final class QueueReader implements Runnable {	...
Open Source Clustering for Java


  Queue Writer

            //...	
            private void run() {	
               whil...
Open Source Clustering for Java


  CoordinationWithQueues Config File
...	
         <dso>	
           <instrumented-class...
Case Studies




Copyright Terracotta 2007
Open Source Clustering for Java


  Fast, Simple, Scalable




    “            [T]hanks to Terracotta and your post about...
Open Source Clustering for Java


  Large Publisher Gets Caught Down the Path with Oracle




                            ...
Open Source Clustering for Java


  Breaking the Pattern without Leaving “Load-Balanced” World
               • $1.5 Milli...
Open Source Clustering for Java


  Coming Soon: Examinator Reference Application


        Online test proctoring applic...
Open Source Clustering for Java


  Gnip—Internet Data Aggregation and Delivery Service




Copyright Terracotta 2007
Open Source Clustering for Java


  Gnip—Internet Data Aggregation and Delivery Service




Copyright Terracotta 2007
Open Source Clustering for Java


  Gnip—Internet Data Aggregation and Delivery Service


                                ...
Open Source Clustering for Java


  Gnip—Internet Data Aggregation and Delivery Service


                                ...
Open Source Clustering for Java


  Gnip—Internet Data Aggregation and Delivery Service

                                 ...
Open Source Clustering for Java


  Common Use Patterns




Copyright Terracotta 2007
Open Source Clustering for Java


  Community Resources

                   http://www.terracotta.org/

                 ...
Upcoming SlideShare
Loading in …5
×

Terracotta Java Scalability - Stateless Versus Stateful Apps

2,741 views

Published on

Orion Letizi's presentation of Terracotta to the Denver Open Source Users Group (DOSUG)

Published in: Education
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
2,741
On SlideShare
0
From Embeds
0
Number of Embeds
6
Actions
Shares
0
Downloads
80
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Terracotta Java Scalability - Stateless Versus Stateful Apps

  1. 1. Stateful Applications in a Stateless World How to write stateful web applications that scale like stateless ones Copyright Terracotta 2007
  2. 2. Open Source Clustering for Java The Innocent Web Application   Within every innocent web application lies a sleeping monster   There comes a time when every successful web application outgrows its single machine architecture   Whether for high-availability or scalability or both, the adult web application must live on more than one application server   That's when the latent beast strikes... Copyright Terracotta 2007
  3. 3. Open Source Clustering for Java The State Monster Copyright Terracotta 2007
  4. 4. Open Source Clustering for Java The State Monster   Conversational state across requests   Application state: caches, indexes, etc. Copyright Terracotta 2007
  5. 5. Open Source Clustering for Java The Stateless Convention   Push state out of your application server to achieve quot;statelessnessquot;   Application server is for computation only   Any application server can handle any request   quot;...with a little ingenuity, [we have created a] very fast application that is much more resilient to application restartsquot; Copyright Terracotta 2007
  6. 6. Open Source Clustering for Java The Stateless Convention: Push State to the Database Copyright Terracotta 2007
  7. 7. Open Source Clustering for Java The Stateless Convention: Push State to the Database   DB becomes a bottleneck   Not optimized for object data Copyright Terracotta 2007
  8. 8. Open Source Clustering for Java The Stateless Convention: Push State to Peers Copyright Terracotta 2007
  9. 9. Open Source Clustering for Java The Stateless Convention: Push State to Peers   Push state everywhere gives HA, but doesn't scale   Push conversational state to buddy can't survive buddy pair death or full cluster restart. Doesn't help for application state. Copyright Terracotta 2007
  10. 10. Open Source Clustering for Java The Stateless Convention: Push State to Client   Highly scalable for conversation state UNLESS state is large   Doesn't help with application state Copyright Terracotta 2007
  11. 11. Open Source Clustering for Java Stateless Convention: The Real Problem quot;With a little ingenuity,quot; many of these problems can be solved on a per-application basis. The real problem with the quot;statelessquot; convention is... Copyright Terracotta 2007
  12. 12. Open Source Clustering for Java The Stateless Convention: Eats Developer Brains Copyright Terracotta 2007
  13. 13. Open Source Clustering for Java The Stateless Convention: Eats Developer Brains   Pushing state out of app server doesn't get rid of state. There is no such thing as quot;statelessquot;   Serialization/externalization:   Full-object graph serialization   breaks object identity   corrupts data and programming model   quot;with a little ingenuity...quot;-- seems fun/easy to try, but ends up taking over the development effort Copyright Terracotta 2007
  14. 14. Open Source Clustering for Java Changing the Assumptions: JVM-level Clustering Copyright Terracotta 2007
  15. 15. Open Source Clustering for Java Performance + Reliability + Simplicity   10X throughput over conventional APIs   All Reads from Cache (implicit locality)   All Writes are Deltas-only   Statistics and Heuristics (greedy locks)   Scale out the Terracotta Server   Simple form of Active / active available today   V1.0 GA this year   Looks like Java to me (code like your mom used to make) Normal access patterns: no check-out before view and check-in on commit   Code and test at a unit level without infrastructure intruding on app logic   Threads on multiple JVMs look like threads on the same JVM   PUFIELD, GETFIELD, synchronized(), wait(), notify() work as expected   Copyright Terracotta 2007
  16. 16. Open Source Clustering for Java Demo: Session Clustering Copyright Terracotta 2007
  17. 17. Open Source Clustering for Java Demo: CoordinationWithQueues (from our Apress book) Copyright Terracotta 2007
  18. 18. Open Source Clustering for Java QueueReader private static final class QueueReader implements Runnable { private final NamedQueue myQueue; public QueueReader(NamedQueue queue) { this.myQueue = queue; } public void run() { while (true) { try { System.out.println(new Date() + quot;: message from the quot; + myQueue.getName() + quot; queue: quot; + myQueue.take()); } catch (InterruptedException e) { // A real application would do something interesting with this // exception. e.printStackTrace(); } } } Copyright Terracotta 2007
  19. 19. Open Source Clustering for Java Queue Writer //... private void run() { while (true) { try { String mood = MOODS[random.nextInt(MOODS.length)]; myQueue.add(myColor + quot; says, quot;I'm feeling quot; + mood + quot;.quot;quot;); Thread.sleep(1000); } catch (InterruptedException e) { // A real application would do something with this exception e.printStackTrace(); } } } // ... Copyright Terracotta 2007
  20. 20. Open Source Clustering for Java CoordinationWithQueues Config File ... <dso> <instrumented-classes> <include> <class-expression> org.terracotta.book.coordination.queues.CoordinationWithQueues </class-expression> </include> <include> <class-expression> org.terracotta.book.coordination.queues.CoordinationWithQueues$NamedQueue </class-expression> </include> </instrumented-classes> <roots> <root> <field-name>org.terracotta.book.coordination.queues.CoordinationWithQueues.QUEUES</field-name> </root> <root> <field-name> org.terracotta.book.coordination.queues.CoordinationWithQueues.sharedCounter</field-name> </root> </roots> <locks> <autolock> <method-expression> void org.terracotta.book.coordination.queues.CoordinationWithQueues.main(java.lang.String[]) </method-expression> <lock-level>write</lock-level> </autolock> </locks> </dso> ... Copyright Terracotta 2007
  21. 21. Case Studies Copyright Terracotta 2007
  22. 22. Open Source Clustering for Java Fast, Simple, Scalable “ [T]hanks to Terracotta and your post about the message bus you did we have stripped all J2EE out of our architecture making it much simpler for service developers, much faster, and much more scalable. What has us so excited about this approach is exactly what you said about developer productivity - that is Right On! --http://blog.markturansky.com/archives/77 Copyright Terracotta 2007
  23. 23. Open Source Clustering for Java Large Publisher Gets Caught Down the Path with Oracle Scaling Out or Up? Copyright Terracotta 2007
  24. 24. Open Source Clustering for Java Breaking the Pattern without Leaving “Load-Balanced” World • $1.5 Million DB & HW savings • Doubled business • More than halved database load Copyright Terracotta 2007
  25. 25. Open Source Clustering for Java Coming Soon: Examinator Reference Application   Online test proctoring application   Fully tested & tuned   Popular stack   Example architecture &   Spring MVC, Webflow components   Sitemesh   Example project layout and tools   Freemarker integration (build/test/debug/   Spring Security deploy)   Tomcat/Jetty   Fully documented best practices   JPA and recommended SDLC   Hibernate processes   MySQL   Maven   Junit Copyright Terracotta 2007
  26. 26. Open Source Clustering for Java Gnip—Internet Data Aggregation and Delivery Service Copyright Terracotta 2007
  27. 27. Open Source Clustering for Java Gnip—Internet Data Aggregation and Delivery Service Copyright Terracotta 2007
  28. 28. Open Source Clustering for Java Gnip—Internet Data Aggregation and Delivery Service Initial Architechture   JMS Queuing   Backing Database JMS JMS Liabilities   Many moving parts   Many technologies DB   Increased developer specialization   Lower core-competency density Copyright Terracotta 2007
  29. 29. Open Source Clustering for Java Gnip—Internet Data Aggregation and Delivery Service Terracotta Architecture   Natural, in-memory data structures EC2 Node 1: TC Client EC2 Node 2: TC Client   Durable, TC-backed objects Periodic EC2 Node 3: TC Server snapshot of Terracotta object store for backup S3 Backup Copyright Terracotta 2007
  30. 30. Open Source Clustering for Java Gnip—Internet Data Aggregation and Delivery Service Performance   50,000 messages/second   3-4 EC2 nodes EC2 Node 1: TC Client EC2 Node 2: TC Client Benefits   Fewer technologies, increased core competency Periodic   App built w/ simple Java EC2 Node 3: TC Server snapshot of constructs Terracotta object store for   Clustering and redundancy “just backup works” S3 Backup   Excellent monitoring/debugging tools   “I can’t believe you give them away for free…” Copyright Terracotta 2007
  31. 31. Open Source Clustering for Java Common Use Patterns Copyright Terracotta 2007
  32. 32. Open Source Clustering for Java Community Resources   http://www.terracotta.org/   http://forums.terracotta.org/   Mailing lists:   tc-dev@terracotta.org   tc-users@terracotta.org   IRC:   #terracotta channel on freenode   Subversion   http://svn.terracotta.org/svn/tc   http://svn.terracotta.org/svn/forge Copyright Terracotta 2007

×