SlideShare une entreprise Scribd logo
1  sur  23
Télécharger pour lire hors ligne
ARE YOU REDIS TO GO ?
MAXIME LEMAITRE – 10/04/2014
1
> GET agenda
> GET introduction
> SMEMBERS datatypes
> INFO commands
> CLIENT LIST
> PSUBSCRIBE performance?
> LRANGE features 0 3
persitence
transaction
replication
pubsub
> ZREVRANGE usecases 0 -1
> SEGFAULT
> ?
I see Redis definitely more as a flexible tool
that as a solution specialized to solve a
specific problem: his mixed soul of cache,
store, and messaging server shows this
very well - Salvatore Sanfilippo (antirez),
creator of Redis
2
Brief Introduction
• Redis is an open source (since March 2009), advanced key-value
store. It is often referred to as a data structure server since keys
can contain strings, hashes, lists, sets and sorted sets.
• Originally written in order to help address the scaling needs of
http://lloogg.com/, a web analytics startup, by Salvatore (antirez)
Sanfilippo.
• Redis is written in ANSI C and works in most POSIX systems like
Linux, *BSD, OS X and Solaris without external dependencies. Redis
project does not directly support Windows, however MSOpenTech
develops and maintains an Windows port targeting Win64.
3
Command Processing
http://redis.io/commands
• Protocol RESP
– clients communicate with the Redis using REdis Serialization Protocol
• Simple, Fast & Human readable
– Commands are processed in serial in a single thread (like Node.js)
• Superfast processing of commands (a few ms, sometimes less)
• If you want to use more CPUs, shard your data client-side
• Command groups
– Request/response
– Pipelined: Several requests / responses
– Transactions:
• Traditional: Several requests processed in order atomically
• Check-And-Set: Request(s), data manipulation in client, more
requests
– Scripts (>v2.6): execute client-defined Lua scripts in the server for
more complex actions 4
What is a Command ?
http://redis.io/commands
Command name + parameters >
Version >
Complexity (really important) >
Description >
Result/return value >
Example >
Approx. 160 available
commands 5
Data Types
List Set Sorted Set Hash
[A, B, C, D]
“A”
“B”
“C”
“D”
D
C
B
A
A:3
C:1
D:2
B:4
{A, B, C, D} {C:1, D:2, A:3, D:4}
“A”
“B”
“C”
“D”
field1
field2
field3
field4
{field1:“A”, field2:“B”…}
{value:score} {key:value}
Basically maps keys to values (Strings), but also contains more advanced data
structures here :
* New Data Structure since April, 1st : HyperLogLog 6
Popular .net clients
Many clients for nearly all languages
• ActionScript
• C / C++
• C#
• Clojure
• Lisp
• Dart
• Erlang
• Fancy
• Go
• Haskell
• haXe
• Io
• Java
• Lua
• Node.js
• Objective-C
• Perl
• PHP
• Python
• Ruby
• Scala
• Smalltalk
• Tcl
7
How fast is Redis ?
(note : it’s common a manage millions of keys)
Redis includes the redis-benchmark utility that simulates running commands done by
N clients at the same time sending M total queries.
• Example on Intel(R) Xeon(R) CPU E5520 @ 2.27GHz (without pipelining)
Commands are generally processed in a few ms. Network
bandwidth and latency usually have a direct impact on the
performance. CPU is another very important factor. 8
Redis Feature : Persistence
http://redis.io/topics/persistence
Redis provides a different range of persistence options: RDB, AOF and None.
• RDB
– Periodic, asynchronous dump to disk
– Can be every N changes or every N seconds
– Written to file in “dbfilename”.rdb (could be backup elsewhere)
– may loss several minutes during a crash
• AOF
– Copies incoming commands as it happens
– Log-based, redo whole steps since startup
– Still fast enough, but often limited by disk performance
– may loss a few seconds during a crash
• None
– Keep data only in Memory.
9
Redis Feature : Transaction
http://redis.io/topics/transactions
• Multiple actions can be put into a transaction
– execute multiple command in a single step.
– Either all of the commands or none are processed
• Command MULTI to start transaction
– EXEC to execute
– DISCARD to discard
– WATCH for Optimistic locking
• Guarantees:
– Executed in the defined order
– Atomic (all or nothing)
– No isolation
– Can use optimistic locking
> MULTI
OK
> INCR pageviews:count
QUEUED
> EXPIRE pageviews:count 60
QUEUED
> SADD pageviews http://google.fr
QUEUED
> EXPIRE pageviews 60
QUEUED
> EXEC
1) (integer) 4660294
2) (integer) 1
3) (integer) 569023
4) (integer) 1 10
Redis Feature : Replication
http://redis.io/topics/replication
• Redis uses classic master / slave replication
• Slaves can replicate to other slaves (in a graph-like structure)
• Replication does not block the master/slave (async)
• Boost scalability & allow redundancy
 Scaling performance by using the replicas for intensive read
