SlideShare une entreprise Scribd logo
1  sur  51
Télécharger pour lire hors ligne
Don’t give up, You can... Cache!
...Reasoning about why Caching Systems are sometimes a pain...
Crafted Software Meetup - 30/01/2020
Hi!
● Stefano Fago
● Software Designer in UBI Banca
● Legacy Application, Middleware and R&D Backend
https://www.linkedin.com/in/stefanofago/
https://github.com/stefanofago73
Where are the Caches?
How we face Caching?
Why Caches can be a pain?
Why Caches can be a pain?
...Because we forget that...
● a Cache hosts our DATA
● a cache IS NOT JUST AN ASSOCIATION ARRAY
● a cache is NOT a BUFFER
● a cache is NOT a POOL
● Business application ! = Twitter / Facebook / ... [Michael Plöd]
Caching is not what you think it is!
https://medium.com/@mauridb/caching-is-not-what-you-think-it-is-5104f8891b51
<< ...caching should be done to decrease costs needed to increase performance
and scalability and NOT to solve performance and scalability problems… >>
[Davide Mauri]
Why Caches can be a pain?
...Because we forget to set well defined goals and trade-off between:
– Offloading :
decrease the load of a system with limited and/or expensive
resources
– Performance :
decrease network/cpu usage
– Scale-out :
horizontal growth of systems having data locality and working-sets
ready
– Resilience
service resilience with fallback, default values, reuse of errors
Why Caches can be a pain?
...Because we forget the important things...
What can we do?
What can we do?
In order not to suffer with Caching we should:
● Decide on the type of cache to use
● Decide on an adoption path (How can we introduce
Caches in our projects?)
● Know our data
● Decide on the trade-off between reads and writes
● Define trade-offs for Resilience and Security
Different Kind of Caches
Different Kind of Caches
● Local/Internal
● In-Process
● Near Cache
Processo
Cache
Processo
Near
Cache
Cache
Server
Cache
Server
Cache
Server
Different Kind of Caches
● Remote/External
● Replicated
● Distributed(Partitioned)
Processo
Cache Cache Cache
Different Kind of Caches
● In-Process : for reads and writes, small/medium size, it does not
scale because it is limited to the process
● Near-Cache : better for reads, small/medium size, can scale in the
relationship with the cluster (of which it is an local
extension/expression)
● Replicated : data consistency for reads, small size, limited
scalability
● Partitioned : for reads and writes, different sizes and ability to
scale with fault tolerance
Different Kind of Caches : DEV
● Small Cache Read-Only/Timed (In-Process)
● Memoization (In-Process/Near Cache)
● Cache (In-Process/Distributed-Partitioned)
● User Session/Working Set (In-Process/Distributed-
Partitioned + … or NoSql)
● Distributed Memory (IMDG)
Different Kind of Caches : Problems
● Cache Stampede/Thunderig Herd ( concurrent calls on a
specific key not already there )
● Cache Fault Tollerance ( error handling for the Caching
subsystem, hierarchical caches, network error
management, ...)
● Cache Security (privacy and security policies, regulations
conformance, technical solutions)
Adopt a Cache
Adopt a Cache
Can follow two paths depending on
whether:
● Cache as First-Citizen in the
Software Architecture (Caching
Application Profiles)
● Cache as an evolution of a pre-
existing system
Added value is in the creation of a data
models, to be changed over time, born
from the evidence from the first phase. [Michael Plöd]
(1) (2) (3)
Adopt a Cache
Cache observability, especially if distributed:
● Hit : the value sought is available
● Miss : the value sought is not available
● Cold/Hot : cache is empty/full
● Warm-Up : populating cache
● Hit Ratio : Hit/(Hits + Miss)
● Hit Rate : Hit/seconds
● Items Size : number of elements in cache
● Conc. Request/s : number of concurrent requests/s
● ...many others!
Adopt a Cache
Having Operations support: collaboration/synergy is important
for network, metrics, deployment and emergency management
aspects
Have an alternative Plan : prepare alternatives that allow the
system/service to be online in the event of widespread errors or
unavailability of the Caching System
Prepare a design where the Cache Provider is abstracted and
appropriately hidden in terms of implementation to avoid
unsolvable dependencies in the future!
Know the Data
Know the Data
What are the data to put in Cache?
● Most Used/Required
● Expensive to Calculate
● Expensive to Retrieve
● Common/Shareable Data
The best are: read-only, frequently used and/or
expensive to calculate
Know the Data
What characteristics of the data to choose?
● Data Type (Better NOT the DTO, NOT Business Object)
● Data Format (Textual? Binary? Custom?)
● Life Time of the Data (When It’s Stale/Fresh)
● Data Type volumes
● Serialization/Deserialization issues
● Data Affinity
● Data Compression (...if you really have to...)
Know the Data
What issues are related to the Data (areas):
● Cache Access
● Cache Eviction
● Cache Invalidation
● Data Search/Data Collections Management
● Definition of Unique Keys
● Cache Concurrency Support
● Storage (RAM, SSD, … )
● Security/Regulations
Know the Data : Eviction
Forgetting is difficult for a cache: we have to find the trade-off between the
usefulness of the data and the size of the cache!
Concepts born from the optimization of linear research (Self-Organizing List
https://en.wikipedia.org/wiki/Self-organizing_list )
● Move To the Front
● Transpose
● Counting
LRU
LFU
Know the Data : Eviction
The frameworks, in a best-effort perspective, essentially offer LRU, LFU and
the ability of creating customized policies.
● LRU: (recency) deletes the least recently used items.
● LFU: (frequency) based on access frequency, eliminates less frequently used
Studies rise in the direction of Adaptive Systems using AI or statistical
processing (on the history of data); can be offered better results in the
compromise between memory, competition, speed!
● https://arxiv.org/pdf/1512.00727.pdf
● https://www.cs.bgu.ac.il/~tanm201/wiki.files/S1P2%20Adaptive%20Software
%20Cache%20Management.pdf
Know the Data : Eviction
When LRU, LFU are not enough which element can improve the
situation?
Time!
Applying timing policies or time windows for the aging of
data or which restrict the validity of data, helps to have a better
degree of adaptability ... but there is more!
Know the Data : Eviction
Know the Data : Problems
● Cache Trashing
the pattern of data usage is such that the cache is useless
● Cold Cache
an empty cache takes time to be useful!
● Cache Security
like any system there are privacy and security issues (what about
GDPR?):
● Data anonymization
● Cache Penetration
● Cache Avalanche
Access Patterns
Access Patterns
Accessing or entering Data in a cache means also choosing
its role and the trade-off between reads and writes...
● Cache-Aside
● Cache-Through
● Write-Around
● Refresh-Ahead
● Write-Back ( Write-Behind)
Access Patterns
Cache-Aside : the application is responsible for reads and writes to storage
as well as to the cache that is collateral to storage
Access Patterns
Related to Cache-Aside are:
● Look-Aside : The value is first searched in the cache and then in the storage
● Demand-Fill : Implies that in the case of MISS not only is the value returned
from the storage but it will also be placed in the cache
Cache-Aside generally provides both the LOOK-ASIDE and the DEMAND-
FILL but it is not mandatory that both are present: in a Pub/Sub system, Cache
and Storage can be subscribers of the same Publisher but they materialize the
data for two different reasons.
Access Patterns
Cache-Through : Write-Through/Read-Through
The application treats the cache as if it were the main storage; reads /
writes take place through the cache and propagated synchronously on
the storage
Access Patterns
Write-Around : The application reads from the cache but for
writes this is avoided. When data is new then is written directly to
the storage: it’s in the case of reads that the cache is filled with
data. (Useful when there are many writes and few reads).
Access Patterns
Refresh-Ahead : The cache is updated, also by scheduling,
asynchronously, for the recently accessed elements, before these expire
Access Patterns
Write-Back ( Write-Behind) : The application writes on the
cache but the propagation on the storage takes place
asynchronously (generally there is a delay configured, it assumes a queue
system; trade-off between high throughput and problems on data consistency)
Access Patterns : DEV
● Cache Aside
● Cache Through
● Cache Selective Bypass
● Cache Massive Load
● Cache Full Cleaning (+ Warmer)
Fight Cache Club
The Club Rules
1) Don’t speak about cache
2) Don’t speak about cache: if you do it, made it not at the expense of
your services
3) Define the price you are willing to pay
4) If you change the rules of the game you must be aware of it
5) Design in a simple way: start local, works on definable models
6) Measure, measure, measure: the cache gives you data and hints
7) Cache tuning takes time and changes over time
8) If you are in the Club ‘cause Microservices ... You have to fight!
Microservices
Microservices & Caching
Microservices amplify the importance of Caching Systems; among
the characteristics that explain this increase, worth mention:
● Microservices have their own data and there are many
● Microservices need to communicate!
● Different microservices have different needs
● Caching becomes part of the Resilience policies
● Caching to support a different persistence vision
● Microservices involve a more complex and powerful infrastructure
Microservices (EVCache Netflix)
Look Aside
Primary Storage
High-Availability
Transient Store
Microservices
The Microservices, on the infrastructural perspective, highlighted the need for a
layer of mediation and coordination of communications, today defined as
Service-Mesh.
Among the patterns deriving from the use of the Service-Mesh vision, Sidecar
has relevance: a container to aid a given Microservice.
Microservices
Service Mesh define, for Caching Systems, new possible topologies:
1) In-Process Cache for Microservice
2) Remote Cache (partitioned) external to the Service-Mesh
3) Remote Cache (partitioned) with Cache Client inside the Service-Mesh
(Sidecar)
4) Remote Cache (partitioned) with Caching System inside the Service-Mesh
( using Operators/Agent/Sidecar)
Microservices
In these scenarios the concepts of Eventual Consistency and Idempotency are
strengthened. The importance of having Streaming Systems and CDC Systems
emerges in the collaboration with the Caching System for important aspects,
among which:
● The persistence of Save Point / Critical Operations
● Alternative to 2PC Transactions
● The Data Propagation to suitable Listener subsystems
https://debezium.io/blog/2018/12/05/automating-cache-invalidation-with-change-data-capture/
https://medium.com/trabe/cache-invalidation-using-mqtt-e3bd8f6c2cf5
Microservices (EVCache Netflix - Replication)
...and remember that...
<< ...Everyone knows WHAT they do,
Some know HOW They do it, Few
people know WHY they do it!... >>
That's All Folks!

