Redis

Post on 25-May-2015

505 views 0 download

Tags:

description

Presentación de Redis en los cursos de verano del e-ghost de 2012.

Transcript of Redis

RedisCursillos de verano del e-ghost 2012

Pablo Orduna y Aitor Gomez-Goiri{pablo.orduna,aitor.gomez}@deusto.es

18 y 19 de Julio de 2012

Outline

Introduccion

Instalacion

Ejercicios

Redis 2 / 37

Outline

Introduccion

Instalacion

Ejercicios

Redis 2 / 37

Outline

Introduccion

Instalacion

Ejercicios

Redis 2 / 37

Outline

Introduccion

Instalacion

Ejercicios

Redis Introduccion 3 / 37

¿Que es Redis?

Remote dictionary server

Redis Introduccion 4 / 37

¿Que es Redis?

...mixed soul of cache,

store, and messagingserver...

Salvatore Sanfilippo

(data structure server, advanced key-value store, etc.)

Redis Introduccion 6 / 37

¿Que es Redis?

...mixed soul of cache, store,

and messagingserver...

Salvatore Sanfilippo

(data structure server, advanced key-value store, etc.)

Redis Introduccion 6 / 37

¿Que es Redis?

...mixed soul of cache, store, and messagingserver...

Salvatore Sanfilippo

(data structure server, advanced key-value store, etc.)

Redis Introduccion 6 / 37

¿Que es Redis?

...mixed soul of cache, store, and messagingserver...

Salvatore Sanfilippo

(data structure server, advanced key-value store, etc.)

Redis Introduccion 6 / 37

Caracterısticas

Redis Introduccion 7 / 37

Caracterısticas

Redis Introduccion 8 / 37

Caracterısticas

Redis Introduccion 9 / 37

Caracterısticas

Redis Introduccion 10 / 37

Caracterısticas

Redis Introduccion 11 / 37

Caracterısticas

Redis Introduccion 12 / 37

Caracterısticas

Redis Introduccion 13 / 37

Caracterısticas

Redis Introduccion 14 / 37

Velocidad

Redis Introduccion 16 / 37

Velocidad y transacciones

I Con el grafico anterior. . .

Sistema Velocidad Transaccional Concurrente RedMySQL (InnoDB) No Sı Sı SıMySQL (MyISAM) No No Sı SıMySQL (Memory) No No Sı Sısqlite (Memory) Sı Sı No No

sqlite (disco) Sı Sı No Noredis Sı Sı Sı Sı

Redis Introduccion 18 / 37

Velocidad

Redis Introduccion 19 / 37

Ejemplo practico: WebLab-Deusto

I WebLab-Deusto: software de la Universidad de Deusto quegestiona acceso a laboratorios fısicos de la misma.

I Regularmente en clase → hasta 60 usuarios concurrentesI Este ano → varios cientos de usuarios concurrentes

Redis Introduccion 20 / 37

Gestion de colas: MySQL I(1 recurso, 150 estudiantes)

Redis Introduccion 21 / 37

Gestion de colas: redis I(1 recurso, 150 estudiantes)

Redis Introduccion 22 / 37

Gestion de colas: MySQL II(80 recursos, 150 estudiantes)

Redis Introduccion 23 / 37

Gestion de colas: redis II(80 recursos, 150 estudiantes)

Redis Introduccion 24 / 37

Outline

Introduccion

Instalacion

Ejercicios

Redis Instalacion 25 / 37

Instalacion

I apt-get install redis-server python-redisI U otra librerıa para crear clientes en el lenguaje que

prefirais...I (en java Jedis)

Redis Instalacion 26 / 37

Outline

Introduccion

Instalacion

Ejercicios

Redis Ejercicios 27 / 37

Caso general

Aplicacion de chat

Redis Ejercicios 29 / 37

Ejercicio 0: Operaciones basicas

I StringsI Comandos: setex, setnx, incr...I Usos:

I usuarios onlineI contadoresI API rate limitingI ids unicos

Redis Ejercicios 30 / 37

Ejercicio 1: Amigos online

I SetsI Comandos: sadd, smembers, sinter. . .I Usos:

I eleccion aleatoria de noticias, etc.I modelar relaciones (followers, following, etc.)I amigos online

Redis Ejercicios 31 / 37

Ejercicio 2: propiedades de amigos

I HashesI Comandos: hset, hget, hvals. . .I Usos:

I almacenamiento de datos estructurados

Redis Ejercicios 32 / 37

Ejercicio 3: chatear

I Publicacion/subscripcionI Comandos: subscribe, publish. . .I Usos:

I Envıo de mensajes N a M

Redis Ejercicios 33 / 37

Ejercicio 4: gestion del tiempo

I PipelinesI Comandos: multi, exec. . .I Usos:

I Envıo de varios comandos en uno

Redis Ejercicios 34 / 37

Bibliografıa I

Sunil Arora.Redis and python.http://www.slideshare.net/sunilar0ra/

redis-and-python-at-pycon2011, September 2011.

Noah Davis and Luke Melia.Redis in practice wiki.http://www.slideshare.net/noahd1/redis-in-practice,December 2010.

Tim Lossen.Redis, memory as the new disk.http://www.slideshare.net/tim.lossen.de/

redis-memory-as-the-new-disk, April 2010.

Redis Bibliografia 35 / 37

Bibliografıa II

Karl Seguin.The Little Redis Book.January 2012.

Redis Bibliografia 36 / 37