GR8Conf 2011: Grails Infinispanplugin, Tom Fuller

896 views
829 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
896
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
14
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

GR8Conf 2011: Grails Infinispanplugin, Tom Fuller

  1. 1. Introduction to theGrails Infinispan Plugin Tom Fuller Coherent Logic Limited
  2. 2. Overview• A story• Design principles• Code examples• Conclusion
  3. 3. Why all the stress? Application Server Application Server
  4. 4. Traffic spike = trouble Hits per minute100000 90000 80000700006000050000 Hits per minute40000300002000010000 0 01 02 03 04 05 06 07 08 09 10 11 12 13 30 40 43 45 50 10 : 10 : 10 : 10 : 10 : 10 : 10 : 10 : 10 : 10 : 10 : 10 : 10 : 10 : 10 : 10 : 10 : 10 :
  5. 5. (CC) griffithchris
  6. 6. (CC) Mr. Gunn
  7. 7. Refactor here, optimise there… Application Server Application Server
  8. 8. Again – a traffic spike = trouble Hits per minute14000012000010000080000 Hits per minute600004000020000 0 10:01 10:02 10:03 10:04 10:05 10:06 10:07 10:08 10:09 10:10 10:11 10:12 10:13 10:30 10:40 10:43 10:45 10:50 10:55
  9. 9. (CC) amboo who?
  10. 10. (CC) Stephi 2006
  11. 11. Just buy bigger servers Application Server Application Server
  12. 12. 0 50000 100000 150000 200000 25000010:0110:0210:0310:0410:0510:0610:0710:0810:0910:1010:1110:12 Hits per minute10:1310:3010:4010:4310:4510:5010:55 Traffic spike = trouble Hits per minute
  13. 13. (CC) fireflythegreat
  14. 14. (CC) Ray_from_LA
  15. 15. Replicate here, replicate there… Application Server Application Server Application Server
  16. 16. No surprise – a traffic spike = trouble Hits per minute400000350000300000250000200000 Hits per minute15000010000050000 0 01 03 05 07 09 11 13 40 45 55 05 10: 10: 10: 10: 10: 10: 10: 10: 10: 10: 11:
  17. 17. (CC) Tweek
  18. 18. Where we’re at:• Optimisation alone won’t solve this problem.• Neither will larger servers.• Scaling the application server and databases doesn’t work.
  19. 19. (CC) Mattastic!
  20. 20. A solution that works! Cache Cache Cache Application Server Cache Cache Cache Cache Cache Application Server
  21. 21. Infinispan• Based in part on code from JBoss Cache• Licensed under the LGPL• Is a distributed in-memory data grid• Has competition• As of May 2011 Infinispan is officially supported by Red Hat.
  22. 22. Traffic spike = not a problem! Hits per minute 600000 500000 400000 300000 Hits per minute 200000 100000 0 01 03 05 07 09 11 13 40 45 55 05 10: 10: 10: 10: 10: 10: 10: 10: 10: 10: 11:
  23. 23. Just grow the grid! Cache Cache Cache Cache Cache Cache Cache Application Server Cache Cache Cache Cache Cache Application Server Cache Cache* NOTE: Caveat with session clustering.
  24. 24. Design Principles of the Grails Infinispan Plugin(CC) El Bibliomata
  25. 25. We aim to help developers:Work with Grails and Groovy naturally.
  26. 26. We aim to help developers:Work with Grails and Groovy naturally.Avoid and diagnose problems quickly.
  27. 27. We aim to help developers:Work with Grails and Groovy naturally.Avoid and diagnose problems quickly.Save time.
  28. 28. Configuring Infinispan in Grailsdevelopment { infinispan = { register { cacheManager { named "matrixCacheManager" configured { externally { using "grails-app/conf/infinispan/infinispan-config.xml" } } caches "agentCache", “citiesCache" } queryHelper { named "agentQueryHelper" referencing "agentCache" properties queryHelperProperties classes infinispantestapp.Agent, infinispantestapp.SuperHero } } } }}
  29. 29. Configuring Infinispan in Grailsproduction { infinispan = { register { cacheManager { named "matrixCacheManager" configured { declaratively { using globalConfiguration using configuration } } caches "agentCache", "illinoisCitiesCache" } queryHelper { named "agentQueryHelper" referencing "agentCache" properties queryHelperProperties classes infinispantestapp.Agent, infinispantestapp.SuperHero } } } }}
  30. 30. Use the cacheLoadAgentCacheController { def agentCache def index = { for (int ctr in 1..1000) { agentCache.put ( "person id $ctr", new Agent (name:"Agent Smith", weapon:"gun") ) } }}
  31. 31. Execute a transactional operationcache.transactionally { cache.put(someKey, someValue); cache.remove(someOtherKey);}
  32. 32. Query and iterate over the resultsdef term = new Term (WEAPON, GUN)def termQuery = new TermQuery (term)def results = agentCache.query (queryHelper, Agent, termQuery)results.each { log.info ("it: $it")}
  33. 33. Add closures as listenersagentCache.onCacheEntryCreated { log.info ("Cache entry created: $it")}
  34. 34. Food for Thought• Infinispan 5.0 is currently under development and will deliver fork/join and map/reduce implementations.• Infinispan can help reduce costs for any data source.• Infinispan can be very useful in the cloud and service-oriented architectures (SOA).
  35. 35. A p p lic a tio n A p p lic a tio n S e rv e r S e rv e r C u s to m e r I n fo r m a t io n O rd e r h is t o r y O rd e r h is t o r yA p p lic a tio n A p p lic a tio n A p p lic a tio n Paym ent S e rv e r O rd e r S e rv e r S e rv e r p r o c e s s in g , p r o c e s s in g S h ip p in gA p p lic a tio n S e rv e r P ro d u ct in fo r m a t io n P a rtn e r & p ro d u ct A n a ly t ic s in fo r m a t io n P a rtn e r r e g is t r a t io n A p p lic a tio n A p p lic a tio n A p p lic a tio n A p p lic a tio n S e rv e r S e rv e r S e rv e r S e rv e r
  36. 36. Conclusion• Three attempts that failed to deliver a solution that could cope with the load.• Design principles behind the Grails Infinispan Plugin.• Example code.• Further documentation is available at http://www.grails.org/plugin/infinispan
  37. 37. Any questions? Contact me Email:thomas.fuller@coherentlogic.com

×