Contenu connexe

Similaire à Don’t give up, You can... Cache!

Cómo se diseña una base de datos que pueda ingerir más de cuatro millones de ...
Cómo se diseña una base de datos que pueda ingerir más de cuatro millones de ...Cómo se diseña una base de datos que pueda ingerir más de cuatro millones de ...
Cómo se diseña una base de datos que pueda ingerir más de cuatro millones de ...javier ramirez
 
BISSA: Empowering Web gadget Communication with Tuple Spaces
BISSA: Empowering Web gadget Communication with Tuple SpacesBISSA: Empowering Web gadget Communication with Tuple Spaces
BISSA: Empowering Web gadget Communication with Tuple SpacesSrinath Perera
 
Distributed systems - A Primer
Distributed systems - A PrimerDistributed systems - A Primer
Distributed systems - A PrimerMD Sayem Ahmed
 
Scalability for Startups (Frank Mashraqi, Startonomics SF 2008)
Scalability for Startups (Frank Mashraqi, Startonomics SF 2008)Scalability for Startups (Frank Mashraqi, Startonomics SF 2008)
Scalability for Startups (Frank Mashraqi, Startonomics SF 2008)Dealmaker Media
 
Scaling Security Workflows in Government Agencies
Scaling Security Workflows in Government AgenciesScaling Security Workflows in Government Agencies
Scaling Security Workflows in Government AgenciesAvere Systems
 
