a bit of algebra
play

A Bit of Algebra Massive Amounts of In-memory Key/Value Storage + - PowerPoint PPT Presentation

A Bit of Algebra Massive Amounts of In-memory Key/Value Storage + In-Memory Search + Java == NoSQL Killer? A bit of Algebra Massive Amounts of In-memory Key/Value Storage + In-Memory Search + Java == NoSQL Killer? Kunal Bhasin, Deputy CTO,


  1. A Bit of Algebra Massive Amounts of In-memory Key/Value Storage + In-Memory Search + Java == NoSQL Killer?

  2. A bit of Algebra Massive Amounts of In-memory Key/Value Storage + In-Memory Search + Java == NoSQL Killer? Kunal Bhasin, Deputy CTO, Terracotta 2

  3. What is NoSQL?  NoSQL = “Not only SQL”  Structured Data not stored in traditional RDBMS  E.g. Key-Value stores, Graph Databases, Document Databases  It really is “Not only RDB” = NoRDB  Key-Value stores – BigTable (disk) – Cassandra – Dynamo – BigTable 3

  4. Why NoSQL?  “One Size Fits All” is .. umm .. a little restrictive  Use the right tool for the job  Or the right strategy depending on business data – Not all data is equal – creation and consumption • Data Volume • Data access patterns • Consistency • Latency, Throughput • Scalability • Availability  Not meant to be “anti”-RDBMS Image Courtesy – Google Images Image URL - http://farm3.static.flickr.com/2523/4193330368_b22b644ddd.jpg http://farm4.static.flickr.com/3620/3402670280_5e8be9f09c.jpg 4

  5. What are we looking for?  Lots of data – > 1 TB to PBs  Performance – Low latency, high throughput access  Scalability and Availability  Flexibility in CAP tradeoffs – Consistency – eventual, strong, ACID – Availability – > 99.99 up time, Durability to failures – Automatic recovery on failures, real time alerts  Flexibility in data consumption – Analytics, Compute 5

  6. Algebra Lots of data + Performance + Scalability and Availability + Flexible CAP tradeoffs + Flexible data consumption = NoSQL or NoRDB 6

  7. What is Ehcache?  Simple API honed by 100,000’s of production deployments Cache cache = manager.getCache("sampleCache1"); � Element element = new Element("key1", "value1"); � cache.put(element); �  Default cache for popular frameworks Hibernate, MyBatis, Open JPA • Spring (Annotations), Google Annotations • Grails • JRuby • Liferay • Cold Fusion • 7

  8. Simple Get/Put API Sample Code: public Object testCache(String key) throws Exception { CacheManager cacheManager = new CacheManager( “<path to my ehcache.xml>”); Cache myCache = cacheManager.getCache("MyCache"); Object value; Element element = myCache.get(key); if (element == null) { value = "go get it from somewhere like DB or service, etc"; myCache.put(new Element(key, value)); } else { value = (Object) element.getValue(); } return value; } 8

  9. Simple and flexible configuration <ehcache> <defaultCache maxElementsInMemory="10000" eternal="false" timeToLiveSeconds="120” memoryStoreEvictionPolicy= "LFU” /> <cache name=”WheelsCache" maxElementsInMemory="10000" timeToIdleSeconds="300” memoryStoreEvictionPolicy= "LFU” /> <cache name=”CarCache" maxElementsInMemory="10000" timeToIdleSeconds="300” memoryStoreEvictionPolicy= "LFU" /> </ehcache> 9

  10. Efficient implementation – Highly concurrent and scalable – Complements multi-threaded app servers – Max utilization of hardware, scales to multi-core CPUs K V Key 1 Value 1 Key 2 Value 2 Key 3 Value 3 10

  11. Some more features  Pluggable eviction policy  Large caches, GC free  Async write-behind  Bulk loader API’s  JTA support  Management console  Third-party monitoring  WAN replication integration 11

  12. Lots of Data + Performance Ehcache BigMemory 12

  13. Why BigMemory? Java has not kept up with Hardware (because of GC) Base Case Big Heap Stacked 4 GB GC Pause 4 GB Times 4 GB 32 GB 4 GB Dev / Ops Complexity 4 GB 4 GB 4 GB 4 GB 13

  14. BigMemory: Scale Up GC Free  Dramatically increased usable memory per JVM  >64GB/JVM Today With BigMemory Available Memory  10x JVM density 64GB  Predictable latency  Easier SLAs  No GC pauses  No tuning Max Usable  Pure Java Memory 2GB 14

  15. BigMemory: Scale Up GC Free BigMemory GC • Transparent to Ehcache users, • Complex, dynamic reference based • Simple <Key,Value> store with no object store cross-references, • Costly (walk the entire object graph) • Uses RAM directly to find “unused/unreachable” objects • Clean interfaces (get, put, remove) for and reclaim memory CRUD operations Striped Memory Manager Young Tenured Chunk 1 Chunk 2 Chunk 3 Chunk 4 Buffer Manager Direct Byte Buffers 15

  16. BigMemory: Scale Up GC Free BigMemory GC New objects are stored on New objects created in Young RAM, away from java heap Generation of heap Striped Memory Manager Young Tenured Chunk 1 Chunk 2 Chunk 3 Chunk 4 Buffer Manager Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value K,V Key,Value Direct Byte Buffers 16

  17. BigMemory: Scale Up GC Free GC BigMemory Young generation full causes Hot objects are kept in BigMemory Young GC, costly but not as bad based on access pattern Striped Memory Manager Young Tenured Key,Value Chunk 1 Chunk 2 Chunk 3 Chunk 4 Key,Value Buffer Manager Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value K,V Key,Value Direct Byte Buffers 17

  18. BigMemory: Scale Up GC Free GC BigMemory Parallel Collector: Medium to long Objects removed on remove(key), lived objects end up in Tenured TimeToLive, TimeToIdle, frequency of Space access; no need to walk the graph Striped Memory Manager Young Tenured Chunk 1 Chunk 2 Chunk 3 Chunk 4 Buffer Manager Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value K,V Direct Byte Buffers 18

  19. BigMemory: Scale Up GC Free GC BigMemory Parallel Collector: Long (stop the Highly concurrent and Intelligent world) pauses proportional to size of algorithms to seek “best fit” free the heap and amount of “collectable” memory chunks: No pauses objects Striped Memory Manager Striped Memory Manager Young Tenured Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value Chunk 1 Chunk 1 Chunk 2 Chunk 2 Chunk 3 Chunk 3 Chunk 4 Chunk 4 Buffer Manager Buffer Manager Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value K,V K,V Key,Value Key,Value Key,Value K,V Key,Value Key,Value Key,Value K,V Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value K,V K,V Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value K,V Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value K,V K,V Direct Byte Buffers Direct Byte Buffers 19

  20. BigMemory: Scale Up GC Free GC BigMemory CMS Fragmentation: Not enough Striped Compaction = contiguous space to copy from No Fragmentation + Good young to tenured, long pauses (stop Performance the world) to run compaction cycles Striped Memory Manager Striped Memory Manager Young Tenured Key,Value Key,Value Key,Value Key,Value Key,Value Chunk 1 Chunk 1 Chunk 2 Chunk 2 Chunk 3 Chunk 3 Chunk 4 Chunk 4 Buffer Manager Buffer Manager Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value Key,Value K,V K,V Direct Byte Buffers Direct Byte Buffers Not enough contiguous space = Fragmentation = Full GC 20

  21. BigMemory - Tiered Storage 21

  22. Ehcache with BigMemory App Server • Up to 350 GB tested JVM JVM JVM JVM • < 1 second GC pauses JVM JVM EHCACHE EHCACHE • Standalone or Distributed EHCACHE EHCACHE EHCACHE EHCACHE • > 1 TB with Terracotta Server Array BigMemory 22

  23. Sample ehcache.xml for standalone Flexibility – add BigMem Selectively < ehcache> <defaultCache maxElementsInMemory="10000" eternal="false" timeToLiveSeconds="120” memoryStoreEvictionPolicy= "LFU” /> <cache name=”WheelsCache" maxElementsInMemory="10000" timeToIdleSeconds="300” memoryStoreEvictionPolicy= "LFU” � � overflowToOffHeap="true ” � maxMemoryOffHeap=”30G" /> <cache name=”CarCache" maxElementsInMemory="10000" timeToIdleSeconds="300” memoryStoreEvictionPolicy= "LFU" /> </ehcache> 23

  24. Scalability & Availability Terracotta Server Array 24

  25. What is Terracotta?  Enterprise class data management – Clustering, Distributed Caching – Highly Available (99.999) – Linear Scale Out – BigMemory - More scalability with less Hardware – ACID, Persistent to Disk (& SSD) – Ease of Operations – Flexibility with CAP tradeoffs 25

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend