SlideShare ist ein Scribd-Unternehmen logo
1 von 30
Downloaden Sie, um offline zu lesen
Redis: The Universal NoSQL-
            Tool
            Eberhard Wolff
Architecture and Technology Manager
              adesso AG
NoSQL is all
about Big Data
NoSQL is all
about Big Data
Redis
•  Remote Dictionary Server
•  Advanced Key Value Store
•  Actually also a cache and a messaging
   server
•  Open Source – free to change the code
•  Sponsored by VMware
•  No commercial agenda
•  Implemented in C (actually pretty small)
•  In memory (fast)
Redis
•  Data should fit in memory
•  Data written asynchronously to disk or in
   an append only file
  –  Won't slow down operations
  –  Configurable delay
•  Bindings for many languages
•  Very easy replication
•  i.e. like an in-memory cache with
   persistence option
•  http://redis.io/
How to Use Redis
•  Very simple protocol
•  Can telnet to it

•  Libraries for lots of languages

•  Java:
    –  Jedis
    –  JRedis
    –  RJC
•  Spring Data Redis as abstraction
    –  Uniform concepts (e.g. templates) across all NoSQL and SQL
       stores
    –  Even JPA
    –  Exception translation
    –  Still exposes unique features
Use Case: High Scores for
            Players
•  Online game
•  Store high scores

•  High data volume
•  Frequently changing data
Use Case: High Scores for
            Players
•  Note: Other data (name, email, etc) can
   still be stored somewhere else

•  Key: Name of player
•  Value: Score
•  Encoded as bytes

•  Operations: GET, SET, DEL
Demo: RedisWriter /
RedisMultiWriter / RedisClean /
   redis-cli / telnet / redis-
         benchmark
Points to Note
•  Extremely fast
•  See http://redis.io/topics/benchmarks
•  Multi Set: Can issue multiple set operations in
   one round trip for very high performance
•  Data in database does not impact performance
•  Data written asynchronously
•  Not shown:
   –  APPEND : append data to a key
   –  KEYS : find all keys for a pattern
   –  RENAME : Change key
Redis as a Cache
•  Data kept in memory
•  …and on disk
•  Data survives restarts
•  No need for the cache to warm up
•  But: What about evicting data from the cache?
•  Solution: Data can have time-to-live
•  Can set global memory policy to avoid
   excessive memory consumption
•  Let assume certain texts (e.g. HTML) should be
   cached for our application…
Demo: RedisCache
Create Unique Player ID
•  Each player should have a unique ID
•  Needs to be unique, even in a cluster
•  Solution: atomic incr operation
•  i.e. works correctly even if multiple
   threads access the counter at the same
   time
•  Quick – in memory
Demo: RedisCreateID
Similar operations
•  GETSET : Atomically get old value and
   set to new value
•  Global locks using SETNX / DEL
•  SETNX returns true only if the client
   successfully set the value
•  i.e. lock was successfully acquired
Replication
•  Redis uses master / slave replication
•  Slaves can replicate to other slaves
•  Replication does not block the master
•  Useable for scalability of reads or data
   redundancy
•  Write would go to the master and be
   propagated
•  Make backups quite easy
•  Just add
   slaveof <ip> <port>
   to redis.conf
Scaling
•  Slaves can be used for (eventually
   consistent) reads
•  Storage to disk can be offloaded to
   slaves
•  No more breaks during disk writes
•  But: Only one master can write
•  Still: All data should fit in RAM
Scaling
•  Can use Virtual Memory
•  Redis has its own Virtual Memory
   implementation (to be deprecated)
•  Partially implemented: Redis Cluster with
   Master / Slave replication
•  Sharding i.e. data distributed across many
   nodes
•  Could implement your own sharding on the
   client
Redis Data Types
•  So far: Simple types: byte[]
   –  String and numbers encoded as byte[]
   –  Can cluster multiple get/set into one atomic action
•  Atomic increment / decrement for integers
•  Lists
   –  Can add / remove atomically
•  Sets
   –  Like lists but no order
•  Sorted sets
   –  Each element has a score to sort by
Highscores
•  Range the high scores
•  Solutions: Use a sorted set

•  Result: scores automatically sorted

•  Trivial to get the top high scores
Demo: RedisHighScore
Sending EMails
•  EMails should be sent by a server

•  Need to queue emails

•  Solution: Use a list + push / pop
Demo: RedisEMailReaderList /
   RedisEMailWriterList
Next step: Messaging
•  Lists are not really designed for communication
•  Message driven middleware is an established
   concept
•  Redis has some parts
•  Topics
   –  Have a name
   –  Multiple receivers can listen to it
•  Subscribe to
   –  A Topic
   –  Or a patterns of topic names
Demo:
RedisEMailReaderMessaging /
 RedisEMailWriterMessaging
Transactions
•    Multiple actions can be put into a transaction
•    Command MULTI to start transaction
•    EXEC to execute
•    DISCARD to discard

•  Guarantees:
     –  Executed in the defined order
     –  Atomic (all or nothing)
     –  No isolation
     –  Can use optimistic locking
Key-Value Stores: Store Complex Data
•  Storing data as serialized blobs / JSON / XML
     –  ”player:wolff" è ”all the data"
•  Storing data as multiple keys
     –  "player:wolff:score" è 42
     –  "player:wolff:email" è ”eberhard.wolff@adesso.de"
•    Requires multi get/set to be efficient
•    Can find all keys using patterns
•    Can create your custom Serializer in Spring Data
•    Key / values stores are no really useful for
     complex data
Conclusion – Redis is a Swiss Knife
•    Very fast - In Memory
•    Cache + persistence
•    Messaging
•    Centralized locking and counting
•    Much more than just persistence
•    Not shown: Lua scripting
•    Not useful for
     –  Big Data
     –  Seamless scaling
     –  Ad hoc queries
•  Will not be the only data store you use
Links
•  http://redis.io/
•  Try it yourself: http://try.redis-db.com/
•  Spring Data Redis
   http://www.springsource.org/spring-data/redis
•  Demos: https://github.com/ewolff/spring-redis-demo
•  Who is using it?
   http://redis.io/topics/whos-using-redis
•  Books
  –  Tiago Macedo, Fred Oliveira: Redis Cookbook
  –  Pollack, Gierke, Risberg, Brisbin, Hunger: Spring Data

Weitere ähnliche Inhalte

Was ist angesagt?

Using Redis at Facebook
Using Redis at FacebookUsing Redis at Facebook
Using Redis at FacebookRedis Labs
 
10 things, an Oracle DBA should care about when moving to PostgreSQL
10 things, an Oracle DBA should care about when moving to PostgreSQL10 things, an Oracle DBA should care about when moving to PostgreSQL
10 things, an Oracle DBA should care about when moving to PostgreSQLPostgreSQL-Consulting
 
Ansible for large scale deployment
Ansible for large scale deploymentAnsible for large scale deployment
Ansible for large scale deploymentKarthik .P.R
 
From 100s to 100s of Millions
From 100s to 100s of MillionsFrom 100s to 100s of Millions
From 100s to 100s of MillionsErik Onnen
 
DrupalCampLA 2014 - Drupal backend performance and scalability
DrupalCampLA 2014 - Drupal backend performance and scalabilityDrupalCampLA 2014 - Drupal backend performance and scalability
DrupalCampLA 2014 - Drupal backend performance and scalabilitycherryhillco
 
Redis everywhere - PHP London
Redis everywhere - PHP LondonRedis everywhere - PHP London
Redis everywhere - PHP LondonRicard Clau
 
CI_CONF 2012: Scaling
CI_CONF 2012: ScalingCI_CONF 2012: Scaling
CI_CONF 2012: ScalingChris Miller
 
Apache Con 2021 Structured Data Streaming
Apache Con 2021 Structured Data StreamingApache Con 2021 Structured Data Streaming
Apache Con 2021 Structured Data StreamingShivji Kumar Jha
 
Managing 50K+ Redis Databases Over 4 Public Clouds ... with a Tiny Devops Team
Managing 50K+ Redis Databases Over 4 Public Clouds ... with a Tiny Devops TeamManaging 50K+ Redis Databases Over 4 Public Clouds ... with a Tiny Devops Team
Managing 50K+ Redis Databases Over 4 Public Clouds ... with a Tiny Devops TeamRedis Labs
 
Migrate Oracle database to Amazon RDS
Migrate Oracle database to Amazon RDSMigrate Oracle database to Amazon RDS
Migrate Oracle database to Amazon RDSJesus Guzman
 
