SlideShare a Scribd company logo
1 of 38
Need
For
Speed ?
1
hello!
I am Nicola Galgano
(alikon)
Real Time Application Management
2
People like
fast sites!
…And so does Google…
Site speed is a
ranking factor
3
Wile E.
Coyote
Needs
Help to
catch
Road
Runner
4
Read and
write data
5
DBMS nowadays
6
James Nicholas "Jim" Gray
“Memory is the
new Disk,
Disk is the new
tape” 7
What is redis ?
REmote DIctionary Server
Open-source, in-memory, persistable
key-value advanced datastore
8
It’s an Open source project
✘Created in 2009
✘ by @antirez
(Salvatore Sanfilippo)
✘https://github.com/antirez
/redis
✘http://redis.io/
9
The redis manifesto
We’re against complexity
the best way to fight complexity
Is, by not creating it at all.
10
is used in
Computer
Science to
describe the
performance of
an algorithm
Big O notation O(n)
describes the
worst case
scenario, used to
describe the
execution time
required 11
Predictable performance
http://bigocheatsheet.com/12
Big O quiz ?
public function isPresent($element, $vector)
{
for ($i = 0; $i < count($vector); $i++)
{
if ($vector[$i] = $element)
{
return true;
}
}
return false;
} 13
understand performance
http://bigocheatsheet.com/14
What is a key-value store
CREATE TABLE redis (
k VARCHAR(512MB) NOT NULL,
v VARCHAR(512MB),
PRIMARY KEY (k)
);
15
Data Structure: strings
used to store 3 types of values:
■ Byte string values
■ Integer values
■ Floating-point values
16
SET & GET
SET tag ’#jab16’
GET tag
String operations
INSERT & SELECT
INSERT INTO redis
(k,v) VALUES
(‘tag’,’#jab16’)
SELECT v FROM redis
WHERE k=‘tag’
17
Basic operations
Increment
INCR vote
INCRBY vote 3
Decrement
DECR vote
DECRBY vote 5
Delete
DEL oldkey
18
Time To Live
Remove expiration
PERSIST key
Expiration
EXPIRE k 60
EXPIREAT k tms
TimeTo Live
TTL key
19
That’s all Folks
20
Who is using redis
… more…. *
21
Caching architecture
Joomla! cache handler
Starting
from
Joomla!
3.4.0
23
Redis:Advanced datastore
24
Redis Data Structures
strings
lists
sets
hashes
sorted
sets
..more..
Key:130468
25
Data Structure: HASHES
✘Using Strings
user:1:name -> wile
user:1:lastname -> coyote
user:1:email -> coyote@acme.com
✘Using Hashes
user:1
id -> 1
name -> wile
lastname -> coyote
email -> coyote@acme.com
Aggregation
Keeping related data together for easy fetching &
updating
Redis in
redis
26
Hashes: use case
Ideal to manage (transient data)
✘ Sessions
✘ Shopping cart
✘ RFC
[New feature] Redis sessions
handler
https://github.com/joomla/jooml
a-cms/pull/7659
Hashes:commands
✘HSET user:1 name Wile
✘HSET user:2 name RoadRunner
✘HMSET user:1 name “wile”
lastname “coyote”
✘HGETALL user:2
✘HGET user:2 email
✘HINCRBY,HEXISTS,HKEYS,HSETNX
✘HSTRLEN,HDEL, ……………
27
https://try.redis.io/
28
Data structure:Lists
✘Is a sequence of ordered strings
✘Up to 2^32 (4 billion) of elements
✘Duplicate possible
✘O(N) - more fast (head/tail)
✘LPUSH mylist “A”
✘RPUSH mylist “Z”
✘RPOP mylist
✘LPOP mylist
✘LINDEX mylist 3
✘LRANGE mylist 4 10
✘LTRIM mylist 0 4
29
LISTS: USE CASE
✘Social network Timeline
✘last user activities, Top n viewed
✘Queques / Stack (LIFO-FIFO)
✘Producer – Consumer
✘Asynchronous job
✘Capped list
30
Data structure:Sets
✘Sets are an unordered collection of
String, similar to Lists but no duplicates
allowed
✘Up to 2^32 (4 billion) of elements
✘SADD myset “G” “A” “N”
✘SCARD myset
✘SISMEMBER myset “C”
✘SREM myset “Z”
✘SUNION
✘SINTER (Algebra of sets)
✘SDIFF
myset
A
B
Z
D
G
N
J
B
Z
31
Sets use case:Relationships
SADD user:1:friends 3 4 5 /* add some friends of user:1 */
SCARD user:1:friends /* How many friends does user:1 have? */
SINTER user:1:friends user:2:friends /* Common friends */
SDIFF user:1:friends user:2:friends /* Exclusive friends */
SUNION user:1:friends user:2:friends /* All the friends */
32
Data structure: Sorted Sets
✘Like sets, sorted sets are composed of unique, string elements
✘every element in a ZSET have a floating point value called the score
✘elements in a sorted sets are taken in order
✘Intersection with ZINTERSTORE union ZUNIONSTORE
✘Uselful l to manage Leaderboard / scoreboard
33
Sorted Sets use case
Key Value Score
Contributor
zero-24 534
andrepereiradasilva 470
wilsonge 403
infograf768 392
mbabker 385
ZADD contributor 534
“zero-24”
ZADD contributor 385
“mbabker”
….
….
ZREVRANGE contributor 0 4 WITHSCORE
TOP 5
JOOMLA
contributor
ZINCRBY
contributor 1
“alikon”
34
ABOUT REDIS KEYS
✘ Very long keys are not a good idea.
✘ Very short keys are often not a good idea.
✘ The maximum allowed key size is 512 MB.
✘ As a convention colon is used (user:1234:followers)
✘ Schema is your keys names so keep them in order.
35
Key-point
✘ Limitation physical memory
✘ Survive crash disk persitence
✘ 160 commands
✘ Single threaded
✘ Replication master-slave
✘ Multilanguage support
36
Further (free) reading
https://redislabs.
com/ebook/redis
-in-action
37
thanks!
Any questions?
You can find me at:
@Alikon
nicolagalgano@yahoo.it
39

More Related Content

Similar to Need 4 speed

Hitbkl 2012
Hitbkl 2012Hitbkl 2012
Hitbkl 2012
F _
 

Similar to Need 4 speed (20)

Apache Flink internals
Apache Flink internalsApache Flink internals
Apache Flink internals
 
Beyond Breakpoints: A Tour of Dynamic Analysis
Beyond Breakpoints: A Tour of Dynamic AnalysisBeyond Breakpoints: A Tour of Dynamic Analysis
Beyond Breakpoints: A Tour of Dynamic Analysis
 
Graph Analytics with ArangoDB
Graph Analytics with ArangoDBGraph Analytics with ArangoDB
Graph Analytics with ArangoDB
 
Hitbkl 2012
Hitbkl 2012Hitbkl 2012
Hitbkl 2012
 
Stripe CTF3 wrap-up
Stripe CTF3 wrap-upStripe CTF3 wrap-up
Stripe CTF3 wrap-up
 
Softshake 2013: Introduction to NoSQL with Couchbase
Softshake 2013: Introduction to NoSQL with CouchbaseSoftshake 2013: Introduction to NoSQL with Couchbase
Softshake 2013: Introduction to NoSQL with Couchbase
 
Handout: 'Open Source Tools & Resources'
Handout: 'Open Source Tools & Resources'Handout: 'Open Source Tools & Resources'
Handout: 'Open Source Tools & Resources'
 
Regex Considered Harmful: Use Rosie Pattern Language Instead
Regex Considered Harmful: Use Rosie Pattern Language InsteadRegex Considered Harmful: Use Rosie Pattern Language Instead
Regex Considered Harmful: Use Rosie Pattern Language Instead
 
How DeepMind Mastered The Game Of Go
How DeepMind Mastered The Game Of GoHow DeepMind Mastered The Game Of Go
How DeepMind Mastered The Game Of Go
 
iSoligorsk #3 2013
iSoligorsk #3 2013iSoligorsk #3 2013
iSoligorsk #3 2013
 
Monitoring Big Data Systems - "The Simple Way"
Monitoring Big Data Systems - "The Simple Way"Monitoring Big Data Systems - "The Simple Way"
Monitoring Big Data Systems - "The Simple Way"
 
Pig latin
Pig latinPig latin
Pig latin
 
Ensuring High Availability for Real-time Analytics featuring Boxed Ice / Serv...
Ensuring High Availability for Real-time Analytics featuring Boxed Ice / Serv...Ensuring High Availability for Real-time Analytics featuring Boxed Ice / Serv...
Ensuring High Availability for Real-time Analytics featuring Boxed Ice / Serv...
 
Rust: Reach Further (from QCon Sao Paolo 2018)
Rust: Reach Further (from QCon Sao Paolo 2018)Rust: Reach Further (from QCon Sao Paolo 2018)
Rust: Reach Further (from QCon Sao Paolo 2018)
 
Graph Database Use Cases - StampedeCon 2015
Graph Database Use Cases - StampedeCon 2015Graph Database Use Cases - StampedeCon 2015
Graph Database Use Cases - StampedeCon 2015
 
Graph database Use Cases
Graph database Use CasesGraph database Use Cases
Graph database Use Cases
 
Perl Memory Use 201207 (OUTDATED, see 201209 )
Perl Memory Use 201207 (OUTDATED, see 201209 )Perl Memory Use 201207 (OUTDATED, see 201209 )
Perl Memory Use 201207 (OUTDATED, see 201209 )
 
Flink internals web
Flink internals web Flink internals web
Flink internals web
 
Application Logging in the 21st century - 2014.key
Application Logging in the 21st century - 2014.keyApplication Logging in the 21st century - 2014.key
Application Logging in the 21st century - 2014.key
 
Scaling PyData Up and Out
Scaling PyData Up and OutScaling PyData Up and Out
Scaling PyData Up and Out
 

Recently uploaded

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Recently uploaded (20)

Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

Need 4 speed