SlideShare a Scribd company logo
1 of 26
Download to read offline
Intro to Redis
Itamar Haber @itamarhaber
Evangely Technicalist
Who We Are
Open source. The leading in-memory database platform,
supporting any high performance operational, analytics or
hybrid use case.
The open source home and commercial provider of Redis
Enterprise (Redise
) technology, platform, products & services.
Itamar Haber @itamarhaber, Evangely Technicalist, formerly
Chief Developer Advocate & Chief OSS Education Officerhello I am
● What is Redis (TL;DR fast + simple = fun)
● Core trivia, critical puns, and some concepts
● Time complexity, i.e. Big O notation
● Data modelling in Redis
This session
From the project's website https://redis.io
Redis is an open source (BSD licensed), in-memory data
structure store, used as a database, cache and message
broker. It supports data structures such as strings,
hashes, lists, sets, sorted sets with range queries,
bitmaps, hyperloglogs and geospatial indexes with
radius queries. Redis has built-in replication, Lua
scripting, LRU eviction, transactions and different levels
of on-disk persistence, and provides high availability via
Redis Sentinel and automatic partitioning with Redis
Cluster.
“
1. REmote DIctionary Server
2. / rɛdɪs/, pronounced “red-iss”
3. OSS (BSD3), https://github.com/antirez/redis
4. In-memory, but with optional disk persistence
5. By Salvatore Sanfilippo @antirez circa 27/2/09
6. DSL4ADT: A Domain Specific Language (DSL) for
Abstract Data Types (ADT)
7. Designed for performance and simplicity
Redis is
1. Redis Manifesto: "We're against complexity"
2. RAM is fastest. Period.
3. Written in ANSI-C (also makes it portable)
4. (mostly) single-threaded event loops are fast
5. Data structures are optimized for performance
6. Configuration settings for space/time tradeoffs
7. Probabilistic housekeeping to keep efforts sane
Designed for performance, examples
The equivalent of a schema in other databases.
Essentially a dictionary (lookup table/associative
array/hashmap) storing a value under a key.
"NoSQL" "schema less" model, although:
1. The key-value schema, i.e. a "table" of keys and
their respective values
2. The implicit schema
The keyspace
Data (the values) is only accessible by a key's name.
The key name, and how it is generated by the client
code, becomes an implicit schema.
Put differently: without your keys, getting the data
is impossible (with impossible meaning inefficient).
The implicit schema and the keyness of naming
Redis keys are pairs made of names and values.
The name is unique, and can be any valid Redis
String (binary safe, max size 0.5GB in current
versions).
The value can be any one of Redis' core or module
data types.
Keys: their names and values
Redis is a (software) tcp (usually) server running in a
process called redis-server.
It listens for incoming connections from clients.
To communicate with the Redis server, a client
needs to open a connection and send Redis
commands using the Redis protocol (RESP).
Connecting with Redis
For developing real applications, there are open
source Redis client implementations in most
languages at https://redis.io/clients
For fooling around, automating and rescue
operations redis-cli works very well. It is the
REPL/multitool that ships with Redis (but telnet can
also work).
Redis client libraries
$ redis-cli -h localhost -p 6379 -a pass1
localhost:6379> PING
PONG
localhost:6379> SET foo bar
OK
localhost:6379> GET foo
"bar"
localhost:6379> APPEND foo vaz
(integer) 6
APPEND appends a string to a Redis String.
It is, like all Redis commands, atomic.
Using it also saves on bandwidth in this use case.
A string value isn't opaque to Redis - you can
perform server-side manipulation of the content
using the relevant String commands.
The value of having a type of value
# There is no n
redis> INCR n
(integer) 1
redis> GET n
"1"
redis> INCRBY n 63
(integer) 64
redis> INCRBYFLOAT n -0.21
"63.79"
redis> PUSH list a b c
(integer) 3
redis> LPOP list
"a"
redis> HSET hash f1 v1 f2 v2 f3 v3
(integer) 3
redis> HGET hash f2
"v2"
Every data type/structure provides different
operations: SETting a String and LPOPping from a
List for example.
Structures are optimized (computationally-wise) for
executing their common operations.
Put differently: think twice, and then once more,
before using operations with scary Big Oh notations
Complexity and/or/vs performance
O(something) expresses how complex an operation
is in term of arbitrary logical computational cycles.
That's Redis' "Time complexity".
A constant time operation is denoted by an O(1).
My O(1) and your O(1) are not necessarily the same
in terms of wallclock time of execution.
Don't be scared by Big Oh No(tation)
O(1) - constant time
O(log n) - logarithmic
O(n) - linear
O(n2
) - squared
O(nn
) - exponential
Check this out!
Don't be scared by Big Oh No(tation)
Redis commands,
visualized by complexity
Link to the live version:
http://bit.ly/redis-rib
Redis commands visualized by complexity
The complexity of each operation is known.
Anything besides O(1), is not necessarily bad. Think.
For O(N), if N's maximal values is small enough, say
5, that's close enough to be considered constant.
Sometimes even 20, 100 or 500 can be considered
as such.
However, if N is four billion (2^32-1)...
Key moment - pay attention, please.
# Imagine a production database
redis> DBSIZE
(integer) 4294967295
redis> EXISTS foo
(integer) 1
redis> LRANGE mylist 0 -1
1) "one"
2) "two"
3) "three"
redis> KEYS *
Warning: you don't
want to do this in prod
We care about complexity because it affects
performance.
Each data structure excels a certain aspects.
To use Redis efficiently, we model the data using
the data structure that fits operations we need.
Put differently: fit the data structure to the
expected "query". Think sideways, it makes sense.
The key to understanding how to model data
The values at keys can be Strings, Lists, Hashes,
Sets, or any other abstract data types.
The language Redis speaks, made up of its many
commands, is used for efficiently manipulating
these structures in useful ways.
The beauty is that it is really simple, once you get
Redis' key values ;)
Simply put, an ultra-fast DSL for ADTs
:

