infinispan , transactional key- value datagrid and nosql database
DESCRIPTION
Infinispan , transactional key- value DataGrid and NoSQL database. 11. April 2013 Alexander Petrov. Alexander Petrov. Sr. Consultant at Inmeta Consulting Current project: Skattetaten Grid POC Previous projects involving grid technologies: - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Infinispan , transactional key- value DataGrid and NoSQL database](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c57550346895dca58e1/html5/thumbnails/1.jpg)
Infinispan, transactional key-value DataGrid and NoSQL database11. April 2013 Alexander Petrov
![Page 2: Infinispan , transactional key- value DataGrid and NoSQL database](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c57550346895dca58e1/html5/thumbnails/2.jpg)
Alexander Petrov
• Sr. Consultant at Inmeta Consulting
• Current project: Skattetaten Grid POC
• Previous projects involving grid technologies:• Mattilsynet food authority system.• FrameSolution BPM framework used in Lovisa National Court
Authority(Norway), Mattilsynet Food Authority
• Other noteworthy projects• Coca Cola Basis ERP system – Coca Cola Bottler factories• mPower Mobilitec 300 million subscribers worldwide, and delivers over
500,000 pieces of content every day.
![Page 3: Infinispan , transactional key- value DataGrid and NoSQL database](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c57550346895dca58e1/html5/thumbnails/3.jpg)
Usage scenarios
• Big data, Databases are slow. Memory is FAST!• Provides huge computing power.• Tax calculation • Financial organizations• Government organizations use it for communication and
data sharing between the different departments.• Scientific computations• MMORPG games
![Page 4: Infinispan , transactional key- value DataGrid and NoSQL database](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c57550346895dca58e1/html5/thumbnails/4.jpg)
Agenda
• General terminology relevant to Distributed Caching
• Challenges related to introducing distributed caching to existing system
• Metrics and tuning
![Page 5: Infinispan , transactional key- value DataGrid and NoSQL database](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c57550346895dca58e1/html5/thumbnails/5.jpg)
Distributed Caching - Concepts
• Cache JSR – 107• Java Data Grid JSR - 347• In memory Data Grid• Cluster• Distribution• Node – a member of a cluster• Transaction awareness• Colocation• Map / Reduce• Consistency
![Page 6: Infinispan , transactional key- value DataGrid and NoSQL database](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c57550346895dca58e1/html5/thumbnails/6.jpg)
Real World Use Case
![Page 7: Infinispan , transactional key- value DataGrid and NoSQL database](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c57550346895dca58e1/html5/thumbnails/7.jpg)
Typical J2EE backend
![Page 8: Infinispan , transactional key- value DataGrid and NoSQL database](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c57550346895dca58e1/html5/thumbnails/8.jpg)
Data access
• Transaction scope• Locking\deadlocking• Flushing policies• Mixing the technologystack.• Performance
![Page 9: Infinispan , transactional key- value DataGrid and NoSQL database](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c57550346895dca58e1/html5/thumbnails/9.jpg)
Legacy Cache
![Page 10: Infinispan , transactional key- value DataGrid and NoSQL database](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c57550346895dca58e1/html5/thumbnails/10.jpg)
Our end goal
• Wow we did it!
![Page 11: Infinispan , transactional key- value DataGrid and NoSQL database](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c57550346895dca58e1/html5/thumbnails/11.jpg)
Summary
• Our Custom cache is super fast, but its cache hit ratio is rather low.
• Our custom cache has a tendency of getting dirty as the updates to the shared data can not be propagated. At the same time the separation of the data regions is not full.
• Marshaling is a rather slow and heavy process.
• We are facing a technological cocktail and we need to keep integrity.
![Page 12: Infinispan , transactional key- value DataGrid and NoSQL database](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c57550346895dca58e1/html5/thumbnails/12.jpg)
Replication
• Write through• Write Behind• Replication Queue
![Page 13: Infinispan , transactional key- value DataGrid and NoSQL database](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c57550346895dca58e1/html5/thumbnails/13.jpg)
Invalidation
![Page 14: Infinispan , transactional key- value DataGrid and NoSQL database](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c57550346895dca58e1/html5/thumbnails/14.jpg)
Distribution
![Page 15: Infinispan , transactional key- value DataGrid and NoSQL database](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c57550346895dca58e1/html5/thumbnails/15.jpg)
More terminology
• Eviction• Least Recently Used• First In First Out• LIRS• Custom
• Expiration
• Invalidation
![Page 16: Infinispan , transactional key- value DataGrid and NoSQL database](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c57550346895dca58e1/html5/thumbnails/16.jpg)
Caching topologies – Mirrored Cache
• Ref. Data vs Transactional• Reference data: Good.Max 30000 reads/sec 1k size• Transactional data: Good.Max 25000 writes/sec 1k size
.
![Page 17: Infinispan , transactional key- value DataGrid and NoSQL database](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c57550346895dca58e1/html5/thumbnails/17.jpg)
Caching topologies – Replica Cache
• Reference data: Good.30000 reads/sec per server.Grow linearly by adding servers.
• Transactional data: Not sogood. Max 20000writes/second. Drops if you add 3rd server to2500.
![Page 18: Infinispan , transactional key- value DataGrid and NoSQL database](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c57550346895dca58e1/html5/thumbnails/18.jpg)
Caching topologies – Partitioned Cache
• Ref. Data vs Transactional• Reference data: Good.Max 30000 reads/sec 1k size• Transactional data: Good.Max 25000 writes/sec 1k size
![Page 19: Infinispan , transactional key- value DataGrid and NoSQL database](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c57550346895dca58e1/html5/thumbnails/19.jpg)
Caching topologies - Partitioned Replica
• Reference data(1kb):Good. 30000 reads/sec per server. Grow linearly by adding servers.
• Transactional data(1kb):Good. 20000 writes/sec per server.Grow linearly by adding servers.
![Page 20: Infinispan , transactional key- value DataGrid and NoSQL database](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c57550346895dca58e1/html5/thumbnails/20.jpg)
How to define our topology
• What is the size of our cluster? Reads vs. Writes• Communication inside our grid
• UDP,TCP• Synchronous vs. Asynchronous.• What about the transaction isolation?
• Repeatable Reads vs. Read Committed• What is the nature of our application?• Read intensive data
• CMS systems • Write Intensive Data
• Document Management System
![Page 21: Infinispan , transactional key- value DataGrid and NoSQL database](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c57550346895dca58e1/html5/thumbnails/21.jpg)
Level 1 Cache / Near Cache
• Level1 cache is Supported only for Distribution mode• Level 1 cache mighthave a performance Impact in certain systems
![Page 22: Infinispan , transactional key- value DataGrid and NoSQL database](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c57550346895dca58e1/html5/thumbnails/22.jpg)
Cache stores and loaders
• Passivation
• Activation
• Hibernate
![Page 23: Infinispan , transactional key- value DataGrid and NoSQL database](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c57550346895dca58e1/html5/thumbnails/23.jpg)
Transactions, Isolation and Locking
• Long running transactions need to be avoided.
• What is a long running transaction? How long is actually long.
• Read Committed vs Repeatable Reads
![Page 24: Infinispan , transactional key- value DataGrid and NoSQL database](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c57550346895dca58e1/html5/thumbnails/24.jpg)
Classic Deadlock situation
begin Update(A) Update(B) Update(C) Update(B)
Begin Update(C) Update(B) Release(A) Lock(A)
TX1 (Wants update A,B,C)
TX2 (Wants to update C,B,A)
C is locked by TX2
A is locked by TX1
![Page 25: Infinispan , transactional key- value DataGrid and NoSQL database](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c57550346895dca58e1/html5/thumbnails/25.jpg)
Repeatable Read
begin get(k) - - Get(k)
Begin Get(k) put(k, v2) commit
What is returned??
TX1
TX2
![Page 26: Infinispan , transactional key- value DataGrid and NoSQL database](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c57550346895dca58e1/html5/thumbnails/26.jpg)
Cache statistics
![Page 27: Infinispan , transactional key- value DataGrid and NoSQL database](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c57550346895dca58e1/html5/thumbnails/27.jpg)
Remoting statistics
![Page 28: Infinispan , transactional key- value DataGrid and NoSQL database](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c57550346895dca58e1/html5/thumbnails/28.jpg)
Locking statistics
![Page 29: Infinispan , transactional key- value DataGrid and NoSQL database](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c57550346895dca58e1/html5/thumbnails/29.jpg)
Marshaling data
• Java serialization
• Java externalization
• Impact on performance
• Generic domain.
![Page 30: Infinispan , transactional key- value DataGrid and NoSQL database](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c57550346895dca58e1/html5/thumbnails/30.jpg)
Real World Use Case
![Page 31: Infinispan , transactional key- value DataGrid and NoSQL database](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c57550346895dca58e1/html5/thumbnails/31.jpg)
Data access
• Transaction scope• Locking\deadlocking• Flushing policies• Mixing the technologystack.• Performance
![Page 32: Infinispan , transactional key- value DataGrid and NoSQL database](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c57550346895dca58e1/html5/thumbnails/32.jpg)
Our end goal
• Wow we did it!
![Page 33: Infinispan , transactional key- value DataGrid and NoSQL database](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c57550346895dca58e1/html5/thumbnails/33.jpg)
The End
• Thank you for your attention
![Page 34: Infinispan , transactional key- value DataGrid and NoSQL database](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c57550346895dca58e1/html5/thumbnails/34.jpg)
Used sources
http://www.alachisoft.com/ncache/caching-topology.htmlhttp://www.infoq.com/news/2011/10/java-data-gridhttps://github.com/datagrids/spec/wikihttp://www.jboss.org/infinispan/documentationhttp://code.google.com/p/thrift-protobuf-compare/wiki/Benchmarking