SlideShare a Scribd company logo
Por qué deberías haberle
pedido Redis a los Reyes
Magos

javier ramirez
@supercoco9
In the beginner's
mind there are many
possibilities, in the
expert's mind there
are few.
Shunryu Suzuki
javier ramirez

@supercoco9

https://teowaki.com

madrid rb 2013
myth: the bottleneck

javier ramirez

@supercoco9

https://teowaki.com

madrid rb 2013
Intel(R) Xeon(R) CPU E5520 @ 2.27GHz (with pipelining)
$ ./redis-benchmark -r 1000000 -n 2000000 -t get,set,lpush,lpop -P 16 -q

SET: 552,028 requests per second
GET: 707,463 requests per second
LPUSH: 767,459 requests per second
LPOP: 770,119 requests per second
Intel(R) Xeon(R) CPU E5520 @ 2.27GHz (without pipelining)
$ ./redis-benchmark -r 1000000 -n 2000000 -t get,set,lpush,lpop -q

SET: 122,556 requests per second
GET: 123,601 requests per second
LPUSH: 136,752 requests per second
LPOP: 132,424 requests per second
javier ramirez

@supercoco9

https://teowaki.com

madrid rb 2013
myth: Redis is just like
memcached

javier ramirez

@supercoco9

https://teowaki.com

madrid rb 2013
myth: Redis is for queues

javier ramirez

@supercoco9

https://teowaki.com

madrid rb 2013
open source, BSD licensed, 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.
http://redis.io
started in 2009 by Salvatore Sanfilippo @antirez
103 contributors at

https://github.com/antirez/redis
javier ramirez

@supercoco9

https://teowaki.com

madrid rb 2013
hacker
meets
thinker*
*@janogonzalez and @advi inspired slide
javier ramirez

@supercoco9

https://teowaki.com

madrid rb 2013
The Redis Manifesto

1.A DSL for Abstract Data Types
2.Memory storage is #1

3.Fundamental data structures for a
fundamental API
4.Two levels of API
5.Code is like a poem; it's not just something
we write to reach some practical result
6.We're against complexity
7.We optimize for joy
javier ramirez

@supercoco9

https://teowaki.com

madrid rb 2013
connecting to redis

javier ramirez

@supercoco9

https://teowaki.com

madrid rb 2013
basics: setting and getting

javier ramirez

@supercoco9

https://teowaki.com

madrid rb 2013
basics: lists

javier ramirez

@supercoco9

https://teowaki.com

madrid rb 2013
basics: hashes

javier ramirez

@supercoco9

https://teowaki.com

madrid rb 2013
basics: sets

cool example about sunionstore
http://robots.thoughtbot.com/post/46335890055/redis-set-intersection-using-sets-to-filter-data
javier ramirez

@supercoco9

https://teowaki.com

madrid rb 2013
Redis as a PUBSUB system

javier ramirez

@supercoco9

https://teowaki.com

madrid rb 2013
Redis keeps
everything
in memory
all the time
javier ramirez

@supercoco9

https://teowaki.com

madrid rb 2013
Persistance: RDB
Compact binary format
Saves snapshots every few minutes
Good for backups and synchronizing
If Redis crashes, a few minutes worth of
data will be lost

javier ramirez

@supercoco9

https://teowaki.com

madrid rb 2013
Durability: AOF
Log text format
Configurable durability
Large file, can slow down startup
If Redis crashes, typically one second of
data could be lost

javier ramirez

@supercoco9

https://teowaki.com

madrid rb 2013
replication & scaling out
one master, several
read-only slaves
sharding
Twemproxy & redis cluster
javier ramirez

@supercoco9

https://teowaki.com

madrid rb 2013
atomicity
single threaded, so no
concurrency problems
transactions and lua
scripts to run multiple
operations atomically

javier ramirez

@supercoco9

https://teowaki.com

madrid rb 2013
Scripting with lua
You can use Lua for scripting Redis when you need to
atomically execute a sequence of commands in which
the output of a command is used as input for another
It reduces the need to use complex lock mechanisms
and simplifies dependencies between clients
You can even extend the functionality of Redis by using
Lua scripts

javier ramirez

@supercoco9

https://teowaki.com

madrid rb 2013
what's being used for

javier ramirez

@supercoco9

https://teowaki.com

madrid rb 2013
twitter
Every time line (800 tweets
per user) is on redis
5000 writes per second avg
300K reads per second
javier ramirez

@supercoco9

https://teowaki.com

madrid rb 2013
twitter

write API (from browser or client app)
follo
e per
on

user id

tweet id

wer

fanout (flockDB)

metadata
rpushx to Redis

user info from
gizmoduck
(memcached)

javier ramirez

@supercoco9

tweet info from
tweetypie
(memcached + mysql)

https://teowaki.com

your twitter
timeline

madrid rb 2013
pinterest object graph
from mysql+memcached
to redis
30% save on IOps
javier ramirez

@supercoco9

https://teowaki.com