Roshan Bhattarai: Scaling WordPress for high traffic sites
Roshan Bhattarai: Scaling WordPress for high traffic sitesRoshan Bhattarai: Scaling WordPress for high traffic sites
Roshan Bhattarai: Scaling WordPress for high traffic siteswpnepal
 
Scaling wordpress for high traffic
Scaling wordpress for high trafficScaling wordpress for high traffic
Scaling wordpress for high trafficRoshan Bhattarai
 
Scaling MySQL using Fabric
Scaling MySQL using FabricScaling MySQL using Fabric
Scaling MySQL using FabricKarthik .P.R
 
EECI 2013 - ExpressionEngine Performance & Optimization - Laying a Solid Foun...
EECI 2013 - ExpressionEngine Performance & Optimization - Laying a Solid Foun...EECI 2013 - ExpressionEngine Performance & Optimization - Laying a Solid Foun...
EECI 2013 - ExpressionEngine Performance & Optimization - Laying a Solid Foun...Nexcess.net LLC
 
lessons from managing a pulsar cluster
 lessons from managing a pulsar cluster lessons from managing a pulsar cluster
lessons from managing a pulsar clusterShivji Kumar Jha
 
REDIS (Remote Dictionary Server)
REDIS (Remote Dictionary Server)REDIS (Remote Dictionary Server)
REDIS (Remote Dictionary Server)Ameya Vijay Gokhale
 

Was ist angesagt? (19)

Using Redis at Facebook
Using Redis at FacebookUsing Redis at Facebook
Using Redis at Facebook
 
10 things, an Oracle DBA should care about when moving to PostgreSQL
10 things, an Oracle DBA should care about when moving to PostgreSQL10 things, an Oracle DBA should care about when moving to PostgreSQL
10 things, an Oracle DBA should care about when moving to PostgreSQL
 
Ansible for large scale deployment
Ansible for large scale deploymentAnsible for large scale deployment
Ansible for large scale deployment
 
From 100s to 100s of Millions
From 100s to 100s of MillionsFrom 100s to 100s of Millions
From 100s to 100s of Millions
 
DrupalCampLA 2014 - Drupal backend performance and scalability
DrupalCampLA 2014 - Drupal backend performance and scalabilityDrupalCampLA 2014 - Drupal backend performance and scalability
DrupalCampLA 2014 - Drupal backend performance and scalability
 
Redis everywhere - PHP London
Redis everywhere - PHP LondonRedis everywhere - PHP London
Redis everywhere - PHP London
 
CI_CONF 2012: Scaling
CI_CONF 2012: ScalingCI_CONF 2012: Scaling
CI_CONF 2012: Scaling
 
Apache Con 2021 Structured Data Streaming
Apache Con 2021 Structured Data StreamingApache Con 2021 Structured Data Streaming
Apache Con 2021 Structured Data Streaming
 
Managing 50K+ Redis Databases Over 4 Public Clouds ... with a Tiny Devops Team
Managing 50K+ Redis Databases Over 4 Public Clouds ... with a Tiny Devops TeamManaging 50K+ Redis Databases Over 4 Public Clouds ... with a Tiny Devops Team
Managing 50K+ Redis Databases Over 4 Public Clouds ... with a Tiny Devops Team
 
Migrate Oracle database to Amazon RDS
Migrate Oracle database to Amazon RDSMigrate Oracle database to Amazon RDS
Migrate Oracle database to Amazon RDS
 
Performance out
Performance outPerformance out
Performance out
 
Roshan Bhattarai: Scaling WordPress for high traffic sites
Roshan Bhattarai: Scaling WordPress for high traffic sitesRoshan Bhattarai: Scaling WordPress for high traffic sites
Roshan Bhattarai: Scaling WordPress for high traffic sites
 
Scaling wordpress for high traffic
Scaling wordpress for high trafficScaling wordpress for high traffic
Scaling wordpress for high traffic
 
Scaling MySQL using Fabric
Scaling MySQL using FabricScaling MySQL using Fabric
Scaling MySQL using Fabric
 
Hadoop in a Windows Shop - CHUG - 20120416
Hadoop in a Windows Shop - CHUG - 20120416Hadoop in a Windows Shop - CHUG - 20120416
Hadoop in a Windows Shop - CHUG - 20120416
 