DataIntensiveComputing.pdf
DataIntensiveComputing.pdfDataIntensiveComputing.pdf
DataIntensiveComputing.pdfBrahmam8
 
Graylog Engineering - Design Your Architecture
Graylog Engineering - Design Your ArchitectureGraylog Engineering - Design Your Architecture
Graylog Engineering - Design Your ArchitectureGraylog
 
Meta scale kognitio hadoop webinar
Meta scale kognitio hadoop webinarMeta scale kognitio hadoop webinar
Meta scale kognitio hadoop webinarMichael Hiskey
 
Distributed caching with java JCache
Distributed caching with java JCacheDistributed caching with java JCache
Distributed caching with java JCacheKasun Gajasinghe
 
What drives Innovation? Innovations And Technological Solutions for the Distr...
What drives Innovation? Innovations And Technological Solutions for the Distr...What drives Innovation? Innovations And Technological Solutions for the Distr...
What drives Innovation? Innovations And Technological Solutions for the Distr...Stefano Fago
 
Managing Memory & Locks - Series 1 Memory Management
Managing  Memory & Locks - Series 1 Memory ManagementManaging  Memory & Locks - Series 1 Memory Management
Managing Memory & Locks - Series 1 Memory ManagementDAGEOP LTD
 
Basic principles of backup policies by Andrea Mauro, Backup Academy
Basic principles of backup policies by Andrea Mauro, Backup AcademyBasic principles of backup policies by Andrea Mauro, Backup Academy
Basic principles of backup policies by Andrea Mauro, Backup AcademyVeeam Software
 
