foro de arquitectos: caché en azure a fondo
TRANSCRIPT
![Page 1: Foro de Arquitectos: caché en azure a fondo](https://reader030.vdocuments.pub/reader030/viewer/2022032422/55a8ed6e1a28abae2b8b478e/html5/thumbnails/1.jpg)
Microsoft Azure nos provee de diferentes
servicios de caché distribuida
Cachés en Azure
![Page 2: Foro de Arquitectos: caché en azure a fondo](https://reader030.vdocuments.pub/reader030/viewer/2022032422/55a8ed6e1a28abae2b8b478e/html5/thumbnails/2.jpg)
![Page 4: Foro de Arquitectos: caché en azure a fondo](https://reader030.vdocuments.pub/reader030/viewer/2022032422/55a8ed6e1a28abae2b8b478e/html5/thumbnails/4.jpg)
AgendaCaché
¿Qué es?Memory vs. no-memoryTipos de datos
A fondo¿Cómo usar la cache?Patrón: cache-aside¿Por qué usar cachés?
Caché modernaCachés distribuidasCachés en Microsoft AzureRedis
ResumenPruebasConclusiones
Caché¿Qué es?
Tipos de datos
A fondo¿Cómo?
Patrones de diseño
¿Por qué?
Caché moderna
Microsoft Azure
Redis
ResumenPruebas
Conclusiones
![Page 5: Foro de Arquitectos: caché en azure a fondo](https://reader030.vdocuments.pub/reader030/viewer/2022032422/55a8ed6e1a28abae2b8b478e/html5/thumbnails/5.jpg)
¿Qué es una caché?
![Page 6: Foro de Arquitectos: caché en azure a fondo](https://reader030.vdocuments.pub/reader030/viewer/2022032422/55a8ed6e1a28abae2b8b478e/html5/thumbnails/6.jpg)
Caché L1
![Page 7: Foro de Arquitectos: caché en azure a fondo](https://reader030.vdocuments.pub/reader030/viewer/2022032422/55a8ed6e1a28abae2b8b478e/html5/thumbnails/7.jpg)
Caché L2
![Page 8: Foro de Arquitectos: caché en azure a fondo](https://reader030.vdocuments.pub/reader030/viewer/2022032422/55a8ed6e1a28abae2b8b478e/html5/thumbnails/8.jpg)
Caché L3
![Page 9: Foro de Arquitectos: caché en azure a fondo](https://reader030.vdocuments.pub/reader030/viewer/2022032422/55a8ed6e1a28abae2b8b478e/html5/thumbnails/9.jpg)
Cache memory vs. no-memory
![Page 10: Foro de Arquitectos: caché en azure a fondo](https://reader030.vdocuments.pub/reader030/viewer/2022032422/55a8ed6e1a28abae2b8b478e/html5/thumbnails/10.jpg)
Demo: output caché
![Page 11: Foro de Arquitectos: caché en azure a fondo](https://reader030.vdocuments.pub/reader030/viewer/2022032422/55a8ed6e1a28abae2b8b478e/html5/thumbnails/11.jpg)
Cache memory vs. no-memory
![Page 12: Foro de Arquitectos: caché en azure a fondo](https://reader030.vdocuments.pub/reader030/viewer/2022032422/55a8ed6e1a28abae2b8b478e/html5/thumbnails/12.jpg)
Demo: HttpRuntime.Cache
![Page 13: Foro de Arquitectos: caché en azure a fondo](https://reader030.vdocuments.pub/reader030/viewer/2022032422/55a8ed6e1a28abae2b8b478e/html5/thumbnails/13.jpg)
Tipos de datos
![Page 14: Foro de Arquitectos: caché en azure a fondo](https://reader030.vdocuments.pub/reader030/viewer/2022032422/55a8ed6e1a28abae2b8b478e/html5/thumbnails/14.jpg)
Datos de referencia
![Page 15: Foro de Arquitectos: caché en azure a fondo](https://reader030.vdocuments.pub/reader030/viewer/2022032422/55a8ed6e1a28abae2b8b478e/html5/thumbnails/15.jpg)
Datos de actividad
![Page 16: Foro de Arquitectos: caché en azure a fondo](https://reader030.vdocuments.pub/reader030/viewer/2022032422/55a8ed6e1a28abae2b8b478e/html5/thumbnails/16.jpg)
Datos de recursos
![Page 17: Foro de Arquitectos: caché en azure a fondo](https://reader030.vdocuments.pub/reader030/viewer/2022032422/55a8ed6e1a28abae2b8b478e/html5/thumbnails/17.jpg)
En resumen:
Datos de referencia
Datos de actividad
Datos de recursos
![Page 18: Foro de Arquitectos: caché en azure a fondo](https://reader030.vdocuments.pub/reader030/viewer/2022032422/55a8ed6e1a28abae2b8b478e/html5/thumbnails/18.jpg)
¿Cómo usar la caché?
![Page 19: Foro de Arquitectos: caché en azure a fondo](https://reader030.vdocuments.pub/reader030/viewer/2022032422/55a8ed6e1a28abae2b8b478e/html5/thumbnails/19.jpg)
cache-aside pattern
1. Determinar si un objeto ya está almacenado en la memoria caché.
2. Si no está almacenado en la memoria caché leerlo del almacén de datos
3. Guardar el objeto que hemos cargado en la memoria caché
?. Devolver el objeto almacenado en la caché
![Page 20: Foro de Arquitectos: caché en azure a fondo](https://reader030.vdocuments.pub/reader030/viewer/2022032422/55a8ed6e1a28abae2b8b478e/html5/thumbnails/20.jpg)
Demo: cache-aside
![Page 21: Foro de Arquitectos: caché en azure a fondo](https://reader030.vdocuments.pub/reader030/viewer/2022032422/55a8ed6e1a28abae2b8b478e/html5/thumbnails/21.jpg)
Consideraciones a la hora de usar cachés
• Tiempo de vida de objetos en caché limitado
• Desalojo de datos
• Preparación inicial de caché
• Consistencia de la información
• Cachés locales
![Page 22: Foro de Arquitectos: caché en azure a fondo](https://reader030.vdocuments.pub/reader030/viewer/2022032422/55a8ed6e1a28abae2b8b478e/html5/thumbnails/22.jpg)
¿Por qué usar caché?
![Page 23: Foro de Arquitectos: caché en azure a fondo](https://reader030.vdocuments.pub/reader030/viewer/2022032422/55a8ed6e1a28abae2b8b478e/html5/thumbnails/23.jpg)
Porque reducimos la latencia
Latencia baja → respuesta rápida
Respuesta rápida → más velocidad
Más velocidad → cliente contento
Cliente contento…
![Page 24: Foro de Arquitectos: caché en azure a fondo](https://reader030.vdocuments.pub/reader030/viewer/2022032422/55a8ed6e1a28abae2b8b478e/html5/thumbnails/24.jpg)
![Page 25: Foro de Arquitectos: caché en azure a fondo](https://reader030.vdocuments.pub/reader030/viewer/2022032422/55a8ed6e1a28abae2b8b478e/html5/thumbnails/25.jpg)
Alternativas:
Más hierro
Performance de procesos
Usando agregados
Variables de sesión
Caché output
![Page 26: Foro de Arquitectos: caché en azure a fondo](https://reader030.vdocuments.pub/reader030/viewer/2022032422/55a8ed6e1a28abae2b8b478e/html5/thumbnails/26.jpg)
Pero:
Escalar es caro
Los procesos tienen límites
Los agregados no son la panacea
La sesión no es compartida
El output lo gestiona el cliente
![Page 27: Foro de Arquitectos: caché en azure a fondo](https://reader030.vdocuments.pub/reader030/viewer/2022032422/55a8ed6e1a28abae2b8b478e/html5/thumbnails/27.jpg)
Caché moderna
![Page 28: Foro de Arquitectos: caché en azure a fondo](https://reader030.vdocuments.pub/reader030/viewer/2022032422/55a8ed6e1a28abae2b8b478e/html5/thumbnails/28.jpg)
Caché distribuida:
Nuevos retos: Nuevo hierro
Gestión
Integración
Escalabilidad
Plan de contingencia
…
![Page 29: Foro de Arquitectos: caché en azure a fondo](https://reader030.vdocuments.pub/reader030/viewer/2022032422/55a8ed6e1a28abae2b8b478e/html5/thumbnails/29.jpg)
Servicios de caché en la nube
![Page 30: Foro de Arquitectos: caché en azure a fondo](https://reader030.vdocuments.pub/reader030/viewer/2022032422/55a8ed6e1a28abae2b8b478e/html5/thumbnails/30.jpg)
Caché en azure
AppFabric Cache
Cache In-Role
Azure Cache Services
Virtual Machine
Redis
![Page 31: Foro de Arquitectos: caché en azure a fondo](https://reader030.vdocuments.pub/reader030/viewer/2022032422/55a8ed6e1a28abae2b8b478e/html5/thumbnails/31.jpg)
Demo: Microsoft Cache
![Page 32: Foro de Arquitectos: caché en azure a fondo](https://reader030.vdocuments.pub/reader030/viewer/2022032422/55a8ed6e1a28abae2b8b478e/html5/thumbnails/32.jpg)
Demo: Cache InRole
![Page 33: Foro de Arquitectos: caché en azure a fondo](https://reader030.vdocuments.pub/reader030/viewer/2022032422/55a8ed6e1a28abae2b8b478e/html5/thumbnails/33.jpg)
Demo: InRole Gateway
![Page 34: Foro de Arquitectos: caché en azure a fondo](https://reader030.vdocuments.pub/reader030/viewer/2022032422/55a8ed6e1a28abae2b8b478e/html5/thumbnails/34.jpg)
Demo: Cache Services
![Page 35: Foro de Arquitectos: caché en azure a fondo](https://reader030.vdocuments.pub/reader030/viewer/2022032422/55a8ed6e1a28abae2b8b478e/html5/thumbnails/35.jpg)
Redis
![Page 36: Foro de Arquitectos: caché en azure a fondo](https://reader030.vdocuments.pub/reader030/viewer/2022032422/55a8ed6e1a28abae2b8b478e/html5/thumbnails/36.jpg)
Redis:
Es una base de datos NO-SQL que almacena información del tipo Clave/Valor.
![Page 37: Foro de Arquitectos: caché en azure a fondo](https://reader030.vdocuments.pub/reader030/viewer/2022032422/55a8ed6e1a28abae2b8b478e/html5/thumbnails/37.jpg)
Características de redis
• Maneja cadenas de texto (o byte arrays)
• 5 tipos de datos:• Keys
• Hashes
• Lists
• Sets
• Sorted Sets
• Pub/Sub
• Operaciones con datos
• Scripts en LUA
• En memoria, pero persiste en forma de snapshots
![Page 38: Foro de Arquitectos: caché en azure a fondo](https://reader030.vdocuments.pub/reader030/viewer/2022032422/55a8ed6e1a28abae2b8b478e/html5/thumbnails/38.jpg)
Demo: Redis
![Page 39: Foro de Arquitectos: caché en azure a fondo](https://reader030.vdocuments.pub/reader030/viewer/2022032422/55a8ed6e1a28abae2b8b478e/html5/thumbnails/39.jpg)
Casos de uso de redis
• Listados de últimos xxx: LPUSH y LTRIM
• Tablas de top o de rankings: ZADD, ZREVRANGE y ZREVRANGEBYSCORE
• Cálculos de tipo “karma”: ZADD, ZRANK, ZINCRBY
• Contadores usuarios activos: INCR y EXPIRE
• Publicación y suscripción: mediator
• QUEUE’s (colas): BLPOP y LPUSH
• Textos auto-completables: ZADD, ZRANK y ZRANGE
• Almacenar información que caduca: EXPIRE
• …
![Page 40: Foro de Arquitectos: caché en azure a fondo](https://reader030.vdocuments.pub/reader030/viewer/2022032422/55a8ed6e1a28abae2b8b478e/html5/thumbnails/40.jpg)
https://www.desarrollaconmicrosoft.com/dotnetspain2015
![Page 41: Foro de Arquitectos: caché en azure a fondo](https://reader030.vdocuments.pub/reader030/viewer/2022032422/55a8ed6e1a28abae2b8b478e/html5/thumbnails/41.jpg)
Pruebas
![Page 42: Foro de Arquitectos: caché en azure a fondo](https://reader030.vdocuments.pub/reader030/viewer/2022032422/55a8ed6e1a28abae2b8b478e/html5/thumbnails/42.jpg)
![Page 43: Foro de Arquitectos: caché en azure a fondo](https://reader030.vdocuments.pub/reader030/viewer/2022032422/55a8ed6e1a28abae2b8b478e/html5/thumbnails/43.jpg)
![Page 44: Foro de Arquitectos: caché en azure a fondo](https://reader030.vdocuments.pub/reader030/viewer/2022032422/55a8ed6e1a28abae2b8b478e/html5/thumbnails/44.jpg)
Conclusiones </>
![Page 45: Foro de Arquitectos: caché en azure a fondo](https://reader030.vdocuments.pub/reader030/viewer/2022032422/55a8ed6e1a28abae2b8b478e/html5/thumbnails/45.jpg)
Bibliografía• http://www.wikipedia.org
• http://www.stackoverflow.com
• http://www.msdn.com• https://msdn.microsoft.com/en-us/library/dn568099.aspx
• Microsoft Azure Documentation
• http://redis.io/• http://oldblog.antirez.com/post/take-advantage-of-redis-adding-it-to-your-stack.html
• http://www.memcached.org
• https://github.com/enyim/EnyimMemcached
• https://github.com/ServiceStack
• https://github.com/StackExchange
• https://github.com/fernandoescolar/Tokiota.Redis
![Page 46: Foro de Arquitectos: caché en azure a fondo](https://reader030.vdocuments.pub/reader030/viewer/2022032422/55a8ed6e1a28abae2b8b478e/html5/thumbnails/46.jpg)
Muchas gracias!!!
Fernando Escolar
@fernandoescolar