Drupal performance
Drupal performanceDrupal performance
Drupal performance
 
EECI 2013 - ExpressionEngine Performance & Optimization - Laying a Solid Foun...
EECI 2013 - ExpressionEngine Performance & Optimization - Laying a Solid Foun...EECI 2013 - ExpressionEngine Performance & Optimization - Laying a Solid Foun...
EECI 2013 - ExpressionEngine Performance & Optimization - Laying a Solid Foun...
 
lessons from managing a pulsar cluster
 lessons from managing a pulsar cluster lessons from managing a pulsar cluster
lessons from managing a pulsar cluster
 
REDIS (Remote Dictionary Server)
REDIS (Remote Dictionary Server)REDIS (Remote Dictionary Server)
REDIS (Remote Dictionary Server)
 

Andere mochten auch

Operations and Monitoring with Spring
Operations and Monitoring with SpringOperations and Monitoring with Spring
Operations and Monitoring with SpringEberhard Wolff
 
JAXonf 2012 New Challenges and Approaches for Enterprise Java
JAXonf 2012 New Challenges and Approaches for Enterprise JavaJAXonf 2012 New Challenges and Approaches for Enterprise Java
JAXonf 2012 New Challenges and Approaches for Enterprise JavaEberhard Wolff
 
More Productivitiy with Spring Roo
More Productivitiy with Spring RooMore Productivitiy with Spring Roo
More Productivitiy with Spring RooEberhard Wolff
 
Architectures For The Cloud
Architectures For The CloudArchitectures For The Cloud
Architectures For The CloudEberhard Wolff
 
Continuous Delivery and DevOps in the Enterprise
Continuous Delivery and DevOps in the EnterpriseContinuous Delivery and DevOps in the Enterprise
Continuous Delivery and DevOps in the EnterpriseEberhard Wolff
 

Andere mochten auch (6)

Operations and Monitoring with Spring
Operations and Monitoring with SpringOperations and Monitoring with Spring
Operations and Monitoring with Spring
 
Legacy Sins
Legacy SinsLegacy Sins
Legacy Sins
 
JAXonf 2012 New Challenges and Approaches for Enterprise Java
JAXonf 2012 New Challenges and Approaches for Enterprise JavaJAXonf 2012 New Challenges and Approaches for Enterprise Java
JAXonf 2012 New Challenges and Approaches for Enterprise Java
 
More Productivitiy with Spring Roo
More Productivitiy with Spring RooMore Productivitiy with Spring Roo
More Productivitiy with Spring Roo
 
Architectures For The Cloud
Architectures For The CloudArchitectures For The Cloud
Architectures For The Cloud
 
Continuous Delivery and DevOps in the Enterprise
Continuous Delivery and DevOps in the EnterpriseContinuous Delivery and DevOps in the Enterprise
Continuous Delivery and DevOps in the Enterprise
 

Ähnlich wie Redis - The Universal NoSQL Tool

Redis Everywhere - Sunshine PHP
Redis Everywhere - Sunshine PHPRedis Everywhere - Sunshine PHP
Redis Everywhere - Sunshine PHPRicard Clau
 
Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to RedisOfer Zelig
 
Scaling the Web: Databases & NoSQL
Scaling the Web: Databases & NoSQLScaling the Web: Databases & NoSQL
Scaling the Web: Databases & NoSQLRichard Schneeman
 
Writing Scalable Software in Java
Writing Scalable Software in JavaWriting Scalable Software in Java
Writing Scalable Software in JavaRuben Badaró
 
Big Data Developers Moscow Meetup 1 - sql on hadoop
Big Data Developers Moscow Meetup 1  - sql on hadoopBig Data Developers Moscow Meetup 1  - sql on hadoop
Big Data Developers Moscow Meetup 1 - sql on hadoopbddmoscow
 
Top 10 lessons learned from deploying hadoop in a private cloud
Top 10 lessons learned from deploying hadoop in a private cloudTop 10 lessons learned from deploying hadoop in a private cloud
Top 10 lessons learned from deploying hadoop in a private cloudRogue Wave Software
 
Cloud computing UNIT 2.1 presentation in
Cloud computing UNIT 2.1 presentation inCloud computing UNIT 2.1 presentation in
Cloud computing UNIT 2.1 presentation inRahulBhole12
 