BD_Architecture and Charateristics.pptx.pdf
BD_Architecture and Charateristics.pptx.pdfBD_Architecture and Charateristics.pptx.pdf
BD_Architecture and Charateristics.pptx.pdferamfatima43
 
Sql server tips from the field
Sql server tips from the fieldSql server tips from the field
Sql server tips from the fieldJoAnna Cheshire
 
Headless approach for offloading heavy tasks in Magento
Headless approach for offloading heavy tasks in MagentoHeadless approach for offloading heavy tasks in Magento
Headless approach for offloading heavy tasks in MagentoSander Mangel
 

Similaire à Don’t give up, You can... Cache! (20)

Cómo se diseña una base de datos que pueda ingerir más de cuatro millones de ...
Cómo se diseña una base de datos que pueda ingerir más de cuatro millones de ...Cómo se diseña una base de datos que pueda ingerir más de cuatro millones de ...
Cómo se diseña una base de datos que pueda ingerir más de cuatro millones de ...
 
BISSA: Empowering Web gadget Communication with Tuple Spaces
BISSA: Empowering Web gadget Communication with Tuple SpacesBISSA: Empowering Web gadget Communication with Tuple Spaces
BISSA: Empowering Web gadget Communication with Tuple Spaces
 
Distributed systems - A Primer
Distributed systems - A PrimerDistributed systems - A Primer
Distributed systems - A Primer
 
Memory comp
Memory compMemory comp
Memory comp
 
Scalability for Startups (Frank Mashraqi, Startonomics SF 2008)
Scalability for Startups (Frank Mashraqi, Startonomics SF 2008)Scalability for Startups (Frank Mashraqi, Startonomics SF 2008)
Scalability for Startups (Frank Mashraqi, Startonomics SF 2008)
 
Scaling Security Workflows in Government Agencies
Scaling Security Workflows in Government AgenciesScaling Security Workflows in Government Agencies
Scaling Security Workflows in Government Agencies
 
DataIntensiveComputing.pdf
DataIntensiveComputing.pdfDataIntensiveComputing.pdf
DataIntensiveComputing.pdf
 
Graylog Engineering - Design Your Architecture
Graylog Engineering - Design Your ArchitectureGraylog Engineering - Design Your Architecture
Graylog Engineering - Design Your Architecture
 
Megastore by Google
Megastore by GoogleMegastore by Google
Megastore by Google
 