madrid rb 2013
per user
Redis SortedSet, with timestamp as the score, is used to
store the users followed explicitly.
Redis SortedSet, with timestamp as the score, is used to
store the users followed implicitly
Redis SortedSet, with timestamp as the score, is used to
store the user’s explicit followers
Redis SortedSet, with timestamp as the score, is used to
store the user’s implicit followers
Redis Set is used to store boards followed explicitly
Redis Set is used to store boards unfollowed explicitly
per board
Redis Hash is used to store a board’s explicit followers
Redis Set is used to store a board’s explicit unfollowers
javier ramirez

@supercoco9

https://teowaki.com

madrid rb 2013
viacom
Object dependency graph. Cache on steroids
Redis as a queue for background jobs
Activity tracking and view counts buffering before saving
to mysql
Lua script working on a slave to recalculate ranking and
popularity of contents, then send the data to master.
The new process takes 1/60th less than the old one in
mysql

javier ramirez

@supercoco9

https://teowaki.com

madrid rb 2013
openredis
redis as a service on AWS
serving over 1000
customers with a single
machine
javier ramirez

@supercoco9

https://teowaki.com

madrid rb 2013
when things go wrong

javier ramirez

@supercoco9

https://teowaki.com

madrid rb 2013
the instagram case
moving from redis to
cassandra: 75% savings on
servers
lesson learnt:
know when redis is not appropriate
javier ramirez

@supercoco9

https://teowaki.com

madrid rb 2013
the twilio case
credit card hell

lesson learnt:
know what you are doing.
Don't change config on the fly
javier ramirez

@supercoco9

https://teowaki.com

madrid rb 2013
how teowaki is using redis

javier ramirez

@supercoco9

https://teowaki.com

madrid rb 2013
Abusing sidekiq/resque
keep track of every activity in the system, even if you
don't need them all right now:
- every page view
- every API request
- every time a record is created/updated/deleted
benefits:
- highly decoupled system
- easier to divide into services
- you can add behaviour without changing your app
javier ramirez

@supercoco9

https://teowaki.com

madrid rb 2013
intermediate cache
* As a very fast lightweight storage for analytics data before
sending them to our google bigquery based solution
* As a cache for AR attributes frequently “plucked” or included
and plucked (names, nicknames, guids, delegated or
included model names...)

javier ramirez

@supercoco9

https://teowaki.com

madrid rb 2013
Some of our uses of Lua
Expiring attributes inside a Redis hash
Inserting notifications into a list only if there are not
pending notifications from the same user for the
same scope
Paginating a list by an attribute
Manipulating JSON directly at the Redis layer

javier ramirez

@supercoco9

https://teowaki.com

madrid rb 2013
counters
Atomic counters can be safely invoked concurrently
from anywhere, so you can implement “like”
features, global sequences or usage monitoring
systems in highly concurrent applications for free.
You can share your counters with any other internal
application and still be sure they won't collide.

javier ramirez

@supercoco9

https://teowaki.com

madrid rb 2013
Temporary data
Redis allows us to self expire keys after a time has
passed. You can use this mechanism for a simple
cache
If you operate on a key with expiration time, you
can change its value and still keep the expiration
going. By combining a decrementing counter with
an expiration time, implementing usage quotas is
trivial
Also, you can inspect which keys you have in your
server efficiently using SCAN commands
javier ramirez

@supercoco9

https://teowaki.com

madrid rb 2013
bloom filters
bloom filter: space-efficient probabilistic data
structure that is used to test whether an element is
a member of a set. False positive matches are
possible, but false negatives are not.
Redis bit operations make easy to implement bloom
filters
We are using bloom filters for checking uniqueness
of user names and reserved words without going to
postgresql

javier ramirez

@supercoco9

https://teowaki.com

madrid rb 2013
nginx + lua + redis
apache + mruby + redis
Multiple levels of cache by using Redis on the webserver/
middleware layer
http://wiki.nginx.org/HttpRedis
https://github.com/jodosha/redis-store

javier ramirez

@supercoco9

https://teowaki.com

madrid rb 2013
summarizing
* Redis is more powerful than it seems
* Very fast, easy to use, simple, good documentation
* In-memory data structures, distributed, shared and persisted
* Good as data store, intermediate data store, cache or queue
* Lots of use cases, both in huge and smaller systems

You should probably use it a lot more

javier ramirez

@supercoco9

https://teowaki.com

madrid rb 2013
Find related links at
https://teowaki.com/teams/javier-community/link-categories/redis

¡Gracias!
Javier Ramírez
@supercoco9
madrid rb 2013

More Related Content

Viewers also liked

Los Tres Reyes Magos
Los Tres Reyes MagosLos Tres Reyes Magos
Los Tres Reyes Magosmichelleossa
 
Audience Preference Analysis Concepts
Audience Preference Analysis ConceptsAudience Preference Analysis Concepts
Audience Preference Analysis Concepts
Sean Ammirati
 
The Three Wise Men Ii
The Three Wise Men IiThe Three Wise Men Ii
The Three Wise Men Iimmart101
 
Visita de los reyes magos
Visita de los reyes magosVisita de los reyes magos
Visita de los reyes magos
Diana López
 
Navidad en España
Navidad en EspañaNavidad en España
Navidad en EspañaNoeliaRG
 
Día de Los Reyes Magos
Día de Los Reyes MagosDía de Los Reyes Magos
Día de Los Reyes Magos
Alessandra Amaral
 
