[Run Reloaded] Estrategias de Caching Distribuído con Microsoft Velocity Project (Juan Ladetto +...
-
Upload
microsoft-argentina-y-uruguay-official-space -
Category
Technology
-
view
564 -
download
3
description
Transcript of [Run Reloaded] Estrategias de Caching Distribuído con Microsoft Velocity Project (Juan Ladetto +...
Microsoft codename: “velocity”
Dante OteroMCS - ConsultorMicrosoft Argentina
Juan LadettoDPE - ArquitectoMicrosoft Argentina
Windows Server AppFabric <caching/>
Dante OteroMCS - ConsultorMicrosoft Argentina
Juan LadettoDPE - ArquitectoMicrosoft Argentina
Por qué?
Base de datos
Cloud
App Tier
Cache Tier
Data Tier
La base de datos es un recurso limitado
msdn, myspace, flickr, facebook, youtube, etc
Siempre trabajamos con != datos
Referencia
Read*Gral estáticosMucho tráficoHigh Avail.
Actividad
Read/WriteCambia frecUser-specificHigh-Scale
Recursos
Read/WriteCambia frecApplication-WideHigh-Scale
Ejemplos:PaísesCatálogosCategoríasetc
Ejemplos:SessionShopping Cart item
Ejemplo:Inventario
Hay alguna solución para esto?
Unified Cache View
Solución de caching que sea explícita, distríbuida, en memoria para cualquier tipo de dato
Veamos cómo funciona (velocity)
High AvailabilityProtect from Server Failure
Share Data Across ApplicationsNo more sticky routing
Scale out by adding more boxesPerformance (Quad Core Box)
Operation Throughput
Latency
Read 2k 30,000 / sec
.6 – 1.5 ms
Write 2k 18,000 / sec
3 ms
Operation Servers Throughput
Read 2k 1 30,000 / sec
Read 2k 2 58, 600 / sec
Read 2k 3 85, 500 / sec
Velocity
Qué debemos analizar para elegir correctamentePerformance
RendimientoLatencia
ConsistencyPuede llegar a ser dirty? Por cuánto tiempo?
EvictionLa información que no sirve es desalojada?
SecurityAvailability
Qué pasa con la información si un nodo se rompe?
Application
Cache2Cache1
Primary forK2,V2
K2, V2
Primary for K1,V1
K1, V1
Cache3
Primary for K3,V3
K3, V3
Velocity Client2
Escalar particionando el cache
Get(K2)
Routing Table
(K2, V2)
Velocity Client1
Routing Table
PUT
La “routing table client” nos diceAlmacenar en el cache2 (primario)
Routing Table
Routing Table
Routing Table
K2
, V
2
Cola de operaciones para notificaciones, new secondary,
etc
Cómo se particiona?
Region Key
"Cust1"
"Cust2"
"Cust33"
"ToyRegion"
"Toy101"
"ToyRegion"
"Toy102"
"BoxRegion"
"Box101"
Partition(Range of Ids)
0 – 1000
1001 - 2000
…
…
..
xxx - Maxint
Region(Name)
Default Region 1
Default Region 2
…
Default Region 256
ToyRegion
BoxRegion
Velo
city
Serv
ice
Velo
city
Serv
ice
Velo
city
Serv
ice
Region Name Hashed into Region Id
Keys Bucketized into Regions
ID Ranges mapped to Nodes
Particionando horizontalmente se logra incrementar escalabilidad y performance
Escalar por el tamaño de los datosMás máquinas => más memoria para cachear
Escalar para tener mejor rendimientoCache Throughput: operaciones/seg desde el cacheMás máquinas => keys distribuidosMás máquinas => mejor rendimiento
PerformanceHigh Performance escalando horizontalmente datos
y procesamiento (a tener en cuenta…)Aumentar la memoriaIncrementar el procesamiento
Distribuir el procesamiento por los nodos del cache
Velocity Client
Local Cache
Local CacheEl cache local puede ayudar a mejorar la velocidad
de acceso desde los clientesUtiliza mecanismos de notificación para refrescar
el cache cuando se produce un cambio
Put(K2, v2)
Routing Table
Cache2Cache1
Primary for K2,V2
K2, V2
Primary for K1,V1
K1, V1
Cache3
Primary for K3,V3
K3, V3
Velocity Client
Local CacheRouting Table
K2, V2
Get(K2)
Get(K2)
Application(K2, V2)
Cache2Cache1 Cache3
Primary for (K2,V2)
Availability
Get(K2)
Primary for (K1,V1) Primary for (K3,V3)
K3, V3
Velocity Client1
Routing Table
K2
, V
2
La “routing table client” nos diceAlmacenar en el cache2 (primario)
PUT • pone en cola la petición•Almacena localmente•Propaga operación a otros nodos secundarios•Espera a tener quorum (se replico como mínimo 1 vez)•Devuelve control
Secondary for (K2,V2), (K3,V3)
K2, V2
K1, V1
K3, V3
Secondary for (K1,V1), (K3,V3)
K3, V3
K1, V1
Secondary for (K1,V1), (K2,V2)
K1, V1
K2, V2
Velocity Client
Routing Table
K2, V2
Replication
Agent
Cache4
Primary for (K4,V4)
K4, V4
Secondary for
K1, V1
K3, V3
Partition ManagerGlobal
Partition Map
Cache2Cache1 Cache3
Primary for (K2,V2)
Failover
Primary for (K3,V3)
K3, V3
Routing Table
Secondary for
K2, V2
K1, V1
K3, V3
Secondary for
K3, V3
K1, V1
Secondary for
K4, V4
K2, V2
K2, V2
Detecta las falla de Cache y notifica a PM (on Cache4)
Replication Agent
Reconfiguration
Agent
Local Partition Map
Elige Cache1 como primario para (K2,V2). Envía mensaje a los nodos secundarios Cache1 y Cache3. actualiza GPM
PM analiza la información de los nodos secundarios de todas los keys que tenía Cache2 para elegir el nuevo primario
Cache1 polls los secundarios de (Cache2) para asegurarse de que tiene la última información; caso contrario no toma ownership
Cache1 inicializa configuración. Después de reconfigurar Cache1 es el primario para (K1, V1) y (K2, V2)
Optimistic Version Based UpdatesGetCacheItem devuelve el valor del objetoCada actualización del objeto incrementa su versiónEnvía la versión obtenida en cada Put/RemovePut/Remove será satisfactorio unicamente si la versión
enviada matchea con la versión del cache
Version Based Update
Time Client1 Client2 (Different Thread or process)
T0 CacheItem item = catalog.GetCacheItem(“PlayerRegion”, ”Zune”);
CacheItem item = catalog.GetCacheItem(“PlayerRegion”, ”Zune”);
T1 ((ZuneObject)item.Object).inventory --;
((ZuneObject)item.Object).inventory--;
T2 catalog.Put(“PlayerRegion”, “Zune”, item.Object, item.Version);
T3 catalog.Put(“PlayerRegion”, “Zune”, item.Object, item.Version);// Version mismatch// Client must retry again
2 clientes acceden al mismo item
Ambos modifican el item
El segundo actualiza el cache; operación satisfactoria debido a que coinciden las versiones; se incrementa versión en el cache
El primer cliente intenta guardar;Falla debido a que la versión no
coincide.
Pessimistic Locking
GetAndLock – devuelve un objeto y lo lockeaOtras llamadas con GetAndLock fallarán (not block)
Lock Expiry time hace que el lock expire
Regular Get no lo bloquearán
Regular Put reescribirán el lock
PutAndUnlock – pone un nuevo objeto y lo
desbloqueaUnLock – desbloquea explicitamente el objetoClient1:
GetAndLock ("k1")
Client2: GetAndLock ("k1")
Client3: Get ("k1")
Regular Get succeeds
GetAndLock gets lock handle
Other GetAndLock on same item fails
Velocity API// Create instance of cachefactory (reads appconfig)DataCacheFactory fac = new DataCacheFactory();
// Get a named cache from the factoryCache catalog = fac.GetCache("catalogcache");
// Simple Get/Putcatalog.Put("toy-101", new Toy("Puzzle", .,.));
// From the same or a different clientToy toyObj = (Toy)catalog.Get("toy-101");
// Region based Get/Putcatalog.CreateRegion("toyRegion");
// Both toy and toyparts are put in the same region catalog.Put("toyRegion", "toy-101", new Toy( .,.));Catalog.Put("toyRegion", "toypart-100", new ToyParts(…));
Toy toyObj = (Toy)catalog.Get("toyRegion", "toy-101");
Access APIs – Tagging ItemsHot or Discount Items in catalog
Use Tagging
List All Items / Hot Items - EnumerationUse Enumeration
// Add TagsTag hotItem = new Tag("hotItem");Tag discItem = new Tag("discountItem");
catalog.Put("toyRegion", "toy-101", new Toy("Puzzle"), new Tag[]{hotItem});catalog.Put("toyRegion", "toy-102", new Toy("Bridge"), new Tag[]{hotItem,discItem});
// From the same or a different clientList<KeyValuePair<string, object>> toys = catalog.GetAnyMatchingTag("toyRegion", hotItem);
BETA FeaturesSeguridad
Authentication y AuthorizationConfiguración
GPM Rebuild for network share obviates need for SQL compact file to store partition
distribution informationADO.Net provider for config store
AdministraciónPerfmon countersLive Cluster Patching & Version
Compatibility
Sector Description
Media Cache all Media Files & Metadata; Big Media Provider in US
Content Big Content Provider in Europe
Content MSDN Forums is Live on CTP2
Healthcare One of the large health Care ISV in the world; US
Finance Big Brokerage Firm/Banking; High Performance Computation
Gaming Notifications for Presence;
Enterprise Largest Mainframe Migration to Windows
Manufacturing
Manufacturing Process Monitoring
Insurance Session data for insurance purchase
Ya se está usando?
Demo
¿Preguntas?