SlideShare ist ein Scribd-Unternehmen logo
1 von 21
CHI: Universal caching
      for Perl
       Jonathan Swartz
       YAPC::NA 2012
         Madison, WI
What is CHI?

•   Cache Handling Interface

•   Standard interface and implementation for Perl
    caching ... like 'DBI for caching'

•   Caching = “Get and set key/values with expiration”
We already have...
What’s it good for?
•   Implement standard caching features in a single place
    •   Namespaces                •   Logging

    •   Serialization             •   Statistics collection

    •   Multilevel caches         •   Error handling

    •   Probablistic expiration   •   Compression

    •   Max size and discard      •   Configuration

•   Make new cache backends trivial to create
Who needs caches?

•   Web frameworks (Catalyst, Dancer, ...)

•   Sessions (Plack::Session, CGI::Session, ...)

•   ORMs (DBIx::Class, RDBO, ...)

•   Templating (TT, Mason, ...)

•   Code processing (Perl::Tidy, Perl::Critic, ...)

•   Slow to startup (Class::MOP/Moose, ...)
Using CHI
Namespaces
•   Separate cache keys into silos

•   Can be inspected, configured, and cleared
    independently

•   Typically package or template name
Drivers
•   Memory/RawMemory - In-process memory

•   File - Hierarchical, one file per entry

•   FastMmap - Mmap'ed files

•   BerkeleyDB

•   DBI

•   Memcached, Redis, TokyoTyrant - Distributed

•   ...
Probabilistic expiration
• Good for avoiding “miss stampedes”
L1/L2 cache
•   Store sessions in mysql, fronted by memcached
Mirror cache
•   Migrate cache from /old/root to /new/root
CHI::Memoize
•   Like Memoize, only CHI-ier
Why is compute() better?


•   Less typing

•   Background recomputation *
    (return old value immediately, recompute in background)

•   Can measure compute time and thus cache utility
    * - theoretical, not yet implemented
Cache utility
HR         =   hit rate
Cget       =   cost of get
Cset       =   cost of set
Ccompute   =   cost of compute

          Cget + (Ccompute + Cset) / HR
Utility = -------------------------------
                     Ccompute
Stats
Stats collected per namespace



•   # hits, misses, and sets   hit rate

•   avg cost of get, set, and compute (ms)

•   avg key and value size
Resources

• Get CHI from CPAN -
  http://search.cpan.org/perldoc?CHI

• Search for drivers -
  http://cpan.uwinnipeg.ca/search?query=CHI::Driver

• Subscribe to perl-cache mailing list -
  http://groups.google.com/group/perl-cache-discuss
