SlideShare una empresa de Scribd logo
1 de 43
Descargar para leer sin conexión
Redis
Cursillos 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




      Redis    2 / 37
Outline



          ´
Introduccion

         ´
Instalacion




      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,




   Redis                            ´
                          Introduccion   6 / 37
´
¿Que es Redis?



     ...mixed soul of cache, store,




   Redis                             ´
                           Introduccion   6 / 37
´
¿Que es Redis?



     ...mixed soul of cache, store, and messaging
  server...
                                        Salvatore Sanfilippo




   Redis                           ´
                         Introduccion                 6 / 37
´
¿Que es Redis?



     ...mixed soul of cache, store, and messaging
  server...
                                                  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
+ info
Velocidad




    Redis             ´
            Introduccion   16 / 37
Velocidad y transacciones



            ´
   Con el grafico anterior. . .

         Sistema       Velocidad      Transaccional   Concurrente     Red
    MySQL (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          No
           redis           S´
                            ı              S´ı            S´
                                                           ı           S´
                                                                        ı




    Redis                                    ´
                                   Introduccion                     18 / 37
Velocidad




    Redis             ´
            Introduccion   19 / 37
´
Ejemplo practico: WebLab-Deusto




  WebLab-Deusto: software de la Universidad de Deusto que
  gestiona acceso a laboratorios f´sicos de la misma.
                                  ı
        Regularmente en clase → hasta 60 usuarios concurrentes
        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




   apt-get install redis-server python-redis
   U otra librer´a para crear clientes en el lenguaje que
                ı
        ´
   prefirais...
        (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




   Strings
   Comandos: setex, setnx, incr...
   Usos:
        usuarios online
        contadores
        API rate limiting
        ids unicos




    Redis                   Ejercicios   30 / 37
Ejercicio 1: Amigos online




   Sets
   Comandos: sadd, smembers, sinter. . .
   Usos:
              ´
        eleccion aleatoria de noticias, etc.
        modelar relaciones (followers, following, etc.)
        amigos online




    Redis                       Ejercicios                31 / 37
Ejercicio 2: propiedades de amigos




   Hashes
   Comandos: hset, hget, hvals. . .
   Usos:
        almacenamiento de datos estructurados




    Redis                    Ejercicios         32 / 37
Ejercicio 3: chatear




            ´            ´
   Publicacion/subscripcion
   Comandos: subscribe, publish. . .
   Usos:
        Env´o de mensajes N a M
           ı




    Redis                     Ejercicios   33 / 37
´
Ejercicio 4: gestion del tiempo




   Pipelines
   Comandos: multi, exec. . .
   Usos:
        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
´
     Todas las imagenes son propiedad de sus
                     ˜
   respectivos duenos*, el resto del contenido
   ´
esta licenciado bajo Creative Commons by-sa 3.0.




  * Andreas, srippon, Andrew Fitzsimon, jfmelero, liftarn, shokunin,
  mcol, djmx1, MongoDB, Riak, Cassandra, Redis, Membase, HBase,
  neo4j y CouchDB.

Más contenido relacionado

La actualidad más candente

exception handling in java.ppt
exception handling in java.pptexception handling in java.ppt
exception handling in java.pptVarshini62
 
Php Using Arrays
Php Using ArraysPhp Using Arrays
Php Using Arraysmussawir20
 
Retrofit library for android
Retrofit library for androidRetrofit library for android
Retrofit library for androidInnovationM
 
Public Key Algorithms
Public Key AlgorithmsPublic Key Algorithms
Public Key AlgorithmsBit Hacker
 
Konsep Routing dalam Laravel (Pemrograman Web II)
Konsep Routing dalam Laravel (Pemrograman Web II)Konsep Routing dalam Laravel (Pemrograman Web II)
Konsep Routing dalam Laravel (Pemrograman Web II)I Gede Iwan Sudipa
 
Spring - Part 2 - Autowiring, Annotations, Java based Configuration - slides
Spring - Part 2 - Autowiring, Annotations, Java based Configuration - slidesSpring - Part 2 - Autowiring, Annotations, Java based Configuration - slides
Spring - Part 2 - Autowiring, Annotations, Java based Configuration - slidesHitesh-Java
 
Dynamic Components using Single-Page-Application Concepts in AEM/CQ
Dynamic Components using Single-Page-Application Concepts in AEM/CQDynamic Components using Single-Page-Application Concepts in AEM/CQ
Dynamic Components using Single-Page-Application Concepts in AEM/CQNetcetera
 
SOLID Design Principles
SOLID Design PrinciplesSOLID Design Principles
SOLID Design PrinciplesAndreas Enbohm
 
A1 - Sql Injection na Prática Parte 01
A1 - Sql Injection na Prática Parte 01A1 - Sql Injection na Prática Parte 01
A1 - Sql Injection na Prática Parte 01Reinaldo Junior
 
Java Server Pages(jsp)
Java Server Pages(jsp)Java Server Pages(jsp)
Java Server Pages(jsp)Manisha Keim
 
Screen orientations in android
Screen orientations in androidScreen orientations in android
Screen orientations in androidmanjakannar
 
Exception Handling in VB.Net
Exception Handling in VB.NetException Handling in VB.Net
Exception Handling in VB.Netrishisingh190
 
Servlet.ppt
Servlet.pptServlet.ppt
Servlet.pptVMahesh5
 

La actualidad más candente (20)

Clean coding-practices
Clean coding-practicesClean coding-practices
Clean coding-practices
 
exception handling in java.ppt
exception handling in java.pptexception handling in java.ppt
exception handling in java.ppt
 
Introdução a php
Introdução a phpIntrodução a php
Introdução a php
 
Php Using Arrays
Php Using ArraysPhp Using Arrays
Php Using Arrays
 
Historia de java script
Historia de java scriptHistoria de java script
Historia de java script
 
Aula 07 - Visualg e Pseudocódigo
Aula 07 - Visualg e PseudocódigoAula 07 - Visualg e Pseudocódigo
Aula 07 - Visualg e Pseudocódigo
 
Retrofit library for android
Retrofit library for androidRetrofit library for android
Retrofit library for android
 
Public Key Algorithms
Public Key AlgorithmsPublic Key Algorithms
Public Key Algorithms
 
Construcao de Algoritmos - Aula 05
Construcao de Algoritmos - Aula 05Construcao de Algoritmos - Aula 05
Construcao de Algoritmos - Aula 05
 
Linguagem C - Vetores
Linguagem C - VetoresLinguagem C - Vetores
Linguagem C - Vetores
 
Konsep Routing dalam Laravel (Pemrograman Web II)
Konsep Routing dalam Laravel (Pemrograman Web II)Konsep Routing dalam Laravel (Pemrograman Web II)
Konsep Routing dalam Laravel (Pemrograman Web II)
 
Spring - Part 2 - Autowiring, Annotations, Java based Configuration - slides
Spring - Part 2 - Autowiring, Annotations, Java based Configuration - slidesSpring - Part 2 - Autowiring, Annotations, Java based Configuration - slides
Spring - Part 2 - Autowiring, Annotations, Java based Configuration - slides
 
Dynamic Components using Single-Page-Application Concepts in AEM/CQ
Dynamic Components using Single-Page-Application Concepts in AEM/CQDynamic Components using Single-Page-Application Concepts in AEM/CQ
Dynamic Components using Single-Page-Application Concepts in AEM/CQ
 
SOLID Design Principles
SOLID Design PrinciplesSOLID Design Principles
SOLID Design Principles
 
A1 - Sql Injection na Prática Parte 01
A1 - Sql Injection na Prática Parte 01A1 - Sql Injection na Prática Parte 01
A1 - Sql Injection na Prática Parte 01
 
Clean code
Clean codeClean code
Clean code
 
Java Server Pages(jsp)
Java Server Pages(jsp)Java Server Pages(jsp)
Java Server Pages(jsp)
 
Screen orientations in android
Screen orientations in androidScreen orientations in android
Screen orientations in android
 
Exception Handling in VB.Net
Exception Handling in VB.NetException Handling in VB.Net
Exception Handling in VB.Net
 
Servlet.ppt
Servlet.pptServlet.ppt
Servlet.ppt
 

Más de Open University, KMi

Coordination of Resource-Constrained Devices through a Distributed Semantic S...
Coordination of Resource-Constrained Devices through a Distributed Semantic S...Coordination of Resource-Constrained Devices through a Distributed Semantic S...
Coordination of Resource-Constrained Devices through a Distributed Semantic S...Open University, KMi
 
Assessing data dissemination strategies
Assessing data dissemination strategiesAssessing data dissemination strategies
Assessing data dissemination strategiesOpen University, KMi
 
Presentación de Otsopack en Tecnalia
Presentación de Otsopack en TecnaliaPresentación de Otsopack en Tecnalia
Presentación de Otsopack en TecnaliaOpen University, KMi
 
Konposizioa, herentzia eta polimorfismoa
Konposizioa, herentzia eta  polimorfismoa Konposizioa, herentzia eta  polimorfismoa
Konposizioa, herentzia eta polimorfismoa Open University, KMi
 
"On the complementarity of Triple Spaces and the Web of Things" poster @ WoT2011
"On the complementarity of Triple Spaces and the Web of Things" poster @ WoT2011"On the complementarity of Triple Spaces and the Web of Things" poster @ WoT2011
"On the complementarity of Triple Spaces and the Web of Things" poster @ WoT2011Open University, KMi
 
A Triple Space-Based Semantic Distributed Middleware for Internet of Things
A Triple Space-Based Semantic Distributed Middleware for Internet of ThingsA Triple Space-Based Semantic Distributed Middleware for Internet of Things
A Triple Space-Based Semantic Distributed Middleware for Internet of ThingsOpen University, KMi
 

Más de Open University, KMi (16)

Coordination of Resource-Constrained Devices through a Distributed Semantic S...
Coordination of Resource-Constrained Devices through a Distributed Semantic S...Coordination of Resource-Constrained Devices through a Distributed Semantic S...
Coordination of Resource-Constrained Devices through a Distributed Semantic S...
 
Assessing data dissemination strategies
Assessing data dissemination strategiesAssessing data dissemination strategies
Assessing data dissemination strategies
 
RESTful Triple Spaces of Things
RESTful Triple Spaces of ThingsRESTful Triple Spaces of Things
RESTful Triple Spaces of Things
 
Presentación de Otsopack en Tecnalia
Presentación de Otsopack en TecnaliaPresentación de Otsopack en Tecnalia
Presentación de Otsopack en Tecnalia
 
Zuhaitzak
ZuhaitzakZuhaitzak
Zuhaitzak
 
Errekurtsibitatea
ErrekurtsibitateaErrekurtsibitatea
Errekurtsibitatea
 
Egitura linealak
Egitura linealakEgitura linealak
Egitura linealak
 
Konposizioa, herentzia eta polimorfismoa
Konposizioa, herentzia eta  polimorfismoa Konposizioa, herentzia eta  polimorfismoa
Konposizioa, herentzia eta polimorfismoa
 
Fitxategiak
FitxategiakFitxategiak
Fitxategiak
 
2D arraya eta objetu arrayak
2D arraya eta objetu arrayak2D arraya eta objetu arrayak
2D arraya eta objetu arrayak
 
"On the complementarity of Triple Spaces and the Web of Things" poster @ WoT2011
"On the complementarity of Triple Spaces and the Web of Things" poster @ WoT2011"On the complementarity of Triple Spaces and the Web of Things" poster @ WoT2011
"On the complementarity of Triple Spaces and the Web of Things" poster @ WoT2011
 
Triple Space adaptation for IoT
Triple Space adaptation for IoTTriple Space adaptation for IoT
Triple Space adaptation for IoT
 
A Triple Space-Based Semantic Distributed Middleware for Internet of Things
A Triple Space-Based Semantic Distributed Middleware for Internet of ThingsA Triple Space-Based Semantic Distributed Middleware for Internet of Things
A Triple Space-Based Semantic Distributed Middleware for Internet of Things
 
Presentacion Defensa
Presentacion DefensaPresentacion Defensa
Presentacion Defensa
 
Introducción a PHP5
Introducción a PHP5Introducción a PHP5
Introducción a PHP5
 
Introducción a PHP5
Introducción a PHP5Introducción a PHP5
Introducción a PHP5
 

Redis

  • 1. Redis Cursillos 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
  • 2. Outline ´ Introduccion Redis 2 / 37
  • 3. Outline ´ Introduccion ´ Instalacion Redis 2 / 37
  • 4. Outline ´ Introduccion ´ Instalacion Ejercicios Redis 2 / 37
  • 5. Outline ´ Introduccion ´ Instalacion Ejercicios Redis ´ Introduccion 3 / 37
  • 6. ´ ¿Que es Redis? Remote dictionary server Redis ´ Introduccion 4 / 37
  • 7.
  • 8. ´ ¿Que es Redis? ...mixed soul of cache, Redis ´ Introduccion 6 / 37
  • 9. ´ ¿Que es Redis? ...mixed soul of cache, store, Redis ´ Introduccion 6 / 37
  • 10. ´ ¿Que es Redis? ...mixed soul of cache, store, and messaging server... Salvatore Sanfilippo Redis ´ Introduccion 6 / 37
  • 11. ´ ¿Que es Redis? ...mixed soul of cache, store, and messaging server... Salvatore Sanfilippo (data structure server, advanced key-value store, etc.) Redis ´ Introduccion 6 / 37
  • 12. Caracter´sticas ı Redis ´ Introduccion 7 / 37
  • 13. Caracter´sticas ı Redis ´ Introduccion 8 / 37
  • 14. Caracter´sticas ı Redis ´ Introduccion 9 / 37
  • 15. Caracter´sticas ı Redis ´ Introduccion 10 / 37
  • 16. Caracter´sticas ı Redis ´ Introduccion 11 / 37
  • 17. Caracter´sticas ı Redis ´ Introduccion 12 / 37
  • 18. Caracter´sticas ı Redis ´ Introduccion 13 / 37
  • 19. Caracter´sticas ı Redis ´ Introduccion 14 / 37
  • 20.
  • 22. Velocidad Redis ´ Introduccion 16 / 37
  • 23.
  • 24. Velocidad y transacciones ´ Con el grafico anterior. . . Sistema Velocidad Transaccional Concurrente Red MySQL (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 No redis S´ ı S´ı S´ ı S´ ı Redis ´ Introduccion 18 / 37
  • 25. Velocidad Redis ´ Introduccion 19 / 37
  • 26. ´ Ejemplo practico: WebLab-Deusto WebLab-Deusto: software de la Universidad de Deusto que gestiona acceso a laboratorios f´sicos de la misma. ı Regularmente en clase → hasta 60 usuarios concurrentes Este ano → varios cientos de usuarios concurrentes ˜ Redis ´ Introduccion 20 / 37
  • 27. ´ Gestion de colas: MySQL I (1 recurso, 150 estudiantes) Redis ´ Introduccion 21 / 37
  • 28. ´ Gestion de colas: redis I (1 recurso, 150 estudiantes) Redis ´ Introduccion 22 / 37
  • 29. ´ Gestion de colas: MySQL II (80 recursos, 150 estudiantes) Redis ´ Introduccion 23 / 37
  • 30. ´ Gestion de colas: redis II (80 recursos, 150 estudiantes) Redis ´ Introduccion 24 / 37
  • 31. Outline ´ Introduccion ´ Instalacion Ejercicios Redis ´ Instalacion 25 / 37
  • 32. ´ Instalacion apt-get install redis-server python-redis U otra librer´a para crear clientes en el lenguaje que ı ´ prefirais... (en java Jedis) Redis ´ Instalacion 26 / 37
  • 33. Outline ´ Introduccion ´ Instalacion Ejercicios Redis Ejercicios 27 / 37
  • 34.
  • 35. Caso general ´ Aplicacion de chat Redis Ejercicios 29 / 37
  • 36. ´ Ejercicio 0: Operaciones basicas Strings Comandos: setex, setnx, incr... Usos: usuarios online contadores API rate limiting ids unicos Redis Ejercicios 30 / 37
  • 37. Ejercicio 1: Amigos online Sets Comandos: sadd, smembers, sinter. . . Usos: ´ eleccion aleatoria de noticias, etc. modelar relaciones (followers, following, etc.) amigos online Redis Ejercicios 31 / 37
  • 38. Ejercicio 2: propiedades de amigos Hashes Comandos: hset, hget, hvals. . . Usos: almacenamiento de datos estructurados Redis Ejercicios 32 / 37
  • 39. Ejercicio 3: chatear ´ ´ Publicacion/subscripcion Comandos: subscribe, publish. . . Usos: Env´o de mensajes N a M ı Redis Ejercicios 33 / 37
  • 40. ´ Ejercicio 4: gestion del tiempo Pipelines Comandos: multi, exec. . . Usos: Env´o de varios comandos en uno ı Redis Ejercicios 34 / 37
  • 41. 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
  • 42. Bibliograf´a II ı Karl Seguin. The Little Redis Book. January 2012. Redis Bibliografia 36 / 37
  • 43. ´ Todas las imagenes son propiedad de sus ˜ respectivos duenos*, el resto del contenido ´ esta licenciado bajo Creative Commons by-sa 3.0. * Andreas, srippon, Andrew Fitzsimon, jfmelero, liftarn, shokunin, mcol, djmx1, MongoDB, Riak, Cassandra, Redis, Membase, HBase, neo4j y CouchDB.