operations.
 Making data redundant in multiple locations.
 Offloading data persistency costs from the master by
delegating it to the slaves
> SLAVEOF PAR-REDIS01:6379
> SLAVEOF PAR-REDIS01:6379
> SLAVEOF PAR-REDIS01:6379
11
Redis Feature : PubSub
http://redis.io/topics/pubsub (my favorite)
• A client can subscribe some topics, and when someone publish topic matches the
interest (topic), redis send it to it.
• Clients can subscribe to channels (eg user:1245) or patterns (eg user:*)
• Subscribing is O(1), posting messages is O(n)
• Use cases : Think chats, real-time analytics, twitter, …
CLIENT 1
> PSUBSCRIBE user:*
psubscribe
user:*
1
…
//wait notification
…
pmessage
user:*
user:1000
themessage
EMITTER 1
> PUBLISH user:1001 themessage
1 //number of message sent
Keyspace Notifications (>2.8) allows client to receive events
affecting the Redis data set (commands affecting a given key,
expiration, any command processed, …)
2
12
Use case #1 : Who’s online ?
//cybermaxs has 3 friends
> SADD cybermaxs:friends maxs
> SADD cybermaxs:friends nicocanicola
> SADD cybermaxs:friends oinant
//cybermaxs connects
> SADD users:online cybermaxs
//maxs connects
> SADD users:online maxs
//oinant connects
> SADD users:online oinant
Who’s online ?
> SMEMBERS users:online
Maxs
oinant
cybermaxs
Are cybermaxs’s friends online ?
> SINTER users:online cybermaxs:friends
maxs
oinant
Is nicocanicola connected ?
> SISMEMBERS users:online nicocanicola
0
How many connected users ?
> SCARD users:online
3
13
Use case #2 : leaderboard
> ZADD leaderboard 1543 cybermaxs
> ZADD leaderboard 4564 nicocanicola
> ZADD leaderboard 8954 toto
> ZADD leaderboard 6164 oinant
> ZADD leaderboard 9642 cybermaxs
> ZADD leaderboard 4123 toto
> ZADD leaderboard 8713 maxs
How to get top 3 ?
> ZREVRANGE leaderboard 0 2
WITHSCORES
cybermaxs
9642
toto
8954
maxs
8713
How to get rank of player X ?
> ZREVRANK leaderboard oinant
3
How to get score of player X ?
> ZSCORE leaderboard toto
8954
How to add score to player ?
> ZINCRBY leaderboard 3000
nicocanicolas
7563
SELECT TOP 10 * FROM leaderboard
WHERE ... ORDER BY score DESC ?
14
> INCR questions:nextid
1234 //last question id was 1233
> HMSET question:1234 title “Are you Redis to go?"
asked_by “cybermaxs“ votes 0
OK //add question to redis
> LPUSH questions question:1234
1 //add to list
> SADD question:1234:tags redis nosql
2 //add to tags
// later upvote by a user
> HINCRBY question:1234 votes 1
1
> ZINCRBY tagged:redis 1 question:1
1
Use case #3 : StackExchange Clone
Lastest 200 questions for Homepage
> LRANGE questions 0 199
question:200
question:199
…
Get Votes for a question
> HMGET question:1234 votes
2
Get Tags for a question
> SMEMBERS question:1234
redis
nosql
Questions by Tags, Sorted by Votes
> ZREVRANGE tagged:redis 0 5
question:1234
question:486
…
Subscribe to all changes on a question
> SUBSCRIBE __key*question:1234
+ Socket.IO
/SignalR
15
Common uses cases
• Cache out-of-process
• Duplicate detector
• FIFO/LIFO Queue
• Priority Queue
• Distributed hashmap
– e.g. url shortener
• UID generator
• Game high scores
• Geolocation lookup
– lat & long -> city
• Real-time analytics
• Metrics DB
• API throttling (rate-
limits)
• Autocomplete
• Twitter
• digg / Hacker News
• Social activity feed
• …
16
Who is using Redis ?
17
Conclusion
18
Questions
(mine : are you Redis to Go ?)
19
References
• http://redis.io/
• http://en.wikipedia.org/wiki/Redis
• http://try.redis.io/ (online introduction)
• http://redis.io/topics/data-types-intro
• http://highscalability.com/blog/2011/7/6/11-common-web-use-cases-solved-in-
redis.html
• http://oldblog.antirez.com/post/take-advantage-of-redis-adding-it-to-your-
stack.html
• http://mono.servicestack.net/docs/redis-client/designing-nosql-database
• http://fr.slideshare.net/dvirsky/kicking-ass-with-redis
• http://fr.slideshare.net/noahd1/redis-in-practice
20
Find out more
• On https://techblog.betclicgroup.com/
21
We want our brands to be easy to use for
every gamer around the world.
Join us to make that happen.
Everything we do reflect our values
Come and work in a friendly atmosphere
based on trust & cooperation between IT
Teams.
Learn & Share with us
Friday tech trainings, BBL, Meetups,
Coding Dojo, Innovation Day & more
If you want to contribute to the success of
our group, look at all the challenges we
offer HERE
Want to be part of a great online gambling company?
Check out our Carreers account
on Stackoverflow
22
About Us
• Betclic Everest Group, one of the world leaders in online
gaming, has a unique portfolio comprising various
complementary international brands: Betclic, Everest, bet-at-
home.com, Expekt, Monte-Carlo Casino…
• Through our brands, Betclic Everest Group places expertise,
technological know-how and security at the heart of our
strategy to deliver an on-line gaming offer attuned to the
passion of our players. We want our brands to be easy to use
for every gamer around the world. We’re building our
company to make that happen.
• Active in 100 countries with more than 12 million customers
worldwide, the Group is committed to promoting secure and
responsible gaming and is a member of several international
professional associations including the EGBA (European
Gaming and Betting Association) and the ESSA (European
Sports Security Association).
23