Los tres reyes magos primera parte
Los tres reyes magos primera parteLos tres reyes magos primera parte
Los tres reyes magos primera parte
Manuel Benet Keil
 
3 kings day_dia_de_tres_reyes
3 kings day_dia_de_tres_reyes3 kings day_dia_de_tres_reyes
3 kings day_dia_de_tres_reyes
SraCSmith
 
Los 3 reyes magos
Los 3 reyes magosLos 3 reyes magos
Los 3 reyes magosclase6boros
 
Reyes magos
Reyes magosReyes magos
Reyes magos
vihugoo
 
la historia de los 3 reyes magos
la historia de los 3 reyes magosla historia de los 3 reyes magos
la historia de los 3 reyes magos
Karen Ramirez
 
Cuento de los Reyes Magos
Cuento de los Reyes MagosCuento de los Reyes Magos
Cuento de los Reyes Magos
patry00
 
Reyes mago presentacion ppt
Reyes mago presentacion pptReyes mago presentacion ppt
Reyes mago presentacion ppt
kvanko
 
Los tres reyes magos
Los tres reyes magosLos tres reyes magos
Los tres reyes magosleoconperafan
 
La Navidad en Espana
La Navidad en EspanaLa Navidad en Espana
La Navidad en Espana
Lisa Stevens
 
Jhon's pp spanish
Jhon's pp spanishJhon's pp spanish
Jhon's pp spanish
John Hernandez
 
Los Reyes Magos
Los Reyes MagosLos Reyes Magos
Los Reyes MagosAmod1044
 

Viewers also liked (18)

Los Tres Reyes Magos
Los Tres Reyes MagosLos Tres Reyes Magos
Los Tres Reyes Magos
 
Audience Preference Analysis Concepts
Audience Preference Analysis ConceptsAudience Preference Analysis Concepts
Audience Preference Analysis Concepts
 
The Three Wise Men Ii
The Three Wise Men IiThe Three Wise Men Ii
The Three Wise Men Ii
 
Visita de los reyes magos
Visita de los reyes magosVisita de los reyes magos
Visita de los reyes magos
 
Navidad en España
Navidad en EspañaNavidad en España
Navidad en España
 
Día de Los Reyes Magos
Día de Los Reyes MagosDía de Los Reyes Magos
Día de Los Reyes Magos
 
Los tres reyes magos primera parte
Los tres reyes magos primera parteLos tres reyes magos primera parte
Los tres reyes magos primera parte
 
3 kings day_dia_de_tres_reyes
3 kings day_dia_de_tres_reyes3 kings day_dia_de_tres_reyes
3 kings day_dia_de_tres_reyes
 
Los 3 reyes magos
Los 3 reyes magosLos 3 reyes magos
Los 3 reyes magos
 
Reyes magos
Reyes magosReyes magos
Reyes magos
 
la historia de los 3 reyes magos
la historia de los 3 reyes magosla historia de los 3 reyes magos
la historia de los 3 reyes magos
 
Cuento de los Reyes Magos
Cuento de los Reyes MagosCuento de los Reyes Magos
Cuento de los Reyes Magos
 
Reyes mago presentacion ppt
Reyes mago presentacion pptReyes mago presentacion ppt
Reyes mago presentacion ppt
 
Los tres reyes magos
Los tres reyes magosLos tres reyes magos
Los tres reyes magos
 
La Navidad en Espana
La Navidad en EspanaLa Navidad en Espana
La Navidad en Espana
 
Jhon's pp spanish
Jhon's pp spanishJhon's pp spanish
Jhon's pp spanish
 
Priyavathsan S_Resume
Priyavathsan S_ResumePriyavathsan S_Resume
Priyavathsan S_Resume
 
Los Reyes Magos
Los Reyes MagosLos Reyes Magos
Los Reyes Magos
 

Similar to Por que deberias haberle pedido redis a los reyes magos

How you can benefit from using Redis - Ramirez
How you can benefit from using Redis - RamirezHow you can benefit from using Redis - Ramirez
How you can benefit from using Redis - Ramirez
Codemotion
 
Fosdem how you can benefit from redis, javier ramirez @ teowaki
Fosdem how you can benefit from redis, javier ramirez @ teowakiFosdem how you can benefit from redis, javier ramirez @ teowaki
Fosdem how you can benefit from redis, javier ramirez @ teowakijavier ramirez
 
Fun with ruby and redis, arrrrcamp edition, javier_ramirez, teowaki
Fun with ruby and redis, arrrrcamp edition, javier_ramirez, teowakiFun with ruby and redis, arrrrcamp edition, javier_ramirez, teowaki
Fun with ruby and redis, arrrrcamp edition, javier_ramirez, teowaki
javier ramirez
 
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
 
Handling Redis failover with ZooKeeper
Handling Redis failover with ZooKeeperHandling Redis failover with ZooKeeper
Handling Redis failover with ZooKeeperryanlecompte
 
Dok Talks #124 - Intro to Druid on Kubernetes
Dok Talks #124 - Intro to Druid on KubernetesDok Talks #124 - Intro to Druid on Kubernetes
Dok Talks #124 - Intro to Druid on Kubernetes
DoKC
 
DAT202_Getting started with Amazon Aurora
DAT202_Getting started with Amazon AuroraDAT202_Getting started with Amazon Aurora
DAT202_Getting started with Amazon Aurora
Amazon Web Services
 
