7. Veamoscómofunciona (velocity) Share Data Across Applications No more sticky routing Scale out by adding more boxes Performance (Quad Core Box) Velocity High Availability Protect from Server Failure
9. Escalarparticionando el cache Application La “routing table client” nos dice Almacenar en el cache2 (primario) PUT Get(K2) Velocity Client1 Velocity Client2 Routing Table Routing Table Cache2 Cache3 Cache1 Routing Table Routing Table Routing Table Primary for K1,V1 Primary for K2,V2 Primary for K3,V3 (K2, V2) K2, V2 K1, V1 K3, V3 K2, V2 Cola de operacionesparanotificaciones, new secondary, etc
10. Cómo se particiona? ID Ranges mapped to Nodes Region Name Hashed into Region Id Keys Bucketized into Regions Velocity Service Velocity Service Velocity Service
11. Particionandohorizontalmente se lograincrementarescalabilidad y performance Escalarpor el tamaño de los datos Másmáquinas => másmemoriaparacachear Escalarparatenermejorrendimiento Cache Throughput: operaciones/segdesde el cache Másmáquinas => keys distribuidos Másmáquinas => mejorrendimiento Performance High Performance escalandohorizontalmentedatos y procesamiento (a tener en cuenta…) Aumentar la memoria Incrementar el procesamiento Distribuir el procesamientopor los nodos del cache
12. Local Cache El cache local puede ayudar a mejorar la velocidad de acceso desde los clientes Utiliza mecanismos de notificación para refrescar el cache cuando se produce un cambio Get(K2) Put(K2, v2) Get(K2) Velocity Client Velocity Client Local Cache Local Cache Routing Table Routing Table Cache2 Cache3 Cache1 K2, V2 K2, V2 Primary for K1,V1 Primary for K3,V3 Primary for K2,V2 K1, V1 K3, V3
17. Devuelve controlVelocity Client1 Velocity Client Routing Table Routing Table Cache1 Cache2 Cache3 Primary for (K1,V1) Primary for (K3,V3) Primary for (K2,V2) Replication Agent K3, V3 K1, V1 K2, V2 (K2, V2) K2, V2 K2, V2 Secondary for (K1,V1), (K2,V2) Secondary for (K1,V1), (K3,V3) Secondary for (K2,V2), (K3,V3) K2, V2 K1, V1 K3, V3 K1, V1 K3, V3
18. Cache4 Partition Manager Primary for (K4,V4) Global Partition Map K4, V4 Secondary for K1, V1 Cache1 Cache2 Cache3 Primary for (K2,V2) Failover PM analiza la información de los nodossecundarios de todas los keys quetenía Cache2 paraelegir el nuevoprimario Elige Cache1 comoprimariopara (K2,V2). Envíamensaje a los nodossecundarios Cache1 y Cache3. actualiza GPM Detectalasfalla de Cache y notifica a PM (on Cache4) Cache1 polls los secundarios de (Cache2) paraasegurarse de quetiene la últimainformación; casocontrario no toma ownership Cache1 inicializaconfiguración. Después de reconfigurar Cache1 es el primariopara (K1, V1) y (K2, V2) Routing Table Reconfiguration Agent K1, V1 Primary for (K3,V3) Replication Agent K3, V3 K2, V2 Local Partition Map K3, V3 K2, V2 Secondary for Secondary for Secondary for K2, V2 K1, V1 K3, V3 K3, V3 K4, V4
19. Optimistic Version Based Updates GetCacheItemdevuelve el valor del objeto Cadaactualización del objetoincrementasuversión Envía la versiónobtenida en cada Put/Remove Put/Remove serásatisfactoriounicamentesi la versiónenviadamatchea con la versión del cache 2 clientesacceden al mismo item Ambos modifican el item El segundoactualiza el cache; operaciónsatisfactoriadebido a quecoincidenlasversiones; se incrementaversión en el cache El primer clienteintentaguardar; Falladebido a que la versión no coincide.
20. Pessimistic Locking GetAndLock – devuelve un objeto y lo lockea Otrasllamadas con GetAndLockfallarán (not block) Lock Expiry time haceque el lock expire Regular Get no lo bloquearán Regular Put reescribirán el lock PutAndUnlock – pone un nuevoobjeto y lo desbloquea UnLock – desbloqueaexplicitamente el objeto Client1: GetAndLock ("k1") Client3: Get ("k1") Client2: GetAndLock ("k1") GetAndLock gets lock handle Regular Get succeeds Other GetAndLock on same item fails
21. Velocity API // Create instance of cachefactory (reads appconfig) DataCacheFactoryfac = new DataCacheFactory(); // Get a named cache from the factory Cache catalog = fac.GetCache("catalogcache"); // Simple Get/Put catalog.Put("toy-101", new Toy("Puzzle", .,.)); // From the same or a different client Toy toyObj = (Toy)catalog.Get("toy-101"); // Region based Get/Put catalog.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");
22. Access APIs – Tagging Items Hot or Discount Items in catalog Use Tagging List All Items / Hot Items - Enumeration Use Enumeration // Add Tags Tag 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 client List<KeyValuePair<string, object>> toys = catalog.GetAnyMatchingTag("toyRegion", hotItem);
23. BETA Features Seguridad Authentication y Authorization Configuración GPM Rebuild for network share obviates need for SQL compact file to store partition distribution information ADO.Net provider for config store Administración Perfmon counters Live Cluster Patching & Version Compatibility