Contenu connexe

Tendances

Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20Michael Lihs
 
Introduction to ansible
Introduction to ansibleIntroduction to ansible
Introduction to ansibleKrish
 
PHP Indonesia - Nodejs Web Development
PHP Indonesia - Nodejs Web DevelopmentPHP Indonesia - Nodejs Web Development
PHP Indonesia - Nodejs Web DevelopmentIrfan Maulana
 
Afrimadoni the power of docker
Afrimadoni   the power of dockerAfrimadoni   the power of docker
Afrimadoni the power of dockerPHP Indonesia
 
OpenNebula in a Multiuser Environment
OpenNebula in a Multiuser EnvironmentOpenNebula in a Multiuser Environment
OpenNebula in a Multiuser EnvironmentNETWAYS
 
Introduction to apache maven
Introduction to apache mavenIntroduction to apache maven
Introduction to apache mavenKrish
 
Codecoon - A technical Case Study
Codecoon - A technical Case StudyCodecoon - A technical Case Study
Codecoon - A technical Case StudyMichael Lihs
 
OpenStack in action 4! Alessandro Pilotti - OpenStack, Hyper-V and Windows
OpenStack in action 4! Alessandro Pilotti - OpenStack, Hyper-V and WindowsOpenStack in action 4! Alessandro Pilotti - OpenStack, Hyper-V and Windows
OpenStack in action 4! Alessandro Pilotti - OpenStack, Hyper-V and WindowseNovance
 
They why behind php frameworks
They why behind php frameworksThey why behind php frameworks
They why behind php frameworksKirk Madera
 
Introduction to jenkins
Introduction to jenkinsIntroduction to jenkins
Introduction to jenkinsKrish
 
Vagrant and Chef on FOSSASIA 2014
Vagrant and Chef on FOSSASIA 2014Vagrant and Chef on FOSSASIA 2014
Vagrant and Chef on FOSSASIA 2014Michael Lihs
 
CodeIgniter For Project : Lesson 103 - Introduction to Codeigniter
CodeIgniter For Project : Lesson 103 - Introduction to CodeigniterCodeIgniter For Project : Lesson 103 - Introduction to Codeigniter
CodeIgniter For Project : Lesson 103 - Introduction to CodeigniterWeerayut Hongsa
 
Untangling - fall2017 - week 8
Untangling - fall2017 - week 8Untangling - fall2017 - week 8
Untangling - fall2017 - week 8Derek Jacoby
 
Introduction to docker
Introduction to dockerIntroduction to docker
Introduction to dockerKrish
 

Tendances (20)

Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
 
Introduction to ansible
Introduction to ansibleIntroduction to ansible
Introduction to ansible
 
Dot Net Core
Dot Net CoreDot Net Core
Dot Net Core
 
PHP Indonesia - Nodejs Web Development
PHP Indonesia - Nodejs Web DevelopmentPHP Indonesia - Nodejs Web Development
PHP Indonesia - Nodejs Web Development
 
Afrimadoni the power of docker
Afrimadoni   the power of dockerAfrimadoni   the power of docker
Afrimadoni the power of docker
 
OpenNebula in a Multiuser Environment
OpenNebula in a Multiuser EnvironmentOpenNebula in a Multiuser Environment
OpenNebula in a Multiuser Environment
 
Docker
DockerDocker
Docker
 
Introduction to apache maven
Introduction to apache mavenIntroduction to apache maven
Introduction to apache maven
 
Codecoon - A technical Case Study
Codecoon - A technical Case StudyCodecoon - A technical Case Study
Codecoon - A technical Case Study
 