ElastiCache and Redis
ElastiCache and RedisElastiCache and Redis
ElastiCache and Redis
Amazon Web Services
 
Bigdata for small pockets, by Javier Ramirez from teowaki. RubyC Kiev 2014
Bigdata for small pockets, by Javier Ramirez from teowaki. RubyC Kiev 2014Bigdata for small pockets, by Javier Ramirez from teowaki. RubyC Kiev 2014
Bigdata for small pockets, by Javier Ramirez from teowaki. RubyC Kiev 2014
javier ramirez
 
Amazon ElastiCache and Redis
Amazon ElastiCache and RedisAmazon ElastiCache and Redis
Amazon ElastiCache and Redis
Amazon Web Services
 
api analytics redis bigquery. Lrug
api analytics redis bigquery. Lrugapi analytics redis bigquery. Lrug
api analytics redis bigquery. Lrug
javier ramirez
 
High availability solution database mirroring
High availability solution database mirroringHigh availability solution database mirroring
High availability solution database mirroring
Mustafa EL-Masry
 
Going serverless
Going serverlessGoing serverless
Going serverless
Jeremy Green
 
Cloud Native Applications on OpenShift
Cloud Native Applications on OpenShiftCloud Native Applications on OpenShift
Cloud Native Applications on OpenShift
Serhat Dirik
 
Amazon Elasticache and Redis
Amazon Elasticache and RedisAmazon Elasticache and Redis
Amazon Elasticache and Redis
Mikhail Prudnikov
 
Low latency in java 8 by Peter Lawrey
Low latency in java 8 by Peter Lawrey Low latency in java 8 by Peter Lawrey
Low latency in java 8 by Peter Lawrey
J On The Beach
 
Introduction to redis
Introduction to redisIntroduction to redis
Introduction to redis
NexThoughts Technologies
 
Orcl siebel-sun-s282213-oow2006
Orcl siebel-sun-s282213-oow2006Orcl siebel-sun-s282213-oow2006
Orcl siebel-sun-s282213-oow2006
Sal Marcus
 
Securing Big Data at rest with encryption for Hadoop, Cassandra and MongoDB o...
Securing Big Data at rest with encryption for Hadoop, Cassandra and MongoDB o...Securing Big Data at rest with encryption for Hadoop, Cassandra and MongoDB o...
Securing Big Data at rest with encryption for Hadoop, Cassandra and MongoDB o...
Big Data Spain
 
API Analytics with Redis and Bigquery. NoSQLmatters Cologne '14 edition. Javi...
API Analytics with Redis and Bigquery. NoSQLmatters Cologne '14 edition. Javi...API Analytics with Redis and Bigquery. NoSQLmatters Cologne '14 edition. Javi...
API Analytics with Redis and Bigquery. NoSQLmatters Cologne '14 edition. Javi...
javier ramirez
 

Similar to Por que deberias haberle pedido redis a los reyes magos (20)

How you can benefit from using Redis - Ramirez
How you can benefit from using Redis - RamirezHow you can benefit from using Redis - Ramirez
How you can benefit from using Redis - Ramirez
 
Fosdem how you can benefit from redis, javier ramirez @ teowaki
Fosdem how you can benefit from redis, javier ramirez @ teowakiFosdem how you can benefit from redis, javier ramirez @ teowaki
Fosdem how you can benefit from redis, javier ramirez @ teowaki
 
Fun with ruby and redis, arrrrcamp edition, javier_ramirez, teowaki
Fun with ruby and redis, arrrrcamp edition, javier_ramirez, teowakiFun with ruby and redis, arrrrcamp edition, javier_ramirez, teowaki
Fun with ruby and redis, arrrrcamp edition, javier_ramirez, teowaki
 
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...
 
Handling Redis failover with ZooKeeper
Handling Redis failover with ZooKeeperHandling Redis failover with ZooKeeper
Handling Redis failover with ZooKeeper
 
Dok Talks #124 - Intro to Druid on Kubernetes
Dok Talks #124 - Intro to Druid on KubernetesDok Talks #124 - Intro to Druid on Kubernetes
Dok Talks #124 - Intro to Druid on Kubernetes
 
DAT202_Getting started with Amazon Aurora
DAT202_Getting started with Amazon AuroraDAT202_Getting started with Amazon Aurora
DAT202_Getting started with Amazon Aurora
 
ElastiCache and Redis
ElastiCache and RedisElastiCache and Redis
ElastiCache and Redis
 
Bigdata for small pockets, by Javier Ramirez from teowaki. RubyC Kiev 2014
Bigdata for small pockets, by Javier Ramirez from teowaki. RubyC Kiev 2014Bigdata for small pockets, by Javier Ramirez from teowaki. RubyC Kiev 2014
Bigdata for small pockets, by Javier Ramirez from teowaki. RubyC Kiev 2014
 
Amazon ElastiCache and Redis
Amazon ElastiCache and RedisAmazon ElastiCache and Redis
Amazon ElastiCache and Redis
 
api analytics redis bigquery. Lrug
api analytics redis bigquery. Lrugapi analytics redis bigquery. Lrug
api analytics redis bigquery. Lrug
 