Benchmarks
Description                    Get time   Set time
CHI::Driver::MemoryRaw         0.019ms    0.036ms
CHI::Driver::Memory            0.042ms    0.066ms
CHI::Driver::BerkeleyDB        0.052ms    0.073ms
CHI::Driver::FastMmap          0.057ms    0.087ms
CHI::Driver::DBI (sqlite)      0.112ms    1.659ms
CHI::Driver::File              0.118ms    1.138ms
CHI::Driver::Memcached::Fast   0.138ms    0.178ms
CHI::Driver::Memcached::libm   0.151ms    0.202ms
CHI::Driver::DBI (mysql)       0.236ms    0.273ms
CHI::Driver::Memcached         0.279ms    0.235ms
Creating a driver
Creating a cache
my $cache = CHI->new(
    driver     => 'File',
    namespace => ‘Foo::Bar’,
    cache_root => '/path/to/root'
);
my $cache = CHI->new(
    driver     => 'FastMmap',
    root_dir   => '/path/to/root',
    cache_size => '1k'
);
my $cache = CHI->new(
    driver => 'Memcached',
    servers => ["10.0.0.15:11211”, ...]
);

Weitere ähnliche Inhalte

Was ist angesagt?

Nodejs - Should Ruby Developers Care?
Nodejs - Should Ruby Developers Care?Nodejs - Should Ruby Developers Care?
Nodejs - Should Ruby Developers Care?Felix Geisendörfer
 
Elasticsearch 1.x Cluster Installation (VirtualBox)
Elasticsearch 1.x Cluster Installation (VirtualBox)Elasticsearch 1.x Cluster Installation (VirtualBox)
Elasticsearch 1.x Cluster Installation (VirtualBox)Amir Sedighi
 
Scaling WordPress On A Small Budget
Scaling WordPress On A Small BudgetScaling WordPress On A Small Budget
Scaling WordPress On A Small BudgetBrecht Ryckaert
 
Highload осень 2012 лекция 3
Highload осень 2012 лекция 3Highload осень 2012 лекция 3
Highload осень 2012 лекция 3Technopark
 
Building low latency java applications with ehcache
Building low latency java applications with ehcacheBuilding low latency java applications with ehcache
Building low latency java applications with ehcacheChris Westin
 
Sofia WP User Group Presentation
Sofia WP User Group PresentationSofia WP User Group Presentation
Sofia WP User Group PresentationDaniel Kanchev
 
Node.js - A practical introduction (v2)
Node.js  - A practical introduction (v2)Node.js  - A practical introduction (v2)
Node.js - A practical introduction (v2)Felix Geisendörfer
 
cache concepts and varnish-cache
cache concepts and varnish-cachecache concepts and varnish-cache
cache concepts and varnish-cacheMarc Cortinas Val
 
Azure Recovery Services
Azure Recovery ServicesAzure Recovery Services
Azure Recovery ServicesPavel Revenkov
 
Scalability at GROU.PS
Scalability at GROU.PSScalability at GROU.PS
Scalability at GROU.PSesokullu
 
To Hire, or to train, that is the question (Percona Live 2014)
To Hire, or to train, that is the question (Percona Live 2014)To Hire, or to train, that is the question (Percona Live 2014)
To Hire, or to train, that is the question (Percona Live 2014)Geoffrey Anderson
 
Backup, Restore, and Disaster Recovery
Backup, Restore, and Disaster RecoveryBackup, Restore, and Disaster Recovery
Backup, Restore, and Disaster RecoveryMongoDB
 

Was ist angesagt? (20)

Node.js - As a networking tool
Node.js - As a networking toolNode.js - As a networking tool
Node.js - As a networking tool
 
Nodejs - Should Ruby Developers Care?
Nodejs - Should Ruby Developers Care?Nodejs - Should Ruby Developers Care?
Nodejs - Should Ruby Developers Care?
 
Nodejs - A quick tour (v4)
Nodejs - A quick tour (v4)Nodejs - A quick tour (v4)
Nodejs - A quick tour (v4)
 
Elasticsearch 1.x Cluster Installation (VirtualBox)
Elasticsearch 1.x Cluster Installation (VirtualBox)Elasticsearch 1.x Cluster Installation (VirtualBox)
Elasticsearch 1.x Cluster Installation (VirtualBox)
 
Scaling WordPress On A Small Budget
Scaling WordPress On A Small BudgetScaling WordPress On A Small Budget
Scaling WordPress On A Small Budget
 
Highload осень 2012 лекция 3
Highload осень 2012 лекция 3Highload осень 2012 лекция 3
Highload осень 2012 лекция 3
 
Memcached
MemcachedMemcached
Memcached
 
Building low latency java applications with ehcache
Building low latency java applications with ehcacheBuilding low latency java applications with ehcache
Building low latency java applications with ehcache
 
Nodejs - A quick tour (v5)
Nodejs - A quick tour (v5)Nodejs - A quick tour (v5)
Nodejs - A quick tour (v5)
 
Sofia WP User Group Presentation
Sofia WP User Group PresentationSofia WP User Group Presentation
Sofia WP User Group Presentation
 
Caching
CachingCaching
Caching
 
Node.js - A practical introduction (v2)
Node.js  - A practical introduction (v2)Node.js  - A practical introduction (v2)
Node.js - A practical introduction (v2)
 
Node.js - A Quick Tour II
Node.js - A Quick Tour IINode.js - A Quick Tour II
Node.js - A Quick Tour II
 
cache concepts and varnish-cache
cache concepts and varnish-cachecache concepts and varnish-cache
cache concepts and varnish-cache
 
Banquet 36
Banquet 36Banquet 36
Banquet 36
 
Azure Recovery Services
Azure Recovery ServicesAzure Recovery Services
Azure Recovery Services
 
Scalability at GROU.PS
Scalability at GROU.PSScalability at GROU.PS
Scalability at GROU.PS
 
To Hire, or to train, that is the question (Percona Live 2014)
To Hire, or to train, that is the question (Percona Live 2014)To Hire, or to train, that is the question (Percona Live 2014)
To Hire, or to train, that is the question (Percona Live 2014)
 
Automating with Ansible
Automating with AnsibleAutomating with Ansible
Automating with Ansible
 
Backup, Restore, and Disaster Recovery
Backup, Restore, and Disaster RecoveryBackup, Restore, and Disaster Recovery
Backup, Restore, and Disaster Recovery
 

Andere mochten auch

Portfolio For Library Course By Teng Miao(Eric)
Portfolio For Library Course By Teng Miao(Eric)Portfolio For Library Course By Teng Miao(Eric)
Portfolio For Library Course By Teng Miao(Eric)guestac1d7c
 
Chiaccherata sulla democrazia partecipata
Chiaccherata sulla democrazia partecipataChiaccherata sulla democrazia partecipata
Chiaccherata sulla democrazia partecipataGianluigi Cogo
 
Uspto reexamination request - update - august 8th to august 14th, 2012 - in...
Uspto   reexamination request - update - august 8th to august 14th, 2012 - in...Uspto   reexamination request - update - august 8th to august 14th, 2012 - in...
Uspto reexamination request - update - august 8th to august 14th, 2012 - in...InvnTree IP Services Pvt. Ltd.
 

Andere mochten auch (7)

Zadar digit presentation
Zadar digit presentationZadar digit presentation
Zadar digit presentation
 
Canal yoga-kit-iniciante
Canal yoga-kit-inicianteCanal yoga-kit-iniciante
Canal yoga-kit-iniciante
 
Portfolio For Library Course By Teng Miao(Eric)
Portfolio For Library Course By Teng Miao(Eric)Portfolio For Library Course By Teng Miao(Eric)
Portfolio For Library Course By Teng Miao(Eric)
 
Chiaccherata sulla democrazia partecipata
Chiaccherata sulla democrazia partecipataChiaccherata sulla democrazia partecipata
Chiaccherata sulla democrazia partecipata
 
Uspto reexamination request - update - august 8th to august 14th, 2012 - in...
Uspto   reexamination request - update - august 8th to august 14th, 2012 - in...Uspto   reexamination request - update - august 8th to august 14th, 2012 - in...
Uspto reexamination request - update - august 8th to august 14th, 2012 - in...
 
Routing 7
Routing 7Routing 7
Routing 7
 
Contract
ContractContract
Contract
 

Ähnlich wie CHI - YAPC NA 2012

Introduction to memcached
Introduction to memcachedIntroduction to memcached
Introduction to memcachedJurriaan Persyn
 
Caching with Memcached and APC
Caching with Memcached and APCCaching with Memcached and APC
Caching with Memcached and APCBen Ramsey
 
Where Django Caching Bust at the Seams
Where Django Caching Bust at the SeamsWhere Django Caching Bust at the Seams
Where Django Caching Bust at the SeamsConcentric Sky
 
Caching Methodology & Strategies
Caching Methodology & StrategiesCaching Methodology & Strategies
Caching Methodology & StrategiesTiệp Vũ
 
Caching methodology and strategies
Caching methodology and strategiesCaching methodology and strategies
Caching methodology and strategiesTiep Vu
 
phptek13 - Caching and tuning fun tutorial
phptek13 - Caching and tuning fun tutorialphptek13 - Caching and tuning fun tutorial
phptek13 - Caching and tuning fun tutorialWim Godden
 
Caching your rails application
Caching your rails applicationCaching your rails application
Caching your rails applicationArrrrCamp
 
Caching and tuning fun for high scalability
Caching and tuning fun for high scalabilityCaching and tuning fun for high scalability
Caching and tuning fun for high scalabilityWim Godden
 
Using cassandra as a distributed logging to store pb data
Using cassandra as a distributed logging to store pb dataUsing cassandra as a distributed logging to store pb data
Using cassandra as a distributed logging to store pb dataRamesh Veeramani
 
Ruby and Distributed Storage Systems
Ruby and Distributed Storage SystemsRuby and Distributed Storage Systems
Ruby and Distributed Storage SystemsSATOSHI TAGOMORI
 
High Performance With Java
High Performance With JavaHigh Performance With Java
High Performance With Javamalduarte
 
Caching and tuning fun for high scalability
Caching and tuning fun for high scalabilityCaching and tuning fun for high scalability
Caching and tuning fun for high scalabilityWim Godden
 
Memcached: What is it and what does it do?
Memcached: What is it and what does it do?Memcached: What is it and what does it do?
Memcached: What is it and what does it do?Brian Moon
 
CREAM - That Conference Austin - January 2024.pptx
CREAM - That Conference Austin - January 2024.pptxCREAM - That Conference Austin - January 2024.pptx
CREAM - That Conference Austin - January 2024.pptxMatthew Groves
 
Configuration Management in the Cloud - Cloud Phoenix Meetup Feb 2014
Configuration Management in the Cloud - Cloud Phoenix Meetup Feb 2014Configuration Management in the Cloud - Cloud Phoenix Meetup Feb 2014
Configuration Management in the Cloud - Cloud Phoenix Meetup Feb 2014Miguel Zuniga
 
Speeding Up The Snail
Speeding Up The SnailSpeeding Up The Snail
Speeding Up The SnailMarcus Deglos
 
Yapc10 Cdt World Domination
Yapc10   Cdt World DominationYapc10   Cdt World Domination
Yapc10 Cdt World DominationcPanel
 
php & performance
 php & performance php & performance
php & performancesimon8410
 

Ähnlich wie CHI - YAPC NA 2012 (20)

Introduction to memcached
Introduction to memcachedIntroduction to memcached
Introduction to memcached
 
Caching with Memcached and APC
Caching with Memcached and APCCaching with Memcached and APC
Caching with Memcached and APC
 
Where Django Caching Bust at the Seams
Where Django Caching Bust at the SeamsWhere Django Caching Bust at the Seams
Where Django Caching Bust at the Seams
 
Caching Methodology & Strategies
Caching Methodology & StrategiesCaching Methodology & Strategies
Caching Methodology & Strategies
 
Caching methodology and strategies
Caching methodology and strategiesCaching methodology and strategies
Caching methodology and strategies
 
Top ten-list
Top ten-listTop ten-list
Top ten-list
 
phptek13 - Caching and tuning fun tutorial
phptek13 - Caching and tuning fun tutorialphptek13 - Caching and tuning fun tutorial
phptek13 - Caching and tuning fun tutorial
 
Caching your rails application
Caching your rails applicationCaching your rails application
Caching your rails application
 
Caching and tuning fun for high scalability
Caching and tuning fun for high scalabilityCaching and tuning fun for high scalability
Caching and tuning fun for high scalability
 
Using cassandra as a distributed logging to store pb data
Using cassandra as a distributed logging to store pb dataUsing cassandra as a distributed logging to store pb data
Using cassandra as a distributed logging to store pb data
 
Ruby and Distributed Storage Systems
Ruby and Distributed Storage SystemsRuby and Distributed Storage Systems
Ruby and Distributed Storage Systems
 
High Performance With Java
High Performance With JavaHigh Performance With Java
High Performance With Java
 
Caching and tuning fun for high scalability
Caching and tuning fun for high scalabilityCaching and tuning fun for high scalability
Caching and tuning fun for high scalability
 
AppFabric Velocity
AppFabric VelocityAppFabric Velocity
AppFabric Velocity
 
Memcached: What is it and what does it do?
Memcached: What is it and what does it do?Memcached: What is it and what does it do?
Memcached: What is it and what does it do?
 
CREAM - That Conference Austin - January 2024.pptx
CREAM - That Conference Austin - January 2024.pptxCREAM - That Conference Austin - January 2024.pptx
CREAM - That Conference Austin - January 2024.pptx
 
Configuration Management in the Cloud - Cloud Phoenix Meetup Feb 2014
Configuration Management in the Cloud - Cloud Phoenix Meetup Feb 2014Configuration Management in the Cloud - Cloud Phoenix Meetup Feb 2014
Configuration Management in the Cloud - Cloud Phoenix Meetup Feb 2014
 
Speeding Up The Snail
Speeding Up The SnailSpeeding Up The Snail
Speeding Up The Snail
 
Yapc10 Cdt World Domination
Yapc10   Cdt World DominationYapc10   Cdt World Domination
Yapc10 Cdt World Domination
 
php & performance
 php & performance php & performance
php & performance
 

Kürzlich hochgeladen

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 

Kürzlich hochgeladen (20)

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 

CHI - YAPC NA 2012

  • 1. CHI: Universal caching for Perl Jonathan Swartz YAPC::NA 2012 Madison, WI
  • 2. What is CHI? • Cache Handling Interface • Standard interface and implementation for Perl caching ... like 'DBI for caching' • Caching = “Get and set key/values with expiration”
  • 4. What’s it good for? • Implement standard caching features in a single place • Namespaces • Logging • Serialization • Statistics collection • Multilevel caches • Error handling • Probablistic expiration • Compression • Max size and discard • Configuration • Make new cache backends trivial to create
  • 5. Who needs caches? • Web frameworks (Catalyst, Dancer, ...) • Sessions (Plack::Session, CGI::Session, ...) • ORMs (DBIx::Class, RDBO, ...) • Templating (TT, Mason, ...) • Code processing (Perl::Tidy, Perl::Critic, ...) • Slow to startup (Class::MOP/Moose, ...)
  • 7. Namespaces • Separate cache keys into silos • Can be inspected, configured, and cleared independently • Typically package or template name
  • 8. Drivers • Memory/RawMemory - In-process memory • File - Hierarchical, one file per entry • FastMmap - Mmap'ed files • BerkeleyDB • DBI • Memcached, Redis, TokyoTyrant - Distributed • ...
  • 9. Probabilistic expiration • Good for avoiding “miss stampedes”
  • 10. L1/L2 cache • Store sessions in mysql, fronted by memcached
  • 11. Mirror cache • Migrate cache from /old/root to /new/root
  • 12. CHI::Memoize • Like Memoize, only CHI-ier
  • 13. Why is compute() better? • Less typing • Background recomputation * (return old value immediately, recompute in background) • Can measure compute time and thus cache utility * - theoretical, not yet implemented
  • 14. Cache utility HR = hit rate Cget = cost of get Cset = cost of set Ccompute = cost of compute Cget + (Ccompute + Cset) / HR Utility = ------------------------------- Ccompute
  • 15. Stats
  • 16. Stats collected per namespace • # hits, misses, and sets hit rate • avg cost of get, set, and compute (ms) • avg key and value size
  • 17. Resources • Get CHI from CPAN - http://search.cpan.org/perldoc?CHI • Search for drivers - http://cpan.uwinnipeg.ca/search?query=CHI::Driver • Subscribe to perl-cache mailing list - http://groups.google.com/group/perl-cache-discuss
  • 18.
  • 19. Benchmarks Description Get time Set time CHI::Driver::MemoryRaw 0.019ms 0.036ms CHI::Driver::Memory 0.042ms 0.066ms CHI::Driver::BerkeleyDB 0.052ms 0.073ms CHI::Driver::FastMmap 0.057ms 0.087ms CHI::Driver::DBI (sqlite) 0.112ms 1.659ms CHI::Driver::File 0.118ms 1.138ms CHI::Driver::Memcached::Fast 0.138ms 0.178ms CHI::Driver::Memcached::libm 0.151ms 0.202ms CHI::Driver::DBI (mysql) 0.236ms 0.273ms CHI::Driver::Memcached 0.279ms 0.235ms
  • 21. Creating a cache my $cache = CHI->new( driver => 'File', namespace => ‘Foo::Bar’, cache_root => '/path/to/root' ); my $cache = CHI->new( driver => 'FastMmap', root_dir => '/path/to/root', cache_size => '1k' ); my $cache = CHI->new( driver => 'Memcached', servers => ["10.0.0.15:11211”, ...] );

Hinweis der Redaktion

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n