Composer
ComposerComposer
Composer
 
OpenStack in action 4! Alessandro Pilotti - OpenStack, Hyper-V and Windows
OpenStack in action 4! Alessandro Pilotti - OpenStack, Hyper-V and WindowsOpenStack in action 4! Alessandro Pilotti - OpenStack, Hyper-V and Windows
OpenStack in action 4! Alessandro Pilotti - OpenStack, Hyper-V and Windows
 
Mastering composer
Mastering composerMastering composer
Mastering composer
 
They why behind php frameworks
They why behind php frameworksThey why behind php frameworks
They why behind php frameworks
 
Mini Training Flyway
Mini Training FlywayMini Training Flyway
Mini Training Flyway
 
Introduction to jenkins
Introduction to jenkinsIntroduction to jenkins
Introduction to jenkins
 
Vagrant and Chef on FOSSASIA 2014
Vagrant and Chef on FOSSASIA 2014Vagrant and Chef on FOSSASIA 2014
Vagrant and Chef on FOSSASIA 2014
 
CodeIgniter For Project : Lesson 103 - Introduction to Codeigniter
CodeIgniter For Project : Lesson 103 - Introduction to CodeigniterCodeIgniter For Project : Lesson 103 - Introduction to Codeigniter
CodeIgniter For Project : Lesson 103 - Introduction to Codeigniter
 
Hacking on WildFly 9
Hacking on WildFly 9Hacking on WildFly 9
Hacking on WildFly 9
 
Untangling - fall2017 - week 8
Untangling - fall2017 - week 8Untangling - fall2017 - week 8
Untangling - fall2017 - week 8
 
Introduction to docker
Introduction to dockerIntroduction to docker
Introduction to docker
 

Similaire à Mini-Training: Redis

Lessons learned while building Omroep.nl
Lessons learned while building Omroep.nlLessons learned while building Omroep.nl
Lessons learned while building Omroep.nltieleman
 
Lessons learned while building Omroep.nl
Lessons learned while building Omroep.nlLessons learned while building Omroep.nl
Lessons learned while building Omroep.nlbartzon
 
Managing Your Security Logs with Elasticsearch
Managing Your Security Logs with ElasticsearchManaging Your Security Logs with Elasticsearch
Managing Your Security Logs with ElasticsearchVic Hargrave
 
Redispresentation apac2012
Redispresentation apac2012Redispresentation apac2012
Redispresentation apac2012Ankur Gupta
 
10 Ways to Scale Your Website Silicon Valley Code Camp 2019
10 Ways to Scale Your Website Silicon Valley Code Camp 201910 Ways to Scale Your Website Silicon Valley Code Camp 2019
10 Ways to Scale Your Website Silicon Valley Code Camp 2019Dave Nielsen
 
Redis everywhere - PHP London
Redis everywhere - PHP LondonRedis everywhere - PHP London
Redis everywhere - PHP LondonRicard Clau
 
6 tips for improving ruby performance
6 tips for improving ruby performance6 tips for improving ruby performance
6 tips for improving ruby performanceEngine Yard
 
Big Data analytics with Nginx, Logstash, Redis, Google Bigquery and Neo4j, ja...
Big Data analytics with Nginx, Logstash, Redis, Google Bigquery and Neo4j, ja...Big Data analytics with Nginx, Logstash, Redis, Google Bigquery and Neo4j, ja...
Big Data analytics with Nginx, Logstash, Redis, Google Bigquery and Neo4j, ja...javier ramirez
 
Drupal Efficiency - Coding, Deployment, Scaling
Drupal Efficiency - Coding, Deployment, ScalingDrupal Efficiency - Coding, Deployment, Scaling
Drupal Efficiency - Coding, Deployment, Scalingsmattoon
 
Developing a Redis Module - Hackathon Kickoff
 Developing a Redis Module - Hackathon Kickoff Developing a Redis Module - Hackathon Kickoff
Developing a Redis Module - Hackathon KickoffItamar Haber
 
Drupal Efficiency using open source technologies from Sun
Drupal Efficiency using open source technologies from SunDrupal Efficiency using open source technologies from Sun
Drupal Efficiency using open source technologies from Sunsmattoon
 
Performance & Scalability Improvements in Perforce
Performance & Scalability Improvements in PerforcePerformance & Scalability Improvements in Perforce
Performance & Scalability Improvements in PerforcePerforce
 
(DAT407) Amazon ElastiCache: Deep Dive
(DAT407) Amazon ElastiCache: Deep Dive(DAT407) Amazon ElastiCache: Deep Dive
(DAT407) Amazon ElastiCache: Deep DiveAmazon Web Services
 