Jay Kreps on Project Voldemort Scaling Simple Storage At LinkedIn
Jay Kreps on Project Voldemort Scaling Simple Storage At LinkedInJay Kreps on Project Voldemort Scaling Simple Storage At LinkedIn
Jay Kreps on Project Voldemort Scaling Simple Storage At LinkedInLinkedIn
 
Introduction to memcached
Introduction to memcachedIntroduction to memcached
Introduction to memcachedJurriaan Persyn
 
Real-time searching of big data with Solr and Hadoop
Real-time searching of big data with Solr and HadoopReal-time searching of big data with Solr and Hadoop
Real-time searching of big data with Solr and HadoopRogue Wave Software
 
(DAT407) Amazon ElastiCache: Deep Dive
(DAT407) Amazon ElastiCache: Deep Dive(DAT407) Amazon ElastiCache: Deep Dive
(DAT407) Amazon ElastiCache: Deep DiveAmazon Web Services
 
Infrastructure Around Hadoop
Infrastructure Around HadoopInfrastructure Around Hadoop
Infrastructure Around HadoopDataWorks Summit
 

Ähnlich wie Redis - The Universal NoSQL Tool (20)

Redis meetup
Redis meetupRedis meetup
Redis meetup
 
Redis Everywhere - Sunshine PHP
Redis Everywhere - Sunshine PHPRedis Everywhere - Sunshine PHP
Redis Everywhere - Sunshine PHP
 
Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to Redis
 
Scaling the Web: Databases & NoSQL
Scaling the Web: Databases & NoSQLScaling the Web: Databases & NoSQL
Scaling the Web: Databases & NoSQL
 
Redis in 20 minutes
Redis in 20 minutesRedis in 20 minutes
Redis in 20 minutes
 
Redis acc 2015_eng
Redis acc 2015_engRedis acc 2015_eng
Redis acc 2015_eng
 
Writing Scalable Software in Java
Writing Scalable Software in JavaWriting Scalable Software in Java
Writing Scalable Software in Java
 
NoSql
NoSqlNoSql
NoSql
 
REDIS327
REDIS327REDIS327
REDIS327
 
Big Data Developers Moscow Meetup 1 - sql on hadoop
Big Data Developers Moscow Meetup 1  - sql on hadoopBig Data Developers Moscow Meetup 1  - sql on hadoop
Big Data Developers Moscow Meetup 1 - sql on hadoop
 
KeyValue Stores
KeyValue StoresKeyValue Stores
KeyValue Stores
 
Redis
RedisRedis
Redis
 
Top 10 lessons learned from deploying hadoop in a private cloud
Top 10 lessons learned from deploying hadoop in a private cloudTop 10 lessons learned from deploying hadoop in a private cloud
Top 10 lessons learned from deploying hadoop in a private cloud
 
Cloud computing UNIT 2.1 presentation in
Cloud computing UNIT 2.1 presentation inCloud computing UNIT 2.1 presentation in
Cloud computing UNIT 2.1 presentation in
 
Jay Kreps on Project Voldemort Scaling Simple Storage At LinkedIn
Jay Kreps on Project Voldemort Scaling Simple Storage At LinkedInJay Kreps on Project Voldemort Scaling Simple Storage At LinkedIn
Jay Kreps on Project Voldemort Scaling Simple Storage At LinkedIn
 
Introduction to memcached
Introduction to memcachedIntroduction to memcached
Introduction to memcached
 
Real-time searching of big data with Solr and Hadoop
Real-time searching of big data with Solr and HadoopReal-time searching of big data with Solr and Hadoop
Real-time searching of big data with Solr and Hadoop
 
Redis Labcamp
Redis LabcampRedis Labcamp
Redis Labcamp
 
(DAT407) Amazon ElastiCache: Deep Dive
(DAT407) Amazon ElastiCache: Deep Dive(DAT407) Amazon ElastiCache: Deep Dive
(DAT407) Amazon ElastiCache: Deep Dive
 
Infrastructure Around Hadoop
Infrastructure Around HadoopInfrastructure Around Hadoop
Infrastructure Around Hadoop
 

Mehr von Eberhard Wolff

Architectures and Alternatives
Architectures and AlternativesArchitectures and Alternatives
Architectures and AlternativesEberhard Wolff
 