Meta scale kognitio hadoop webinar
Meta scale kognitio hadoop webinarMeta scale kognitio hadoop webinar
Meta scale kognitio hadoop webinar
 
Fast Analytics
Fast Analytics Fast Analytics
Fast Analytics
 
Distributed caching with java JCache
Distributed caching with java JCacheDistributed caching with java JCache
Distributed caching with java JCache
 
Mini-Training: To cache or not to cache
Mini-Training: To cache or not to cacheMini-Training: To cache or not to cache
Mini-Training: To cache or not to cache
 
What drives Innovation? Innovations And Technological Solutions for the Distr...
What drives Innovation? Innovations And Technological Solutions for the Distr...What drives Innovation? Innovations And Technological Solutions for the Distr...
What drives Innovation? Innovations And Technological Solutions for the Distr...
 
Managing Memory & Locks - Series 1 Memory Management
Managing  Memory & Locks - Series 1 Memory ManagementManaging  Memory & Locks - Series 1 Memory Management
Managing Memory & Locks - Series 1 Memory Management
 
Basic principles of backup policies by Andrea Mauro, Backup Academy
Basic principles of backup policies by Andrea Mauro, Backup AcademyBasic principles of backup policies by Andrea Mauro, Backup Academy
Basic principles of backup policies by Andrea Mauro, Backup Academy
 
BD_Architecture and Charateristics.pptx.pdf
BD_Architecture and Charateristics.pptx.pdfBD_Architecture and Charateristics.pptx.pdf
BD_Architecture and Charateristics.pptx.pdf
 
Sql server tips from the field
Sql server tips from the fieldSql server tips from the field
Sql server tips from the field
 
Big data nyu
Big data nyuBig data nyu
Big data nyu
 
Headless approach for offloading heavy tasks in Magento
Headless approach for offloading heavy tasks in MagentoHeadless approach for offloading heavy tasks in Magento
Headless approach for offloading heavy tasks in Magento
 

Plus de Stefano Fago

Exploring Open Source Licensing
Exploring Open Source LicensingExploring Open Source Licensing
Exploring Open Source LicensingStefano Fago
 
Non solo Microservizi: API, Prodotti e Piattaforme
Non solo Microservizi: API, Prodotti e PiattaformeNon solo Microservizi: API, Prodotti e Piattaforme
Non solo Microservizi: API, Prodotti e PiattaformeStefano Fago
 
Resisting to The Shocks
Resisting to The ShocksResisting to The Shocks
Resisting to The ShocksStefano Fago
 
Gamification - Introduzione e Idee di un NON GIOCATORE
Gamification - Introduzione e Idee di un NON GIOCATOREGamification - Introduzione e Idee di un NON GIOCATORE
Gamification - Introduzione e Idee di un NON GIOCATOREStefano Fago
 
Quale IT nel futuro delle Banche?
Quale IT nel futuro delle Banche?Quale IT nel futuro delle Banche?
Quale IT nel futuro delle Banche?Stefano Fago
 
Microservices & Bento
Microservices & BentoMicroservices & Bento
Microservices & BentoStefano Fago
 
Reasoning about QRCode
Reasoning about QRCodeReasoning about QRCode
Reasoning about QRCodeStefano Fago
 
... thinking about Microformats!
... thinking about Microformats!... thinking about Microformats!
... thinking about Microformats!Stefano Fago
 
Uncommon Design Patterns
Uncommon Design PatternsUncommon Design Patterns
Uncommon Design PatternsStefano Fago
 
Riuso Object Oriented
Riuso Object OrientedRiuso Object Oriented
Riuso Object OrientedStefano Fago
 

Plus de Stefano Fago (12)

Exploring Open Source Licensing
Exploring Open Source LicensingExploring Open Source Licensing
Exploring Open Source Licensing
 
Non solo Microservizi: API, Prodotti e Piattaforme
Non solo Microservizi: API, Prodotti e PiattaformeNon solo Microservizi: API, Prodotti e Piattaforme
Non solo Microservizi: API, Prodotti e Piattaforme
 