What's new with enterprise Redis - Leena Joshi, Redis Labs
What's new with enterprise Redis - Leena Joshi, Redis LabsWhat's new with enterprise Redis - Leena Joshi, Redis Labs
What's new with enterprise Redis - Leena Joshi, Redis LabsRedis Labs
 
Important work-arounds for making ASS multi-lingual
Important work-arounds for making ASS multi-lingualImportant work-arounds for making ASS multi-lingual
Important work-arounds for making ASS multi-lingualAxel Faust
 
Hadoop & no sql new generation database systems
Hadoop & no sql   new generation database systemsHadoop & no sql   new generation database systems
Hadoop & no sql new generation database systemsramazan fırın
 
Drilling into Data with Apache Drill
Drilling into Data with Apache DrillDrilling into Data with Apache Drill
Drilling into Data with Apache DrillMapR Technologies
 
10 Ways to Scale with Redis - LA Redis Meetup 2019
10 Ways to Scale with Redis - LA Redis Meetup 201910 Ways to Scale with Redis - LA Redis Meetup 2019
10 Ways to Scale with Redis - LA Redis Meetup 2019Dave Nielsen
 

Similaire à Mini-Training: Redis (20)

REDIS327
REDIS327REDIS327
REDIS327
 
Lessons learned while building Omroep.nl
Lessons learned while building Omroep.nlLessons learned while building Omroep.nl
Lessons learned while building Omroep.nl
 
Lessons learned while building Omroep.nl
Lessons learned while building Omroep.nlLessons learned while building Omroep.nl
Lessons learned while building Omroep.nl
 
Managing Your Security Logs with Elasticsearch
Managing Your Security Logs with ElasticsearchManaging Your Security Logs with Elasticsearch
Managing Your Security Logs with Elasticsearch
 
Redispresentation apac2012
Redispresentation apac2012Redispresentation apac2012
Redispresentation apac2012
 
10 Ways to Scale Your Website Silicon Valley Code Camp 2019
10 Ways to Scale Your Website Silicon Valley Code Camp 201910 Ways to Scale Your Website Silicon Valley Code Camp 2019
10 Ways to Scale Your Website Silicon Valley Code Camp 2019
 
Redis everywhere - PHP London
Redis everywhere - PHP LondonRedis everywhere - PHP London
Redis everywhere - PHP London
 
6 tips for improving ruby performance
6 tips for improving ruby performance6 tips for improving ruby performance
6 tips for improving ruby performance
 
Big Data analytics with Nginx, Logstash, Redis, Google Bigquery and Neo4j, ja...
Big Data analytics with Nginx, Logstash, Redis, Google Bigquery and Neo4j, ja...Big Data analytics with Nginx, Logstash, Redis, Google Bigquery and Neo4j, ja...
Big Data analytics with Nginx, Logstash, Redis, Google Bigquery and Neo4j, ja...
 
Drupal Efficiency - Coding, Deployment, Scaling
Drupal Efficiency - Coding, Deployment, ScalingDrupal Efficiency - Coding, Deployment, Scaling
Drupal Efficiency - Coding, Deployment, Scaling
 
Developing a Redis Module - Hackathon Kickoff
 Developing a Redis Module - Hackathon Kickoff Developing a Redis Module - Hackathon Kickoff
Developing a Redis Module - Hackathon Kickoff
 
Drupal Efficiency using open source technologies from Sun
Drupal Efficiency using open source technologies from SunDrupal Efficiency using open source technologies from Sun
Drupal Efficiency using open source technologies from Sun
 
Hotsos Advanced Linux Tools
Hotsos Advanced Linux ToolsHotsos Advanced Linux Tools
Hotsos Advanced Linux Tools
 
Performance & Scalability Improvements in Perforce
Performance & Scalability Improvements in PerforcePerformance & Scalability Improvements in Perforce
Performance & Scalability Improvements in Perforce
 
(DAT407) Amazon ElastiCache: Deep Dive
(DAT407) Amazon ElastiCache: Deep Dive(DAT407) Amazon ElastiCache: Deep Dive
(DAT407) Amazon ElastiCache: Deep Dive
 
What's new with enterprise Redis - Leena Joshi, Redis Labs
What's new with enterprise Redis - Leena Joshi, Redis LabsWhat's new with enterprise Redis - Leena Joshi, Redis Labs
What's new with enterprise Redis - Leena Joshi, Redis Labs
 
Important work-arounds for making ASS multi-lingual
Important work-arounds for making ASS multi-lingualImportant work-arounds for making ASS multi-lingual
Important work-arounds for making ASS multi-lingual
 
Hadoop & no sql new generation database systems
Hadoop & no sql   new generation database systemsHadoop & no sql   new generation database systems
Hadoop & no sql new generation database systems
 
Drilling into Data with Apache Drill
Drilling into Data with Apache DrillDrilling into Data with Apache Drill
Drilling into Data with Apache Drill
 