The Frontiers of Continuous Delivery
The Frontiers of Continuous DeliveryThe Frontiers of Continuous Delivery
The Frontiers of Continuous DeliveryEberhard Wolff
 
Four Times Microservices - REST, Kubernetes, UI Integration, Async
Four Times Microservices - REST, Kubernetes, UI Integration, AsyncFour Times Microservices - REST, Kubernetes, UI Integration, Async
Four Times Microservices - REST, Kubernetes, UI Integration, AsyncEberhard Wolff
 
Microservices - not just with Java
Microservices - not just with JavaMicroservices - not just with Java
Microservices - not just with JavaEberhard Wolff
 
Deployment - Done Right!
Deployment - Done Right!Deployment - Done Right!
Deployment - Done Right!Eberhard Wolff
 
Data Architecture not Just for Microservices
Data Architecture not Just for MicroservicesData Architecture not Just for Microservices
Data Architecture not Just for MicroservicesEberhard Wolff
 
How to Split Your System into Microservices
How to Split Your System into MicroservicesHow to Split Your System into Microservices
How to Split Your System into MicroservicesEberhard Wolff
 
Microservices and Self-contained System to Scale Agile
Microservices and Self-contained System to Scale AgileMicroservices and Self-contained System to Scale Agile
Microservices and Self-contained System to Scale AgileEberhard Wolff
 
How Small Can Java Microservices Be?
How Small Can Java Microservices Be?How Small Can Java Microservices Be?
How Small Can Java Microservices Be?Eberhard Wolff
 
Data Architecturen Not Just for Microservices
Data Architecturen Not Just for MicroservicesData Architecturen Not Just for Microservices
Data Architecturen Not Just for MicroservicesEberhard Wolff
 
Microservices: Redundancy=Maintainability
Microservices: Redundancy=MaintainabilityMicroservices: Redundancy=Maintainability
Microservices: Redundancy=MaintainabilityEberhard Wolff
 
Self-contained Systems: A Different Approach to Microservices
Self-contained Systems: A Different Approach to MicroservicesSelf-contained Systems: A Different Approach to Microservices
Self-contained Systems: A Different Approach to MicroservicesEberhard Wolff
 
Microservices Technology Stack
Microservices Technology StackMicroservices Technology Stack
Microservices Technology StackEberhard Wolff
 
Software Architecture for Innovation
Software Architecture for InnovationSoftware Architecture for Innovation
Software Architecture for InnovationEberhard Wolff
 
Five (easy?) Steps Towards Continuous Delivery
Five (easy?) Steps Towards Continuous DeliveryFive (easy?) Steps Towards Continuous Delivery
Five (easy?) Steps Towards Continuous DeliveryEberhard Wolff
 
Nanoservices and Microservices with Java
Nanoservices and Microservices with JavaNanoservices and Microservices with Java
Nanoservices and Microservices with JavaEberhard Wolff
 
Microservices: Architecture to Support Agile
Microservices: Architecture to Support AgileMicroservices: Architecture to Support Agile
Microservices: Architecture to Support AgileEberhard Wolff
 
Microservices: Architecture to scale Agile
Microservices: Architecture to scale AgileMicroservices: Architecture to scale Agile
Microservices: Architecture to scale AgileEberhard Wolff
 
Microservices, DevOps, Continuous Delivery – More Than Three Buzzwords
Microservices, DevOps, Continuous Delivery – More Than Three BuzzwordsMicroservices, DevOps, Continuous Delivery – More Than Three Buzzwords
Microservices, DevOps, Continuous Delivery – More Than Three BuzzwordsEberhard Wolff
 

Mehr von Eberhard Wolff (20)

Architectures and Alternatives
Architectures and AlternativesArchitectures and Alternatives
Architectures and Alternatives
 
Beyond Microservices
Beyond MicroservicesBeyond Microservices
Beyond Microservices
 
The Frontiers of Continuous Delivery
The Frontiers of Continuous DeliveryThe Frontiers of Continuous Delivery
The Frontiers of Continuous Delivery
 
Four Times Microservices - REST, Kubernetes, UI Integration, Async
Four Times Microservices - REST, Kubernetes, UI Integration, AsyncFour Times Microservices - REST, Kubernetes, UI Integration, Async
Four Times Microservices - REST, Kubernetes, UI Integration, Async
 