High availability solution database mirroring
High availability solution database mirroringHigh availability solution database mirroring
High availability solution database mirroring
 
Going serverless
Going serverlessGoing serverless
Going serverless
 
Cloud Native Applications on OpenShift
Cloud Native Applications on OpenShiftCloud Native Applications on OpenShift
Cloud Native Applications on OpenShift
 
Amazon Elasticache and Redis
Amazon Elasticache and RedisAmazon Elasticache and Redis
Amazon Elasticache and Redis
 
Low latency in java 8 by Peter Lawrey
Low latency in java 8 by Peter Lawrey Low latency in java 8 by Peter Lawrey
Low latency in java 8 by Peter Lawrey
 
Introduction to redis
Introduction to redisIntroduction to redis
Introduction to redis
 
Orcl siebel-sun-s282213-oow2006
Orcl siebel-sun-s282213-oow2006Orcl siebel-sun-s282213-oow2006
Orcl siebel-sun-s282213-oow2006
 
Securing Big Data at rest with encryption for Hadoop, Cassandra and MongoDB o...
Securing Big Data at rest with encryption for Hadoop, Cassandra and MongoDB o...Securing Big Data at rest with encryption for Hadoop, Cassandra and MongoDB o...
Securing Big Data at rest with encryption for Hadoop, Cassandra and MongoDB o...
 
API Analytics with Redis and Bigquery. NoSQLmatters Cologne '14 edition. Javi...
API Analytics with Redis and Bigquery. NoSQLmatters Cologne '14 edition. Javi...API Analytics with Redis and Bigquery. NoSQLmatters Cologne '14 edition. Javi...
API Analytics with Redis and Bigquery. NoSQLmatters Cologne '14 edition. Javi...
 

More from javier ramirez

The Building Blocks of QuestDB, a Time Series Database
The Building Blocks of QuestDB, a Time Series DatabaseThe Building Blocks of QuestDB, a Time Series Database
The Building Blocks of QuestDB, a Time Series Database
javier ramirez
 
¿Se puede vivir del open source? T3chfest
¿Se puede vivir del open source? T3chfest¿Se puede vivir del open source? T3chfest
¿Se puede vivir del open source? T3chfest
javier ramirez
 
QuestDB: The building blocks of a fast open-source time-series database
QuestDB: The building blocks of a fast open-source time-series databaseQuestDB: The building blocks of a fast open-source time-series database
QuestDB: The building blocks of a fast open-source time-series database
javier ramirez
 
Como creamos QuestDB Cloud, un SaaS basado en Kubernetes alrededor de QuestDB...
Como creamos QuestDB Cloud, un SaaS basado en Kubernetes alrededor de QuestDB...Como creamos QuestDB Cloud, un SaaS basado en Kubernetes alrededor de QuestDB...
Como creamos QuestDB Cloud, un SaaS basado en Kubernetes alrededor de QuestDB...
javier ramirez
 
Ingesting Over Four Million Rows Per Second With QuestDB Timeseries Database ...
Ingesting Over Four Million Rows Per Second With QuestDB Timeseries Database ...Ingesting Over Four Million Rows Per Second With QuestDB Timeseries Database ...
Ingesting Over Four Million Rows Per Second With QuestDB Timeseries Database ...
javier ramirez
 
Deduplicating and analysing time-series data with Apache Beam and QuestDB
Deduplicating and analysing time-series data with Apache Beam and QuestDBDeduplicating and analysing time-series data with Apache Beam and QuestDB
Deduplicating and analysing time-series data with Apache Beam and QuestDB
javier ramirez
 
Your Database Cannot Do this (well)
Your Database Cannot Do this (well)Your Database Cannot Do this (well)
Your Database Cannot Do this (well)
javier ramirez
 
Your Timestamps Deserve Better than a Generic Database
Your Timestamps Deserve Better than a Generic DatabaseYour Timestamps Deserve Better than a Generic Database
Your Timestamps Deserve Better than a Generic Database
javier ramirez
 
Cómo se diseña una base de datos que pueda ingerir más de cuatro millones de ...
Cómo se diseña una base de datos que pueda ingerir más de cuatro millones de ...Cómo se diseña una base de datos que pueda ingerir más de cuatro millones de ...
Cómo se diseña una base de datos que pueda ingerir más de cuatro millones de ...
javier ramirez
 
QuestDB-Community-Call-20220728
QuestDB-Community-Call-20220728QuestDB-Community-Call-20220728
QuestDB-Community-Call-20220728
javier ramirez
 
Processing and analysing streaming data with Python. Pycon Italy 2022
Processing and analysing streaming  data with Python. Pycon Italy 2022Processing and analysing streaming  data with Python. Pycon Italy 2022
Processing and analysing streaming data with Python. Pycon Italy 2022
javier ramirez
 
QuestDB: ingesting a million time series per second on a single instance. Big...
QuestDB: ingesting a million time series per second on a single instance. Big...QuestDB: ingesting a million time series per second on a single instance. Big...
QuestDB: ingesting a million time series per second on a single instance. Big...
javier ramirez
 
Servicios e infraestructura de AWS y la próxima región en Aragón
Servicios e infraestructura de AWS y la próxima región en AragónServicios e infraestructura de AWS y la próxima región en Aragón
Servicios e infraestructura de AWS y la próxima región en Aragón
javier ramirez
 