More Related Content

What's hot

Boosting Machine Learning with Redis Modules and Spark
Boosting Machine Learning with Redis Modules and SparkBoosting Machine Learning with Redis Modules and Spark
Boosting Machine Learning with Redis Modules and SparkDvir Volk
 
HornetQ Presentation On JBoss World 2009
HornetQ Presentation On JBoss World 2009HornetQ Presentation On JBoss World 2009
HornetQ Presentation On JBoss World 2009jarfield
 
Type safe, versioned, and rewindable stream processing with Apache {Avro, K...
Type safe, versioned, and rewindable stream processing  with  Apache {Avro, K...Type safe, versioned, and rewindable stream processing  with  Apache {Avro, K...
Type safe, versioned, and rewindable stream processing with Apache {Avro, K...Hisham Mardam-Bey
 
Dynamic pricing of Lyft rides using streaming
Dynamic pricing of Lyft rides using streamingDynamic pricing of Lyft rides using streaming
Dynamic pricing of Lyft rides using streamingAmar Pai
 
Postgres & Redis Sitting in a Tree- Rimas Silkaitis, Heroku
Postgres & Redis Sitting in a Tree- Rimas Silkaitis, HerokuPostgres & Redis Sitting in a Tree- Rimas Silkaitis, Heroku
Postgres & Redis Sitting in a Tree- Rimas Silkaitis, HerokuRedis Labs
 
Redis cluster
Redis clusterRedis cluster
Redis clusteriammutex
 
Gsummit apis-2013
Gsummit apis-2013Gsummit apis-2013
Gsummit apis-2013Gluster.org
 
HBaseCon2017 gohbase: Pure Go HBase Client
HBaseCon2017 gohbase: Pure Go HBase ClientHBaseCon2017 gohbase: Pure Go HBase Client
HBaseCon2017 gohbase: Pure Go HBase ClientHBaseCon
 
Java features. Java 8, 9, 10, 11
Java features. Java 8, 9, 10, 11Java features. Java 8, 9, 10, 11
Java features. Java 8, 9, 10, 11Ivelin Yanev
 
Managing terabytes: When Postgres gets big
Managing terabytes: When Postgres gets bigManaging terabytes: When Postgres gets big
Managing terabytes: When Postgres gets bigSelena Deckelmann
 
Python Streaming Pipelines on Flink - Beam Meetup at Lyft 2019
Python Streaming Pipelines on Flink - Beam Meetup at Lyft 2019Python Streaming Pipelines on Flink - Beam Meetup at Lyft 2019
Python Streaming Pipelines on Flink - Beam Meetup at Lyft 2019Thomas Weise
 
Distributed Postgres
Distributed PostgresDistributed Postgres
Distributed PostgresStas Kelvich
 
Dive into Fluentd plugin v0.12
Dive into Fluentd plugin v0.12Dive into Fluentd plugin v0.12
Dive into Fluentd plugin v0.12N Masahiro
 
Everything I Ever Learned About JVM Performance Tuning @Twitter
Everything I Ever Learned About JVM Performance Tuning @TwitterEverything I Ever Learned About JVM Performance Tuning @Twitter
Everything I Ever Learned About JVM Performance Tuning @TwitterAttila Szegedi
 
Streaming your Lyft Ride Prices - Flink Forward SF 2019
Streaming your Lyft Ride Prices - Flink Forward SF 2019Streaming your Lyft Ride Prices - Flink Forward SF 2019
Streaming your Lyft Ride Prices - Flink Forward SF 2019Thomas Weise
 
Kafka Summit SF 2017 - Shopify Flash Sales with Apache Kafka
Kafka Summit SF 2017 - Shopify Flash Sales with Apache KafkaKafka Summit SF 2017 - Shopify Flash Sales with Apache Kafka
Kafka Summit SF 2017 - Shopify Flash Sales with Apache Kafkaconfluent
 

What's hot (20)

Boosting Machine Learning with Redis Modules and Spark
Boosting Machine Learning with Redis Modules and SparkBoosting Machine Learning with Redis Modules and Spark
Boosting Machine Learning with Redis Modules and Spark
 
Level DB - Quick Cheat Sheet
Level DB - Quick Cheat SheetLevel DB - Quick Cheat Sheet
Level DB - Quick Cheat Sheet
 
Postgres clusters
Postgres clustersPostgres clusters
Postgres clusters
 
HornetQ Presentation On JBoss World 2009
HornetQ Presentation On JBoss World 2009HornetQ Presentation On JBoss World 2009
HornetQ Presentation On JBoss World 2009
 
The basics of fluentd
The basics of fluentdThe basics of fluentd
The basics of fluentd
 
Type safe, versioned, and rewindable stream processing with Apache {Avro, K...
Type safe, versioned, and rewindable stream processing  with  Apache {Avro, K...Type safe, versioned, and rewindable stream processing  with  Apache {Avro, K...
Type safe, versioned, and rewindable stream processing with Apache {Avro, K...
 
Dynamic pricing of Lyft rides using streaming
Dynamic pricing of Lyft rides using streamingDynamic pricing of Lyft rides using streaming
Dynamic pricing of Lyft rides using streaming
 
Postgres & Redis Sitting in a Tree- Rimas Silkaitis, Heroku
Postgres & Redis Sitting in a Tree- Rimas Silkaitis, HerokuPostgres & Redis Sitting in a Tree- Rimas Silkaitis, Heroku
Postgres & Redis Sitting in a Tree- Rimas Silkaitis, Heroku
 
Redis cluster
Redis clusterRedis cluster
Redis cluster
 
Gsummit apis-2013
Gsummit apis-2013Gsummit apis-2013
Gsummit apis-2013
 
9.4json
9.4json9.4json
9.4json
 
HBaseCon2017 gohbase: Pure Go HBase Client
HBaseCon2017 gohbase: Pure Go HBase ClientHBaseCon2017 gohbase: Pure Go HBase Client
HBaseCon2017 gohbase: Pure Go HBase Client
 
Java features. Java 8, 9, 10, 11
Java features. Java 8, 9, 10, 11Java features. Java 8, 9, 10, 11
Java features. Java 8, 9, 10, 11
 
Managing terabytes: When Postgres gets big
Managing terabytes: When Postgres gets bigManaging terabytes: When Postgres gets big
Managing terabytes: When Postgres gets big
 
Python Streaming Pipelines on Flink - Beam Meetup at Lyft 2019
Python Streaming Pipelines on Flink - Beam Meetup at Lyft 2019Python Streaming Pipelines on Flink - Beam Meetup at Lyft 2019
Python Streaming Pipelines on Flink - Beam Meetup at Lyft 2019
 
Distributed Postgres
Distributed PostgresDistributed Postgres
Distributed Postgres
 
Dive into Fluentd plugin v0.12
Dive into Fluentd plugin v0.12Dive into Fluentd plugin v0.12
Dive into Fluentd plugin v0.12
 
Everything I Ever Learned About JVM Performance Tuning @Twitter
Everything I Ever Learned About JVM Performance Tuning @TwitterEverything I Ever Learned About JVM Performance Tuning @Twitter
Everything I Ever Learned About JVM Performance Tuning @Twitter
 
Streaming your Lyft Ride Prices - Flink Forward SF 2019
Streaming your Lyft Ride Prices - Flink Forward SF 2019Streaming your Lyft Ride Prices - Flink Forward SF 2019
Streaming your Lyft Ride Prices - Flink Forward SF 2019
 
Kafka Summit SF 2017 - Shopify Flash Sales with Apache Kafka
Kafka Summit SF 2017 - Shopify Flash Sales with Apache KafkaKafka Summit SF 2017 - Shopify Flash Sales with Apache Kafka
Kafka Summit SF 2017 - Shopify Flash Sales with Apache Kafka
 

Similar to Intro to Redis

Fun with Ruby and Redis
Fun with Ruby and RedisFun with Ruby and Redis
Fun with Ruby and Redisjavier ramirez
 
Redis Modules - Redis India Tour - 2017
Redis Modules - Redis India Tour - 2017Redis Modules - Redis India Tour - 2017
Redis Modules - Redis India Tour - 2017HashedIn Technologies
 
Spark Summit EU talk by Shay Nativ and Dvir Volk
Spark Summit EU talk by Shay Nativ and Dvir VolkSpark Summit EU talk by Shay Nativ and Dvir Volk
Spark Summit EU talk by Shay Nativ and Dvir VolkSpark Summit
 
Redis Use Patterns (DevconTLV June 2014)
Redis Use Patterns (DevconTLV June 2014)Redis Use Patterns (DevconTLV June 2014)
Redis Use Patterns (DevconTLV June 2014)Itamar Haber
 
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
 
Redispresentation apac2012
Redispresentation apac2012Redispresentation apac2012
Redispresentation apac2012Ankur Gupta
 
Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to RedisArnab Mitra
 
Cost Savings at High Performance with Redis Labs and AWS
Cost Savings at High Performance with Redis Labs and AWSCost Savings at High Performance with Redis Labs and AWS
Cost Savings at High Performance with Redis Labs and AWSAmazon Web Services
 
New York REDIS Meetup Welcome Session
New York REDIS Meetup Welcome SessionNew York REDIS Meetup Welcome Session
New York REDIS Meetup Welcome SessionAleksandr Yampolskiy
 
mar07-redis.pdf
mar07-redis.pdfmar07-redis.pdf
mar07-redis.pdfAnisSalhi3
 
Etu L2 Training - Hadoop 企業應用實作
Etu L2 Training - Hadoop 企業應用實作Etu L2 Training - Hadoop 企業應用實作
Etu L2 Training - Hadoop 企業應用實作James Chen
 
Redis Indices (#RedisTLV)
Redis Indices (#RedisTLV)Redis Indices (#RedisTLV)
Redis Indices (#RedisTLV)Itamar Haber
 
Redis for Security Data : SecurityScorecard JVM Redis Usage
Redis for Security Data : SecurityScorecard JVM Redis UsageRedis for Security Data : SecurityScorecard JVM Redis Usage
Redis for Security Data : SecurityScorecard JVM Redis UsageTimothy Spann
 
Introduction to redis
Introduction to redisIntroduction to redis
Introduction to redisTanu Siwag
 
Extend Redis with Modules
Extend Redis with ModulesExtend Redis with Modules
Extend Redis with ModulesItamar Haber
 

Similar to Intro to Redis (20)

Fun with Ruby and Redis
Fun with Ruby and RedisFun with Ruby and Redis
Fun with Ruby and Redis
 
Redis Modules - Redis India Tour - 2017
Redis Modules - Redis India Tour - 2017Redis Modules - Redis India Tour - 2017
Redis Modules - Redis India Tour - 2017
 
Redis introduction
Redis introductionRedis introduction
Redis introduction
 
Redis and Ohm
Redis and OhmRedis and Ohm
Redis and Ohm
 
Redis overview
Redis overviewRedis overview
Redis overview
 
Spark Summit EU talk by Shay Nativ and Dvir Volk
Spark Summit EU talk by Shay Nativ and Dvir VolkSpark Summit EU talk by Shay Nativ and Dvir Volk
Spark Summit EU talk by Shay Nativ and Dvir Volk
 
Introduction to redis
Introduction to redisIntroduction to redis
Introduction to redis
 
Redis Use Patterns (DevconTLV June 2014)
Redis Use Patterns (DevconTLV June 2014)Redis Use Patterns (DevconTLV June 2014)
Redis Use Patterns (DevconTLV June 2014)
 
Developing a Redis Module - Hackathon Kickoff
 Developing a Redis Module - Hackathon Kickoff Developing a Redis Module - Hackathon Kickoff
Developing a Redis Module - Hackathon Kickoff
 
Redispresentation apac2012
Redispresentation apac2012Redispresentation apac2012
Redispresentation apac2012
 
Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to Redis
 
Cost Savings at High Performance with Redis Labs and AWS
Cost Savings at High Performance with Redis Labs and AWSCost Savings at High Performance with Redis Labs and AWS
Cost Savings at High Performance with Redis Labs and AWS
 
New York REDIS Meetup Welcome Session
New York REDIS Meetup Welcome SessionNew York REDIS Meetup Welcome Session
New York REDIS Meetup Welcome Session
 
mar07-redis.pdf
mar07-redis.pdfmar07-redis.pdf
mar07-redis.pdf
 
Etu L2 Training - Hadoop 企業應用實作
Etu L2 Training - Hadoop 企業應用實作Etu L2 Training - Hadoop 企業應用實作
Etu L2 Training - Hadoop 企業應用實作
 
Redis Indices (#RedisTLV)
Redis Indices (#RedisTLV)Redis Indices (#RedisTLV)
Redis Indices (#RedisTLV)
 
Redis for Security Data : SecurityScorecard JVM Redis Usage
Redis for Security Data : SecurityScorecard JVM Redis UsageRedis for Security Data : SecurityScorecard JVM Redis Usage
Redis for Security Data : SecurityScorecard JVM Redis Usage
 
Introduction to redis
Introduction to redisIntroduction to redis
Introduction to redis
 
Extend Redis with Modules
Extend Redis with ModulesExtend Redis with Modules
Extend Redis with Modules
 
Redis overview
Redis overviewRedis overview
Redis overview
 

More from Itamar Haber

How I Implemented the #1 Requested Feature In Redis In Less than 1 Hour with ...
How I Implemented the #1 Requested Feature In Redis In Less than 1 Hour with ...How I Implemented the #1 Requested Feature In Redis In Less than 1 Hour with ...
How I Implemented the #1 Requested Feature In Redis In Less than 1 Hour with ...Itamar Haber
 
Redis Streams - Fiverr Tech5 meetup
Redis Streams - Fiverr Tech5 meetupRedis Streams - Fiverr Tech5 meetup
Redis Streams - Fiverr Tech5 meetupItamar Haber
 
Leveraging Probabilistic Data Structures for Real Time Analytics with Redis M...
Leveraging Probabilistic Data Structures for Real Time Analytics with Redis M...Leveraging Probabilistic Data Structures for Real Time Analytics with Redis M...
Leveraging Probabilistic Data Structures for Real Time Analytics with Redis M...Itamar Haber
 
Power to the People: Redis Lua Scripts
Power to the People: Redis Lua ScriptsPower to the People: Redis Lua Scripts
Power to the People: Redis Lua ScriptsItamar Haber
 
What's new in Redis v3.2
What's new in Redis v3.2What's new in Redis v3.2
What's new in Redis v3.2Itamar Haber
 
Redis Developers Day 2015 - Secondary Indexes and State of Lua
Redis Developers Day 2015 - Secondary Indexes and State of LuaRedis Developers Day 2015 - Secondary Indexes and State of Lua
Redis Developers Day 2015 - Secondary Indexes and State of LuaItamar Haber
 
Use Redis in Odd and Unusual Ways
Use Redis in Odd and Unusual WaysUse Redis in Odd and Unusual Ways
Use Redis in Odd and Unusual WaysItamar Haber
 
Why Your MongoDB Needs Redis
Why Your MongoDB Needs RedisWhy Your MongoDB Needs Redis
Why Your MongoDB Needs RedisItamar Haber
 
Redis & MongoDB: Stop Big Data Indigestion Before It Starts
Redis & MongoDB: Stop Big Data Indigestion Before It StartsRedis & MongoDB: Stop Big Data Indigestion Before It Starts
Redis & MongoDB: Stop Big Data Indigestion Before It StartsItamar Haber
 
Benchmarking Redis by itself and versus other NoSQL databases
Benchmarking Redis by itself and versus other NoSQL databasesBenchmarking Redis by itself and versus other NoSQL databases
Benchmarking Redis by itself and versus other NoSQL databasesItamar Haber
 

More from Itamar Haber (10)

How I Implemented the #1 Requested Feature In Redis In Less than 1 Hour with ...
How I Implemented the #1 Requested Feature In Redis In Less than 1 Hour with ...How I Implemented the #1 Requested Feature In Redis In Less than 1 Hour with ...
How I Implemented the #1 Requested Feature In Redis In Less than 1 Hour with ...
 
Redis Streams - Fiverr Tech5 meetup
Redis Streams - Fiverr Tech5 meetupRedis Streams - Fiverr Tech5 meetup
Redis Streams - Fiverr Tech5 meetup
 
Leveraging Probabilistic Data Structures for Real Time Analytics with Redis M...
Leveraging Probabilistic Data Structures for Real Time Analytics with Redis M...Leveraging Probabilistic Data Structures for Real Time Analytics with Redis M...
Leveraging Probabilistic Data Structures for Real Time Analytics with Redis M...
 
Power to the People: Redis Lua Scripts
Power to the People: Redis Lua ScriptsPower to the People: Redis Lua Scripts
Power to the People: Redis Lua Scripts
 
What's new in Redis v3.2
What's new in Redis v3.2What's new in Redis v3.2
What's new in Redis v3.2
 
Redis Developers Day 2015 - Secondary Indexes and State of Lua
Redis Developers Day 2015 - Secondary Indexes and State of LuaRedis Developers Day 2015 - Secondary Indexes and State of Lua
Redis Developers Day 2015 - Secondary Indexes and State of Lua
 
Use Redis in Odd and Unusual Ways
Use Redis in Odd and Unusual WaysUse Redis in Odd and Unusual Ways
Use Redis in Odd and Unusual Ways
 
Why Your MongoDB Needs Redis
Why Your MongoDB Needs RedisWhy Your MongoDB Needs Redis
Why Your MongoDB Needs Redis
 
Redis & MongoDB: Stop Big Data Indigestion Before It Starts
Redis & MongoDB: Stop Big Data Indigestion Before It StartsRedis & MongoDB: Stop Big Data Indigestion Before It Starts
Redis & MongoDB: Stop Big Data Indigestion Before It Starts
 
Benchmarking Redis by itself and versus other NoSQL databases
Benchmarking Redis by itself and versus other NoSQL databasesBenchmarking Redis by itself and versus other NoSQL databases
Benchmarking Redis by itself and versus other NoSQL databases
 

Recently uploaded

Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 

Recently uploaded (20)

Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 

Intro to Redis

  • 1. Intro to Redis Itamar Haber @itamarhaber Evangely Technicalist
  • 2. Who We Are Open source. The leading in-memory database platform, supporting any high performance operational, analytics or hybrid use case. The open source home and commercial provider of Redis Enterprise (Redise ) technology, platform, products & services. Itamar Haber @itamarhaber, Evangely Technicalist, formerly Chief Developer Advocate & Chief OSS Education Officerhello I am
  • 3. ● What is Redis (TL;DR fast + simple = fun) ● Core trivia, critical puns, and some concepts ● Time complexity, i.e. Big O notation ● Data modelling in Redis This session
  • 4.
  • 5. From the project's website https://redis.io Redis is an open source (BSD licensed), in-memory data structure store, used as a database, cache and message broker. It supports data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs and geospatial indexes with radius queries. Redis has built-in replication, Lua scripting, LRU eviction, transactions and different levels of on-disk persistence, and provides high availability via Redis Sentinel and automatic partitioning with Redis Cluster. “
  • 6. 1. REmote DIctionary Server 2. / rɛdɪs/, pronounced “red-iss” 3. OSS (BSD3), https://github.com/antirez/redis 4. In-memory, but with optional disk persistence 5. By Salvatore Sanfilippo @antirez circa 27/2/09 6. DSL4ADT: A Domain Specific Language (DSL) for Abstract Data Types (ADT) 7. Designed for performance and simplicity Redis is
  • 7. 1. Redis Manifesto: "We're against complexity" 2. RAM is fastest. Period. 3. Written in ANSI-C (also makes it portable) 4. (mostly) single-threaded event loops are fast 5. Data structures are optimized for performance 6. Configuration settings for space/time tradeoffs 7. Probabilistic housekeeping to keep efforts sane Designed for performance, examples
  • 8. The equivalent of a schema in other databases. Essentially a dictionary (lookup table/associative array/hashmap) storing a value under a key. "NoSQL" "schema less" model, although: 1. The key-value schema, i.e. a "table" of keys and their respective values 2. The implicit schema The keyspace
  • 9. Data (the values) is only accessible by a key's name. The key name, and how it is generated by the client code, becomes an implicit schema. Put differently: without your keys, getting the data is impossible (with impossible meaning inefficient). The implicit schema and the keyness of naming
  • 10. Redis keys are pairs made of names and values. The name is unique, and can be any valid Redis String (binary safe, max size 0.5GB in current versions). The value can be any one of Redis' core or module data types. Keys: their names and values
  • 11. Redis is a (software) tcp (usually) server running in a process called redis-server. It listens for incoming connections from clients. To communicate with the Redis server, a client needs to open a connection and send Redis commands using the Redis protocol (RESP). Connecting with Redis
  • 12. For developing real applications, there are open source Redis client implementations in most languages at https://redis.io/clients For fooling around, automating and rescue operations redis-cli works very well. It is the REPL/multitool that ships with Redis (but telnet can also work). Redis client libraries
  • 13. $ redis-cli -h localhost -p 6379 -a pass1 localhost:6379> PING PONG localhost:6379> SET foo bar OK localhost:6379> GET foo "bar" localhost:6379> APPEND foo vaz (integer) 6
  • 14. APPEND appends a string to a Redis String. It is, like all Redis commands, atomic. Using it also saves on bandwidth in this use case. A string value isn't opaque to Redis - you can perform server-side manipulation of the content using the relevant String commands. The value of having a type of value
  • 15. # There is no n redis> INCR n (integer) 1 redis> GET n "1" redis> INCRBY n 63 (integer) 64 redis> INCRBYFLOAT n -0.21 "63.79"
  • 16. redis> PUSH list a b c (integer) 3 redis> LPOP list "a" redis> HSET hash f1 v1 f2 v2 f3 v3 (integer) 3 redis> HGET hash f2 "v2"
  • 17. Every data type/structure provides different operations: SETting a String and LPOPping from a List for example. Structures are optimized (computationally-wise) for executing their common operations. Put differently: think twice, and then once more, before using operations with scary Big Oh notations Complexity and/or/vs performance
  • 18. O(something) expresses how complex an operation is in term of arbitrary logical computational cycles. That's Redis' "Time complexity". A constant time operation is denoted by an O(1). My O(1) and your O(1) are not necessarily the same in terms of wallclock time of execution. Don't be scared by Big Oh No(tation)
  • 19. O(1) - constant time O(log n) - logarithmic O(n) - linear O(n2 ) - squared O(nn ) - exponential Check this out! Don't be scared by Big Oh No(tation)
  • 20. Redis commands, visualized by complexity Link to the live version: http://bit.ly/redis-rib Redis commands visualized by complexity
  • 21. The complexity of each operation is known. Anything besides O(1), is not necessarily bad. Think. For O(N), if N's maximal values is small enough, say 5, that's close enough to be considered constant. Sometimes even 20, 100 or 500 can be considered as such. However, if N is four billion (2^32-1)... Key moment - pay attention, please.
  • 22. # Imagine a production database redis> DBSIZE (integer) 4294967295 redis> EXISTS foo (integer) 1 redis> LRANGE mylist 0 -1 1) "one" 2) "two" 3) "three" redis> KEYS * Warning: you don't want to do this in prod
  • 23. We care about complexity because it affects performance. Each data structure excels a certain aspects. To use Redis efficiently, we model the data using the data structure that fits operations we need. Put differently: fit the data structure to the expected "query". Think sideways, it makes sense. The key to understanding how to model data
  • 24. The values at keys can be Strings, Lists, Hashes, Sets, or any other abstract data types. The language Redis speaks, made up of its many commands, is used for efficiently manipulating these structures in useful ways. The beauty is that it is really simple, once you get Redis' key values ;) Simply put, an ultra-fast DSL for ADTs
  • 25.
  • 26. :