Microservices - not just with Java
Microservices - not just with JavaMicroservices - not just with Java
Microservices - not just with Java
 
Deployment - Done Right!
Deployment - Done Right!Deployment - Done Right!
Deployment - Done Right!
 
Data Architecture not Just for Microservices
Data Architecture not Just for MicroservicesData Architecture not Just for Microservices
Data Architecture not Just for Microservices
 
How to Split Your System into Microservices
How to Split Your System into MicroservicesHow to Split Your System into Microservices
How to Split Your System into Microservices
 
Microservices and Self-contained System to Scale Agile
Microservices and Self-contained System to Scale AgileMicroservices and Self-contained System to Scale Agile
Microservices and Self-contained System to Scale Agile
 
How Small Can Java Microservices Be?
How Small Can Java Microservices Be?How Small Can Java Microservices Be?
How Small Can Java Microservices Be?
 
Data Architecturen Not Just for Microservices
Data Architecturen Not Just for MicroservicesData Architecturen Not Just for Microservices
Data Architecturen Not Just for Microservices
 
Microservices: Redundancy=Maintainability
Microservices: Redundancy=MaintainabilityMicroservices: Redundancy=Maintainability
Microservices: Redundancy=Maintainability
 
Self-contained Systems: A Different Approach to Microservices
Self-contained Systems: A Different Approach to MicroservicesSelf-contained Systems: A Different Approach to Microservices
Self-contained Systems: A Different Approach to Microservices
 
Microservices Technology Stack
Microservices Technology StackMicroservices Technology Stack
Microservices Technology Stack
 
Software Architecture for Innovation
Software Architecture for InnovationSoftware Architecture for Innovation
Software Architecture for Innovation
 
Five (easy?) Steps Towards Continuous Delivery
Five (easy?) Steps Towards Continuous DeliveryFive (easy?) Steps Towards Continuous Delivery
Five (easy?) Steps Towards Continuous Delivery
 
Nanoservices and Microservices with Java
Nanoservices and Microservices with JavaNanoservices and Microservices with Java
Nanoservices and Microservices with Java
 
Microservices: Architecture to Support Agile
Microservices: Architecture to Support AgileMicroservices: Architecture to Support Agile
Microservices: Architecture to Support Agile
 
Microservices: Architecture to scale Agile
Microservices: Architecture to scale AgileMicroservices: Architecture to scale Agile
Microservices: Architecture to scale Agile
 
Microservices, DevOps, Continuous Delivery – More Than Three Buzzwords
Microservices, DevOps, Continuous Delivery – More Than Three BuzzwordsMicroservices, DevOps, Continuous Delivery – More Than Three Buzzwords
Microservices, DevOps, Continuous Delivery – More Than Three Buzzwords
 