10 Ways to Scale with Redis - LA Redis Meetup 2019
10 Ways to Scale with Redis - LA Redis Meetup 201910 Ways to Scale with Redis - LA Redis Meetup 2019
10 Ways to Scale with Redis - LA Redis Meetup 2019
 

Plus de Betclic Everest Group Tech Team

Mini-training: Personalization & Recommendation Demystified
Mini-training: Personalization & Recommendation DemystifiedMini-training: Personalization & Recommendation Demystified
Mini-training: Personalization & Recommendation DemystifiedBetclic Everest Group Tech Team
 

Plus de Betclic Everest Group Tech Team (20)

Mini training - Reactive Extensions (Rx)
Mini training - Reactive Extensions (Rx)Mini training - Reactive Extensions (Rx)
Mini training - Reactive Extensions (Rx)
 
Mini training - Moving to xUnit.net
Mini training - Moving to xUnit.netMini training - Moving to xUnit.net
Mini training - Moving to xUnit.net
 
Mini training - Introduction to Microsoft Azure Storage
Mini training - Introduction to Microsoft Azure StorageMini training - Introduction to Microsoft Azure Storage
Mini training - Introduction to Microsoft Azure Storage
 
Akka.Net
Akka.NetAkka.Net
Akka.Net
 
Mini training- Scenario Driven Design
Mini training- Scenario Driven DesignMini training- Scenario Driven Design
Mini training- Scenario Driven Design
 
Email Management in Outlook
Email Management in OutlookEmail Management in Outlook
Email Management in Outlook
 
Mini-Training: SSO with Windows Identity Foundation
Mini-Training: SSO with Windows Identity FoundationMini-Training: SSO with Windows Identity Foundation
Mini-Training: SSO with Windows Identity Foundation
 
Training - What is Performance ?
Training  - What is Performance ?Training  - What is Performance ?
Training - What is Performance ?
 
Mini-Training: Docker
Mini-Training: DockerMini-Training: Docker
Mini-Training: Docker
 
Mini-Training: NDepend
Mini-Training: NDependMini-Training: NDepend
Mini-Training: NDepend
 
Management 3.0 Workout
Management 3.0 WorkoutManagement 3.0 Workout
Management 3.0 Workout
 
Lean for Business
Lean for BusinessLean for Business
Lean for Business
 
Training – Going Async
Training – Going AsyncTraining – Going Async
Training – Going Async
 
Mini-Training: Mobile UX Trends
Mini-Training: Mobile UX TrendsMini-Training: Mobile UX Trends
Mini-Training: Mobile UX Trends
 
Training: MVVM Pattern
Training: MVVM PatternTraining: MVVM Pattern
Training: MVVM Pattern
 
Mini-training: Personalization & Recommendation Demystified
Mini-training: Personalization & Recommendation DemystifiedMini-training: Personalization & Recommendation Demystified
Mini-training: Personalization & Recommendation Demystified
 
AngularJS Best Practices
AngularJS Best PracticesAngularJS Best Practices
AngularJS Best Practices
 
Mini-Training: Roslyn
Mini-Training: RoslynMini-Training: Roslyn
Mini-Training: Roslyn
 
Mini-Training: Netflix Simian Army
Mini-Training: Netflix Simian ArmyMini-Training: Netflix Simian Army
Mini-Training: Netflix Simian Army
 
WCF Configuration - The basics
WCF Configuration - The basicsWCF Configuration - The basics
WCF Configuration - The basics
 

Dernier

Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringHironori Washizaki
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Developmentvyaparkranti
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Rob Geurden
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identityteam-WIBU
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf31events.com
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
How To Manage Restaurant Staff -BTRESTRO
How To Manage Restaurant Staff -BTRESTROHow To Manage Restaurant Staff -BTRESTRO
How To Manage Restaurant Staff -BTRESTROmotivationalword821
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 

Dernier (20)

Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Development
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identity
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
How To Manage Restaurant Staff -BTRESTRO
How To Manage Restaurant Staff -BTRESTROHow To Manage Restaurant Staff -BTRESTRO
How To Manage Restaurant Staff -BTRESTRO
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 