Api and Fluency
Api and FluencyApi and Fluency
Api and Fluency
 
Resisting to The Shocks
Resisting to The ShocksResisting to The Shocks
Resisting to The Shocks
 
Gamification - Introduzione e Idee di un NON GIOCATORE
Gamification - Introduzione e Idee di un NON GIOCATOREGamification - Introduzione e Idee di un NON GIOCATORE
Gamification - Introduzione e Idee di un NON GIOCATORE
 
Quale IT nel futuro delle Banche?
Quale IT nel futuro delle Banche?Quale IT nel futuro delle Banche?
Quale IT nel futuro delle Banche?
 
Microservices & Bento
Microservices & BentoMicroservices & Bento
Microservices & Bento
 
Giochi in Azienda
Giochi in AziendaGiochi in Azienda
Giochi in Azienda
 
Reasoning about QRCode
Reasoning about QRCodeReasoning about QRCode
Reasoning about QRCode
 
... thinking about Microformats!
... thinking about Microformats!... thinking about Microformats!
... thinking about Microformats!
 
Uncommon Design Patterns
Uncommon Design PatternsUncommon Design Patterns
Uncommon Design Patterns
 
Riuso Object Oriented
Riuso Object OrientedRiuso Object Oriented
Riuso Object Oriented
 

Dernier

SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendArshad QA
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 

Dernier (20)

SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and Backend
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 