Primeros pasos en desarrollo serverless
Primeros pasos en desarrollo serverlessPrimeros pasos en desarrollo serverless
Primeros pasos en desarrollo serverless
javier ramirez
 
How AWS is reinventing the cloud
How AWS is reinventing the cloudHow AWS is reinventing the cloud
How AWS is reinventing the cloud
javier ramirez
 
Analitica de datos en tiempo real con Apache Flink y Apache BEAM
Analitica de datos en tiempo real con Apache Flink y Apache BEAMAnalitica de datos en tiempo real con Apache Flink y Apache BEAM
Analitica de datos en tiempo real con Apache Flink y Apache BEAM
javier ramirez
 
Getting started with streaming analytics
Getting started with streaming analyticsGetting started with streaming analytics
Getting started with streaming analytics
javier ramirez
 
Getting started with streaming analytics: Setting up a pipeline
Getting started with streaming analytics: Setting up a pipelineGetting started with streaming analytics: Setting up a pipeline
Getting started with streaming analytics: Setting up a pipeline
javier ramirez
 
Getting started with streaming analytics: Deep Dive
Getting started with streaming analytics: Deep DiveGetting started with streaming analytics: Deep Dive
Getting started with streaming analytics: Deep Dive
javier ramirez
 
Getting started with streaming analytics: streaming basics (1 of 3)
Getting started with streaming analytics: streaming basics (1 of 3)Getting started with streaming analytics: streaming basics (1 of 3)
Getting started with streaming analytics: streaming basics (1 of 3)
javier ramirez
 

More from javier ramirez (20)

The Building Blocks of QuestDB, a Time Series Database
The Building Blocks of QuestDB, a Time Series DatabaseThe Building Blocks of QuestDB, a Time Series Database
The Building Blocks of QuestDB, a Time Series Database
 
¿Se puede vivir del open source? T3chfest
¿Se puede vivir del open source? T3chfest¿Se puede vivir del open source? T3chfest
¿Se puede vivir del open source? T3chfest
 
QuestDB: The building blocks of a fast open-source time-series database
QuestDB: The building blocks of a fast open-source time-series databaseQuestDB: The building blocks of a fast open-source time-series database
QuestDB: The building blocks of a fast open-source time-series database
 
Como creamos QuestDB Cloud, un SaaS basado en Kubernetes alrededor de QuestDB...
Como creamos QuestDB Cloud, un SaaS basado en Kubernetes alrededor de QuestDB...Como creamos QuestDB Cloud, un SaaS basado en Kubernetes alrededor de QuestDB...
Como creamos QuestDB Cloud, un SaaS basado en Kubernetes alrededor de QuestDB...
 
Ingesting Over Four Million Rows Per Second With QuestDB Timeseries Database ...
Ingesting Over Four Million Rows Per Second With QuestDB Timeseries Database ...Ingesting Over Four Million Rows Per Second With QuestDB Timeseries Database ...
Ingesting Over Four Million Rows Per Second With QuestDB Timeseries Database ...
 
Deduplicating and analysing time-series data with Apache Beam and QuestDB
Deduplicating and analysing time-series data with Apache Beam and QuestDBDeduplicating and analysing time-series data with Apache Beam and QuestDB
Deduplicating and analysing time-series data with Apache Beam and QuestDB
 
Your Database Cannot Do this (well)
Your Database Cannot Do this (well)Your Database Cannot Do this (well)
Your Database Cannot Do this (well)
 
Your Timestamps Deserve Better than a Generic Database
Your Timestamps Deserve Better than a Generic DatabaseYour Timestamps Deserve Better than a Generic Database
Your Timestamps Deserve Better than a Generic Database
 
Cómo se diseña una base de datos que pueda ingerir más de cuatro millones de ...
Cómo se diseña una base de datos que pueda ingerir más de cuatro millones de ...Cómo se diseña una base de datos que pueda ingerir más de cuatro millones de ...
Cómo se diseña una base de datos que pueda ingerir más de cuatro millones de ...
 
QuestDB-Community-Call-20220728
QuestDB-Community-Call-20220728QuestDB-Community-Call-20220728
QuestDB-Community-Call-20220728
 
Processing and analysing streaming data with Python. Pycon Italy 2022
Processing and analysing streaming  data with Python. Pycon Italy 2022Processing and analysing streaming  data with Python. Pycon Italy 2022
Processing and analysing streaming data with Python. Pycon Italy 2022
 
QuestDB: ingesting a million time series per second on a single instance. Big...
QuestDB: ingesting a million time series per second on a single instance. Big...QuestDB: ingesting a million time series per second on a single instance. Big...
QuestDB: ingesting a million time series per second on a single instance. Big...
 
Servicios e infraestructura de AWS y la próxima región en Aragón
Servicios e infraestructura de AWS y la próxima región en AragónServicios e infraestructura de AWS y la próxima región en Aragón
Servicios e infraestructura de AWS y la próxima región en Aragón
 
Primeros pasos en desarrollo serverless
Primeros pasos en desarrollo serverlessPrimeros pasos en desarrollo serverless
Primeros pasos en desarrollo serverless
 