Mini-Training: Redis

  • 1. ARE YOU REDIS TO GO ? MAXIME LEMAITRE – 10/04/2014 1
  • 2. > GET agenda > GET introduction > SMEMBERS datatypes > INFO commands > CLIENT LIST > PSUBSCRIBE performance? > LRANGE features 0 3 persitence transaction replication pubsub > ZREVRANGE usecases 0 -1 > SEGFAULT > ? I see Redis definitely more as a flexible tool that as a solution specialized to solve a specific problem: his mixed soul of cache, store, and messaging server shows this very well - Salvatore Sanfilippo (antirez), creator of Redis 2
  • 3. Brief Introduction • Redis is an open source (since March 2009), advanced key-value store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets and sorted sets. • Originally written in order to help address the scaling needs of http://lloogg.com/, a web analytics startup, by Salvatore (antirez) Sanfilippo. • Redis is written in ANSI C and works in most POSIX systems like Linux, *BSD, OS X and Solaris without external dependencies. Redis project does not directly support Windows, however MSOpenTech develops and maintains an Windows port targeting Win64. 3
  • 4. Command Processing http://redis.io/commands • Protocol RESP – clients communicate with the Redis using REdis Serialization Protocol • Simple, Fast & Human readable – Commands are processed in serial in a single thread (like Node.js) • Superfast processing of commands (a few ms, sometimes less) • If you want to use more CPUs, shard your data client-side • Command groups – Request/response – Pipelined: Several requests / responses – Transactions: • Traditional: Several requests processed in order atomically • Check-And-Set: Request(s), data manipulation in client, more requests – Scripts (>v2.6): execute client-defined Lua scripts in the server for more complex actions 4
  • 5. What is a Command ? http://redis.io/commands Command name + parameters > Version > Complexity (really important) > Description > Result/return value > Example > Approx. 160 available commands 5
  • 6. Data Types List Set Sorted Set Hash [A, B, C, D] “A” “B” “C” “D” D C B A A:3 C:1 D:2 B:4 {A, B, C, D} {C:1, D:2, A:3, D:4} “A” “B” “C” “D” field1 field2 field3 field4 {field1:“A”, field2:“B”…} {value:score} {key:value} Basically maps keys to values (Strings), but also contains more advanced data structures here : * New Data Structure since April, 1st : HyperLogLog 6
  • 7. Popular .net clients Many clients for nearly all languages • ActionScript • C / C++ • C# • Clojure • Lisp • Dart • Erlang • Fancy • Go • Haskell • haXe • Io • Java • Lua • Node.js • Objective-C • Perl • PHP • Python • Ruby • Scala • Smalltalk • Tcl 7
  • 8. How fast is Redis ? (note : it’s common a manage millions of keys) Redis includes the redis-benchmark utility that simulates running commands done by N clients at the same time sending M total queries. • Example on Intel(R) Xeon(R) CPU E5520 @ 2.27GHz (without pipelining) Commands are generally processed in a few ms. Network bandwidth and latency usually have a direct impact on the performance. CPU is another very important factor. 8
  • 9. Redis Feature : Persistence http://redis.io/topics/persistence Redis provides a different range of persistence options: RDB, AOF and None. • RDB – Periodic, asynchronous dump to disk – Can be every N changes or every N seconds – Written to file in “dbfilename”.rdb (could be backup elsewhere) – may loss several minutes during a crash • AOF – Copies incoming commands as it happens – Log-based, redo whole steps since startup – Still fast enough, but often limited by disk performance – may loss a few seconds during a crash • None – Keep data only in Memory. 9
  • 10. Redis Feature : Transaction http://redis.io/topics/transactions • Multiple actions can be put into a transaction – execute multiple command in a single step. – Either all of the commands or none are processed • Command MULTI to start transaction – EXEC to execute – DISCARD to discard – WATCH for Optimistic locking • Guarantees: – Executed in the defined order – Atomic (all or nothing) – No isolation – Can use optimistic locking > MULTI OK > INCR pageviews:count QUEUED > EXPIRE pageviews:count 60 QUEUED > SADD pageviews http://google.fr QUEUED > EXPIRE pageviews 60 QUEUED > EXEC 1) (integer) 4660294 2) (integer) 1 3) (integer) 569023 4) (integer) 1 10
  • 11. Redis Feature : Replication http://redis.io/topics/replication • Redis uses classic master / slave replication • Slaves can replicate to other slaves (in a graph-like structure) • Replication does not block the master/slave (async) • Boost scalability & allow redundancy  Scaling performance by using the replicas for intensive read operations.  Making data redundant in multiple locations.  Offloading data persistency costs from the master by delegating it to the slaves > SLAVEOF PAR-REDIS01:6379 > SLAVEOF PAR-REDIS01:6379 > SLAVEOF PAR-REDIS01:6379 11
  • 12. Redis Feature : PubSub http://redis.io/topics/pubsub (my favorite) • A client can subscribe some topics, and when someone publish topic matches the interest (topic), redis send it to it. • Clients can subscribe to channels (eg user:1245) or patterns (eg user:*) • Subscribing is O(1), posting messages is O(n) • Use cases : Think chats, real-time analytics, twitter, … CLIENT 1 > PSUBSCRIBE user:* psubscribe user:* 1 … //wait notification … pmessage user:* user:1000 themessage EMITTER 1 > PUBLISH user:1001 themessage 1 //number of message sent Keyspace Notifications (>2.8) allows client to receive events affecting the Redis data set (commands affecting a given key, expiration, any command processed, …) 2 12
  • 13. Use case #1 : Who’s online ? //cybermaxs has 3 friends > SADD cybermaxs:friends maxs > SADD cybermaxs:friends nicocanicola > SADD cybermaxs:friends oinant //cybermaxs connects > SADD users:online cybermaxs //maxs connects > SADD users:online maxs //oinant connects > SADD users:online oinant Who’s online ? > SMEMBERS users:online Maxs oinant cybermaxs Are cybermaxs’s friends online ? > SINTER users:online cybermaxs:friends maxs oinant Is nicocanicola connected ? > SISMEMBERS users:online nicocanicola 0 How many connected users ? > SCARD users:online 3 13
  • 14. Use case #2 : leaderboard > ZADD leaderboard 1543 cybermaxs > ZADD leaderboard 4564 nicocanicola > ZADD leaderboard 8954 toto > ZADD leaderboard 6164 oinant > ZADD leaderboard 9642 cybermaxs > ZADD leaderboard 4123 toto > ZADD leaderboard 8713 maxs How to get top 3 ? > ZREVRANGE leaderboard 0 2 WITHSCORES cybermaxs 9642 toto 8954 maxs 8713 How to get rank of player X ? > ZREVRANK leaderboard oinant 3 How to get score of player X ? > ZSCORE leaderboard toto 8954 How to add score to player ? > ZINCRBY leaderboard 3000 nicocanicolas 7563 SELECT TOP 10 * FROM leaderboard WHERE ... ORDER BY score DESC ? 14
  • 15. > INCR questions:nextid 1234 //last question id was 1233 > HMSET question:1234 title “Are you Redis to go?" asked_by “cybermaxs“ votes 0 OK //add question to redis > LPUSH questions question:1234 1 //add to list > SADD question:1234:tags redis nosql 2 //add to tags // later upvote by a user > HINCRBY question:1234 votes 1 1 > ZINCRBY tagged:redis 1 question:1 1 Use case #3 : StackExchange Clone Lastest 200 questions for Homepage > LRANGE questions 0 199 question:200 question:199 … Get Votes for a question > HMGET question:1234 votes 2 Get Tags for a question > SMEMBERS question:1234 redis nosql Questions by Tags, Sorted by Votes > ZREVRANGE tagged:redis 0 5 question:1234 question:486 … Subscribe to all changes on a question > SUBSCRIBE __key*question:1234 + Socket.IO /SignalR 15
  • 16. Common uses cases • Cache out-of-process • Duplicate detector • FIFO/LIFO Queue • Priority Queue • Distributed hashmap – e.g. url shortener • UID generator • Game high scores • Geolocation lookup – lat & long -> city • Real-time analytics • Metrics DB • API throttling (rate- limits) • Autocomplete • Twitter • digg / Hacker News • Social activity feed • … 16
  • 17. Who is using Redis ? 17
  • 19. Questions (mine : are you Redis to Go ?) 19
  • 20. References • http://redis.io/ • http://en.wikipedia.org/wiki/Redis • http://try.redis.io/ (online introduction) • http://redis.io/topics/data-types-intro • http://highscalability.com/blog/2011/7/6/11-common-web-use-cases-solved-in- redis.html • http://oldblog.antirez.com/post/take-advantage-of-redis-adding-it-to-your- stack.html • http://mono.servicestack.net/docs/redis-client/designing-nosql-database • http://fr.slideshare.net/dvirsky/kicking-ass-with-redis • http://fr.slideshare.net/noahd1/redis-in-practice 20
  • 21. Find out more • On https://techblog.betclicgroup.com/ 21
  • 22. We want our brands to be easy to use for every gamer around the world. Join us to make that happen. Everything we do reflect our values Come and work in a friendly atmosphere based on trust & cooperation between IT Teams. Learn & Share with us Friday tech trainings, BBL, Meetups, Coding Dojo, Innovation Day & more If you want to contribute to the success of our group, look at all the challenges we offer HERE Want to be part of a great online gambling company? Check out our Carreers account on Stackoverflow 22
  • 23. About Us • Betclic Everest Group, one of the world leaders in online gaming, has a unique portfolio comprising various complementary international brands: Betclic, Everest, bet-at- home.com, Expekt, Monte-Carlo Casino… • Through our brands, Betclic Everest Group places expertise, technological know-how and security at the heart of our strategy to deliver an on-line gaming offer attuned to the passion of our players. We want our brands to be easy to use for every gamer around the world. We’re building our company to make that happen. • Active in 100 countries with more than 12 million customers worldwide, the Group is committed to promoting secure and responsible gaming and is a member of several international professional associations including the EGBA (European Gaming and Betting Association) and the ESSA (European Sports Security Association). 23