Don’t give up, You can... Cache!

  • 1. Don’t give up, You can... Cache! ...Reasoning about why Caching Systems are sometimes a pain... Crafted Software Meetup - 30/01/2020
  • 2. Hi! ● Stefano Fago ● Software Designer in UBI Banca ● Legacy Application, Middleware and R&D Backend https://www.linkedin.com/in/stefanofago/ https://github.com/stefanofago73
  • 3. Where are the Caches?
  • 4.
  • 5. How we face Caching?
  • 6.
  • 7. Why Caches can be a pain?
  • 8. Why Caches can be a pain? ...Because we forget that... ● a Cache hosts our DATA ● a cache IS NOT JUST AN ASSOCIATION ARRAY ● a cache is NOT a BUFFER ● a cache is NOT a POOL ● Business application ! = Twitter / Facebook / ... [Michael Plöd] Caching is not what you think it is! https://medium.com/@mauridb/caching-is-not-what-you-think-it-is-5104f8891b51 << ...caching should be done to decrease costs needed to increase performance and scalability and NOT to solve performance and scalability problems… >> [Davide Mauri]
  • 9. Why Caches can be a pain? ...Because we forget to set well defined goals and trade-off between: – Offloading : decrease the load of a system with limited and/or expensive resources – Performance : decrease network/cpu usage – Scale-out : horizontal growth of systems having data locality and working-sets ready – Resilience service resilience with fallback, default values, reuse of errors
  • 10. Why Caches can be a pain? ...Because we forget the important things...
  • 11. What can we do?
  • 12. What can we do? In order not to suffer with Caching we should: ● Decide on the type of cache to use ● Decide on an adoption path (How can we introduce Caches in our projects?) ● Know our data ● Decide on the trade-off between reads and writes ● Define trade-offs for Resilience and Security
  • 14. Different Kind of Caches ● Local/Internal ● In-Process ● Near Cache Processo Cache Processo Near Cache Cache Server Cache Server Cache Server
  • 15. Different Kind of Caches ● Remote/External ● Replicated ● Distributed(Partitioned) Processo Cache Cache Cache
  • 16. Different Kind of Caches ● In-Process : for reads and writes, small/medium size, it does not scale because it is limited to the process ● Near-Cache : better for reads, small/medium size, can scale in the relationship with the cluster (of which it is an local extension/expression) ● Replicated : data consistency for reads, small size, limited scalability ● Partitioned : for reads and writes, different sizes and ability to scale with fault tolerance
  • 17. Different Kind of Caches : DEV ● Small Cache Read-Only/Timed (In-Process) ● Memoization (In-Process/Near Cache) ● Cache (In-Process/Distributed-Partitioned) ● User Session/Working Set (In-Process/Distributed- Partitioned + … or NoSql) ● Distributed Memory (IMDG)
  • 18. Different Kind of Caches : Problems ● Cache Stampede/Thunderig Herd ( concurrent calls on a specific key not already there ) ● Cache Fault Tollerance ( error handling for the Caching subsystem, hierarchical caches, network error management, ...) ● Cache Security (privacy and security policies, regulations conformance, technical solutions)
  • 20. Adopt a Cache Can follow two paths depending on whether: ● Cache as First-Citizen in the Software Architecture (Caching Application Profiles) ● Cache as an evolution of a pre- existing system Added value is in the creation of a data models, to be changed over time, born from the evidence from the first phase. [Michael Plöd] (1) (2) (3)
  • 21. Adopt a Cache Cache observability, especially if distributed: ● Hit : the value sought is available ● Miss : the value sought is not available ● Cold/Hot : cache is empty/full ● Warm-Up : populating cache ● Hit Ratio : Hit/(Hits + Miss) ● Hit Rate : Hit/seconds ● Items Size : number of elements in cache ● Conc. Request/s : number of concurrent requests/s ● ...many others!
  • 22. Adopt a Cache Having Operations support: collaboration/synergy is important for network, metrics, deployment and emergency management aspects Have an alternative Plan : prepare alternatives that allow the system/service to be online in the event of widespread errors or unavailability of the Caching System Prepare a design where the Cache Provider is abstracted and appropriately hidden in terms of implementation to avoid unsolvable dependencies in the future!
  • 24. Know the Data What are the data to put in Cache? ● Most Used/Required ● Expensive to Calculate ● Expensive to Retrieve ● Common/Shareable Data The best are: read-only, frequently used and/or expensive to calculate
  • 25. Know the Data What characteristics of the data to choose? ● Data Type (Better NOT the DTO, NOT Business Object) ● Data Format (Textual? Binary? Custom?) ● Life Time of the Data (When It’s Stale/Fresh) ● Data Type volumes ● Serialization/Deserialization issues ● Data Affinity ● Data Compression (...if you really have to...)
  • 26. Know the Data What issues are related to the Data (areas): ● Cache Access ● Cache Eviction ● Cache Invalidation ● Data Search/Data Collections Management ● Definition of Unique Keys ● Cache Concurrency Support ● Storage (RAM, SSD, … ) ● Security/Regulations
  • 27. Know the Data : Eviction Forgetting is difficult for a cache: we have to find the trade-off between the usefulness of the data and the size of the cache! Concepts born from the optimization of linear research (Self-Organizing List https://en.wikipedia.org/wiki/Self-organizing_list ) ● Move To the Front ● Transpose ● Counting LRU LFU
  • 28. Know the Data : Eviction The frameworks, in a best-effort perspective, essentially offer LRU, LFU and the ability of creating customized policies. ● LRU: (recency) deletes the least recently used items. ● LFU: (frequency) based on access frequency, eliminates less frequently used Studies rise in the direction of Adaptive Systems using AI or statistical processing (on the history of data); can be offered better results in the compromise between memory, competition, speed! ● https://arxiv.org/pdf/1512.00727.pdf ● https://www.cs.bgu.ac.il/~tanm201/wiki.files/S1P2%20Adaptive%20Software %20Cache%20Management.pdf
  • 29. Know the Data : Eviction When LRU, LFU are not enough which element can improve the situation? Time! Applying timing policies or time windows for the aging of data or which restrict the validity of data, helps to have a better degree of adaptability ... but there is more!
  • 30. Know the Data : Eviction
  • 31. Know the Data : Problems ● Cache Trashing the pattern of data usage is such that the cache is useless ● Cold Cache an empty cache takes time to be useful! ● Cache Security like any system there are privacy and security issues (what about GDPR?): ● Data anonymization ● Cache Penetration ● Cache Avalanche
  • 33. Access Patterns Accessing or entering Data in a cache means also choosing its role and the trade-off between reads and writes... ● Cache-Aside ● Cache-Through ● Write-Around ● Refresh-Ahead ● Write-Back ( Write-Behind)
  • 34. Access Patterns Cache-Aside : the application is responsible for reads and writes to storage as well as to the cache that is collateral to storage
  • 35. Access Patterns Related to Cache-Aside are: ● Look-Aside : The value is first searched in the cache and then in the storage ● Demand-Fill : Implies that in the case of MISS not only is the value returned from the storage but it will also be placed in the cache Cache-Aside generally provides both the LOOK-ASIDE and the DEMAND- FILL but it is not mandatory that both are present: in a Pub/Sub system, Cache and Storage can be subscribers of the same Publisher but they materialize the data for two different reasons.
  • 36. Access Patterns Cache-Through : Write-Through/Read-Through The application treats the cache as if it were the main storage; reads / writes take place through the cache and propagated synchronously on the storage
  • 37. Access Patterns Write-Around : The application reads from the cache but for writes this is avoided. When data is new then is written directly to the storage: it’s in the case of reads that the cache is filled with data. (Useful when there are many writes and few reads).
  • 38. Access Patterns Refresh-Ahead : The cache is updated, also by scheduling, asynchronously, for the recently accessed elements, before these expire
  • 39. Access Patterns Write-Back ( Write-Behind) : The application writes on the cache but the propagation on the storage takes place asynchronously (generally there is a delay configured, it assumes a queue system; trade-off between high throughput and problems on data consistency)
  • 40. Access Patterns : DEV ● Cache Aside ● Cache Through ● Cache Selective Bypass ● Cache Massive Load ● Cache Full Cleaning (+ Warmer)
  • 42. The Club Rules 1) Don’t speak about cache 2) Don’t speak about cache: if you do it, made it not at the expense of your services 3) Define the price you are willing to pay 4) If you change the rules of the game you must be aware of it 5) Design in a simple way: start local, works on definable models 6) Measure, measure, measure: the cache gives you data and hints 7) Cache tuning takes time and changes over time 8) If you are in the Club ‘cause Microservices ... You have to fight!
  • 44. Microservices & Caching Microservices amplify the importance of Caching Systems; among the characteristics that explain this increase, worth mention: ● Microservices have their own data and there are many ● Microservices need to communicate! ● Different microservices have different needs ● Caching becomes part of the Resilience policies ● Caching to support a different persistence vision ● Microservices involve a more complex and powerful infrastructure
  • 45. Microservices (EVCache Netflix) Look Aside Primary Storage High-Availability Transient Store
  • 46. Microservices The Microservices, on the infrastructural perspective, highlighted the need for a layer of mediation and coordination of communications, today defined as Service-Mesh. Among the patterns deriving from the use of the Service-Mesh vision, Sidecar has relevance: a container to aid a given Microservice.
  • 47. Microservices Service Mesh define, for Caching Systems, new possible topologies: 1) In-Process Cache for Microservice 2) Remote Cache (partitioned) external to the Service-Mesh 3) Remote Cache (partitioned) with Cache Client inside the Service-Mesh (Sidecar) 4) Remote Cache (partitioned) with Caching System inside the Service-Mesh ( using Operators/Agent/Sidecar)
  • 48. Microservices In these scenarios the concepts of Eventual Consistency and Idempotency are strengthened. The importance of having Streaming Systems and CDC Systems emerges in the collaboration with the Caching System for important aspects, among which: ● The persistence of Save Point / Critical Operations ● Alternative to 2PC Transactions ● The Data Propagation to suitable Listener subsystems https://debezium.io/blog/2018/12/05/automating-cache-invalidation-with-change-data-capture/ https://medium.com/trabe/cache-invalidation-using-mqtt-e3bd8f6c2cf5
  • 50. ...and remember that... << ...Everyone knows WHAT they do, Some know HOW They do it, Few people know WHY they do it!... >>