How AWS is reinventing the cloud
How AWS is reinventing the cloudHow AWS is reinventing the cloud
How AWS is reinventing the cloud
 
Analitica de datos en tiempo real con Apache Flink y Apache BEAM
Analitica de datos en tiempo real con Apache Flink y Apache BEAMAnalitica de datos en tiempo real con Apache Flink y Apache BEAM
Analitica de datos en tiempo real con Apache Flink y Apache BEAM
 
Getting started with streaming analytics
Getting started with streaming analyticsGetting started with streaming analytics
Getting started with streaming analytics
 
Getting started with streaming analytics: Setting up a pipeline
Getting started with streaming analytics: Setting up a pipelineGetting started with streaming analytics: Setting up a pipeline
Getting started with streaming analytics: Setting up a pipeline
 
Getting started with streaming analytics: Deep Dive
Getting started with streaming analytics: Deep DiveGetting started with streaming analytics: Deep Dive
Getting started with streaming analytics: Deep Dive
 
Getting started with streaming analytics: streaming basics (1 of 3)
Getting started with streaming analytics: streaming basics (1 of 3)Getting started with streaming analytics: streaming basics (1 of 3)
Getting started with streaming analytics: streaming basics (1 of 3)
 

Recently uploaded

Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
Neo4j
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 

Recently uploaded (20)

Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 