Redis - The Universal NoSQL Tool

  • 1. Redis: The Universal NoSQL- Tool Eberhard Wolff Architecture and Technology Manager adesso AG
  • 4. Redis •  Remote Dictionary Server •  Advanced Key Value Store •  Actually also a cache and a messaging server •  Open Source – free to change the code •  Sponsored by VMware •  No commercial agenda •  Implemented in C (actually pretty small) •  In memory (fast)
  • 5. Redis •  Data should fit in memory •  Data written asynchronously to disk or in an append only file –  Won't slow down operations –  Configurable delay •  Bindings for many languages •  Very easy replication •  i.e. like an in-memory cache with persistence option •  http://redis.io/
  • 6.
  • 7. How to Use Redis •  Very simple protocol •  Can telnet to it •  Libraries for lots of languages •  Java: –  Jedis –  JRedis –  RJC •  Spring Data Redis as abstraction –  Uniform concepts (e.g. templates) across all NoSQL and SQL stores –  Even JPA –  Exception translation –  Still exposes unique features
  • 8. Use Case: High Scores for Players •  Online game •  Store high scores •  High data volume •  Frequently changing data
  • 9. Use Case: High Scores for Players •  Note: Other data (name, email, etc) can still be stored somewhere else •  Key: Name of player •  Value: Score •  Encoded as bytes •  Operations: GET, SET, DEL
  • 10. Demo: RedisWriter / RedisMultiWriter / RedisClean / redis-cli / telnet / redis- benchmark
  • 11. Points to Note •  Extremely fast •  See http://redis.io/topics/benchmarks •  Multi Set: Can issue multiple set operations in one round trip for very high performance •  Data in database does not impact performance •  Data written asynchronously •  Not shown: –  APPEND : append data to a key –  KEYS : find all keys for a pattern –  RENAME : Change key
  • 12. Redis as a Cache •  Data kept in memory •  …and on disk •  Data survives restarts •  No need for the cache to warm up •  But: What about evicting data from the cache? •  Solution: Data can have time-to-live •  Can set global memory policy to avoid excessive memory consumption •  Let assume certain texts (e.g. HTML) should be cached for our application…
  • 14. Create Unique Player ID •  Each player should have a unique ID •  Needs to be unique, even in a cluster •  Solution: atomic incr operation •  i.e. works correctly even if multiple threads access the counter at the same time •  Quick – in memory
  • 16. Similar operations •  GETSET : Atomically get old value and set to new value •  Global locks using SETNX / DEL •  SETNX returns true only if the client successfully set the value •  i.e. lock was successfully acquired
  • 17. Replication •  Redis uses master / slave replication •  Slaves can replicate to other slaves •  Replication does not block the master •  Useable for scalability of reads or data redundancy •  Write would go to the master and be propagated •  Make backups quite easy •  Just add slaveof <ip> <port> to redis.conf
  • 18. Scaling •  Slaves can be used for (eventually consistent) reads •  Storage to disk can be offloaded to slaves •  No more breaks during disk writes •  But: Only one master can write •  Still: All data should fit in RAM
  • 19. Scaling •  Can use Virtual Memory •  Redis has its own Virtual Memory implementation (to be deprecated) •  Partially implemented: Redis Cluster with Master / Slave replication •  Sharding i.e. data distributed across many nodes •  Could implement your own sharding on the client
  • 20. Redis Data Types •  So far: Simple types: byte[] –  String and numbers encoded as byte[] –  Can cluster multiple get/set into one atomic action •  Atomic increment / decrement for integers •  Lists –  Can add / remove atomically •  Sets –  Like lists but no order •  Sorted sets –  Each element has a score to sort by
  • 21. Highscores •  Range the high scores •  Solutions: Use a sorted set •  Result: scores automatically sorted •  Trivial to get the top high scores
  • 23. Sending EMails •  EMails should be sent by a server •  Need to queue emails •  Solution: Use a list + push / pop
  • 24. Demo: RedisEMailReaderList / RedisEMailWriterList
  • 25. Next step: Messaging •  Lists are not really designed for communication •  Message driven middleware is an established concept •  Redis has some parts •  Topics –  Have a name –  Multiple receivers can listen to it •  Subscribe to –  A Topic –  Or a patterns of topic names
  • 27. Transactions •  Multiple actions can be put into a transaction •  Command MULTI to start transaction •  EXEC to execute •  DISCARD to discard •  Guarantees: –  Executed in the defined order –  Atomic (all or nothing) –  No isolation –  Can use optimistic locking
  • 28. Key-Value Stores: Store Complex Data •  Storing data as serialized blobs / JSON / XML –  ”player:wolff" è ”all the data" •  Storing data as multiple keys –  "player:wolff:score" è 42 –  "player:wolff:email" è ”eberhard.wolff@adesso.de" •  Requires multi get/set to be efficient •  Can find all keys using patterns •  Can create your custom Serializer in Spring Data •  Key / values stores are no really useful for complex data
  • 29. Conclusion – Redis is a Swiss Knife •  Very fast - In Memory •  Cache + persistence •  Messaging •  Centralized locking and counting •  Much more than just persistence •  Not shown: Lua scripting •  Not useful for –  Big Data –  Seamless scaling –  Ad hoc queries •  Will not be the only data store you use
  • 30. Links •  http://redis.io/ •  Try it yourself: http://try.redis-db.com/ •  Spring Data Redis http://www.springsource.org/spring-data/redis •  Demos: https://github.com/ewolff/spring-redis-demo •  Who is using it? http://redis.io/topics/whos-using-redis •  Books –  Tiago Macedo, Fred Oliveira: Redis Cookbook –  Pollack, Gierke, Risberg, Brisbin, Hunger: Spring Data