Por que deberias haberle pedido redis a los reyes magos

  • 1. Por qué deberías haberle pedido Redis a los Reyes Magos javier ramirez @supercoco9
  • 2.
  • 3. In the beginner's mind there are many possibilities, in the expert's mind there are few. Shunryu Suzuki javier ramirez @supercoco9 https://teowaki.com madrid rb 2013
  • 4. myth: the bottleneck javier ramirez @supercoco9 https://teowaki.com madrid rb 2013
  • 5. Intel(R) Xeon(R) CPU E5520 @ 2.27GHz (with pipelining) $ ./redis-benchmark -r 1000000 -n 2000000 -t get,set,lpush,lpop -P 16 -q SET: 552,028 requests per second GET: 707,463 requests per second LPUSH: 767,459 requests per second LPOP: 770,119 requests per second Intel(R) Xeon(R) CPU E5520 @ 2.27GHz (without pipelining) $ ./redis-benchmark -r 1000000 -n 2000000 -t get,set,lpush,lpop -q SET: 122,556 requests per second GET: 123,601 requests per second LPUSH: 136,752 requests per second LPOP: 132,424 requests per second javier ramirez @supercoco9 https://teowaki.com madrid rb 2013
  • 6. myth: Redis is just like memcached javier ramirez @supercoco9 https://teowaki.com madrid rb 2013
  • 7. myth: Redis is for queues javier ramirez @supercoco9 https://teowaki.com madrid rb 2013
  • 8. open source, BSD licensed, 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. http://redis.io started in 2009 by Salvatore Sanfilippo @antirez 103 contributors at https://github.com/antirez/redis javier ramirez @supercoco9 https://teowaki.com madrid rb 2013
  • 9. hacker meets thinker* *@janogonzalez and @advi inspired slide javier ramirez @supercoco9 https://teowaki.com madrid rb 2013
  • 10. The Redis Manifesto 1.A DSL for Abstract Data Types 2.Memory storage is #1 3.Fundamental data structures for a fundamental API 4.Two levels of API 5.Code is like a poem; it's not just something we write to reach some practical result 6.We're against complexity 7.We optimize for joy javier ramirez @supercoco9 https://teowaki.com madrid rb 2013
  • 11. connecting to redis javier ramirez @supercoco9 https://teowaki.com madrid rb 2013
  • 12. basics: setting and getting javier ramirez @supercoco9 https://teowaki.com madrid rb 2013
  • 15. basics: sets cool example about sunionstore http://robots.thoughtbot.com/post/46335890055/redis-set-intersection-using-sets-to-filter-data javier ramirez @supercoco9 https://teowaki.com madrid rb 2013
  • 16. Redis as a PUBSUB system javier ramirez @supercoco9 https://teowaki.com madrid rb 2013
  • 17. Redis keeps everything in memory all the time javier ramirez @supercoco9 https://teowaki.com madrid rb 2013
  • 18. Persistance: RDB Compact binary format Saves snapshots every few minutes Good for backups and synchronizing If Redis crashes, a few minutes worth of data will be lost javier ramirez @supercoco9 https://teowaki.com madrid rb 2013
  • 19. Durability: AOF Log text format Configurable durability Large file, can slow down startup If Redis crashes, typically one second of data could be lost javier ramirez @supercoco9 https://teowaki.com madrid rb 2013
  • 20. replication & scaling out one master, several read-only slaves sharding Twemproxy & redis cluster javier ramirez @supercoco9 https://teowaki.com madrid rb 2013
  • 21. atomicity single threaded, so no concurrency problems transactions and lua scripts to run multiple operations atomically javier ramirez @supercoco9 https://teowaki.com madrid rb 2013
  • 22. Scripting with lua You can use Lua for scripting Redis when you need to atomically execute a sequence of commands in which the output of a command is used as input for another It reduces the need to use complex lock mechanisms and simplifies dependencies between clients You can even extend the functionality of Redis by using Lua scripts javier ramirez @supercoco9 https://teowaki.com madrid rb 2013
  • 23. what's being used for javier ramirez @supercoco9 https://teowaki.com madrid rb 2013
  • 24. twitter Every time line (800 tweets per user) is on redis 5000 writes per second avg 300K reads per second javier ramirez @supercoco9 https://teowaki.com madrid rb 2013
  • 25. twitter write API (from browser or client app) follo e per on user id tweet id wer fanout (flockDB) metadata rpushx to Redis user info from gizmoduck (memcached) javier ramirez @supercoco9 tweet info from tweetypie (memcached + mysql) https://teowaki.com your twitter timeline madrid rb 2013
  • 26. pinterest object graph from mysql+memcached to redis 30% save on IOps javier ramirez @supercoco9 https://teowaki.com madrid rb 2013
  • 27. per user Redis SortedSet, with timestamp as the score, is used to store the users followed explicitly. Redis SortedSet, with timestamp as the score, is used to store the users followed implicitly Redis SortedSet, with timestamp as the score, is used to store the user’s explicit followers Redis SortedSet, with timestamp as the score, is used to store the user’s implicit followers Redis Set is used to store boards followed explicitly Redis Set is used to store boards unfollowed explicitly per board Redis Hash is used to store a board’s explicit followers Redis Set is used to store a board’s explicit unfollowers javier ramirez @supercoco9 https://teowaki.com madrid rb 2013
  • 28. viacom Object dependency graph. Cache on steroids Redis as a queue for background jobs Activity tracking and view counts buffering before saving to mysql Lua script working on a slave to recalculate ranking and popularity of contents, then send the data to master. The new process takes 1/60th less than the old one in mysql javier ramirez @supercoco9 https://teowaki.com madrid rb 2013
  • 29. openredis redis as a service on AWS serving over 1000 customers with a single machine javier ramirez @supercoco9 https://teowaki.com madrid rb 2013
  • 30. when things go wrong javier ramirez @supercoco9 https://teowaki.com madrid rb 2013
  • 31. the instagram case moving from redis to cassandra: 75% savings on servers lesson learnt: know when redis is not appropriate javier ramirez @supercoco9 https://teowaki.com madrid rb 2013
  • 32. the twilio case credit card hell lesson learnt: know what you are doing. Don't change config on the fly javier ramirez @supercoco9 https://teowaki.com madrid rb 2013
  • 33. how teowaki is using redis javier ramirez @supercoco9 https://teowaki.com madrid rb 2013
  • 34. Abusing sidekiq/resque keep track of every activity in the system, even if you don't need them all right now: - every page view - every API request - every time a record is created/updated/deleted benefits: - highly decoupled system - easier to divide into services - you can add behaviour without changing your app javier ramirez @supercoco9 https://teowaki.com madrid rb 2013
  • 35. intermediate cache * As a very fast lightweight storage for analytics data before sending them to our google bigquery based solution * As a cache for AR attributes frequently “plucked” or included and plucked (names, nicknames, guids, delegated or included model names...) javier ramirez @supercoco9 https://teowaki.com madrid rb 2013
  • 36. Some of our uses of Lua Expiring attributes inside a Redis hash Inserting notifications into a list only if there are not pending notifications from the same user for the same scope Paginating a list by an attribute Manipulating JSON directly at the Redis layer javier ramirez @supercoco9 https://teowaki.com madrid rb 2013
  • 37. counters Atomic counters can be safely invoked concurrently from anywhere, so you can implement “like” features, global sequences or usage monitoring systems in highly concurrent applications for free. You can share your counters with any other internal application and still be sure they won't collide. javier ramirez @supercoco9 https://teowaki.com madrid rb 2013
  • 38. Temporary data Redis allows us to self expire keys after a time has passed. You can use this mechanism for a simple cache If you operate on a key with expiration time, you can change its value and still keep the expiration going. By combining a decrementing counter with an expiration time, implementing usage quotas is trivial Also, you can inspect which keys you have in your server efficiently using SCAN commands javier ramirez @supercoco9 https://teowaki.com madrid rb 2013
  • 39. bloom filters bloom filter: space-efficient probabilistic data structure that is used to test whether an element is a member of a set. False positive matches are possible, but false negatives are not. Redis bit operations make easy to implement bloom filters We are using bloom filters for checking uniqueness of user names and reserved words without going to postgresql javier ramirez @supercoco9 https://teowaki.com madrid rb 2013
  • 40. nginx + lua + redis apache + mruby + redis Multiple levels of cache by using Redis on the webserver/ middleware layer http://wiki.nginx.org/HttpRedis https://github.com/jodosha/redis-store javier ramirez @supercoco9 https://teowaki.com madrid rb 2013
  • 41. summarizing * Redis is more powerful than it seems * Very fast, easy to use, simple, good documentation * In-memory data structures, distributed, shared and persisted * Good as data store, intermediate data store, cache or queue * Lots of use cases, both in huge and smaller systems You should probably use it a lot more javier ramirez @supercoco9 https://teowaki.com madrid rb 2013
  • 42. Find related links at https://teowaki.com/teams/javier-community/link-categories/redis ¡Gracias! Javier Ramírez @supercoco9 madrid rb 2013