SlideShare una empresa de Scribd logo
1 de 46
Descargar para leer sin conexión
<?PHP Performance ?>
                       w/APC + Memcached
                              for Windows

@FordAntiTrust
thaicyberpoint.com
thaithinkpad.com
thaihi5.com
Cache Theory ?
Cache Theory ?

             Req
                               1 Check

                      2 Miss
        Compute

                   Store 3        Cache
     4 Hit
         Output

                     Miss - [Store] - Hit
Type ?
                    Fast                                Slow




http://ralphlosey.files.wordpress.com/2007/06/ram.jpg
http://www.pctechguide.com/images/31HardDrive.jpg
APC ?

Alternative PHP Cache
Opcode Cache and Variables Cache




            Automatic update w/code changes




Code not changes request and Simply Installation
Free & Open Source
PHP Flow
                                             Req
• Scanning and Lexing
  (Plain Text to Tokens)

• Parsing                              • Scanning
                                       • Lexing
  (Tokens to Expressions)              • Parsing
                                       • Compilation
• Compilation
  (Translated Expressions to Opcode)

• Execution                             Execution
  (Opcode stacks are processed)

                                          Output
Normal PHP vs APC
Normal PHP vs APC
                  Req


            • Scanning
            • Lexing
            • Parsing
            • Compilation




             Execution


               Output
Normal PHP vs APC
             Req

           APC hook

       • Scanning
       • Lexing
       • Parsing           Miss
       • Compilation
           APC hook    Store      Opcode
                                   cache
        Execution
                           Hit

          Output
Why ?
Why ?




        http://ralphschindler.com/
Why ?




        http://ralphschindler.com/
Installation
• Windows (http://downloads.php.net/pierre/)
  – extension=php_apc.dll
Installation
• Windows (http://downloads.php.net/pierre/)
  – extension=php_apc.dll
• Basic PECL
  (http://pecl.php.net)
  – pecl install apc
Installation
• Windows (http://downloads.php.net/pierre/)
  – extension=php_apc.dll
                            Conf
• Basic PECL
  (http://pecl.php.net)
  – pecl install apc
Benchmark
                                         PHP Native               PHP w/APC
Concurrency Level                                                10
Time taken for tests                                       60 seconds
Complete requests                        298                      914

Total transferred                        643,149 bytes            1,962,675 bytes

HTML transferred                         516,971 bytes            1,582,035 bytes

Requests per second                      4.91 [#/sec] (mean)      15.21 [#/sec] (mean)

Time per request                         2035.405 [ms] (mean)     657.623 [ms] (mean)

Time per request                         203.541 [ms]             65.762 [ms]
(mean, across all concurrent requests)
Transfer rate                            10.35 [KB/s] received    31.88 [KB/s] received
Memcached
History



    “Developed by Danga Interactive for
             LiveJournal.com”
Memcached ?
• a distributed memory object caching system
  with hash table
Memcached ?
• a distributed memory object caching system
  with hash table
Memcached ?
• a distributed memory object caching system
  with hash table
• a generic two stage hashing system (clients
  and servers). Clients are written for specific
  application languages. Server is written in C
Memcached ?
• a distributed memory object caching system
  with hash table
• a generic two stage hashing system (clients
  and servers). Clients are written for specific
  application languages. Server is written in C
Memcached ?
• a distributed memory object caching system
  with hash table
• a generic two stage hashing system (clients
  and servers). Clients are written for specific
  application languages. Server is written in C
• 85% of top 20 sites use memcached; 50%+ of
  top 5k sites uses Memcached
Memcached ?
• a distributed memory object caching system
  with hash table
• a generic two stage hashing system (clients
  and servers). Clients are written for specific
  application languages. Server is written in C
• 85% of top 20 sites use memcached; 50%+ of
  top 5k sites uses Memcached
Limits (c/Hash Table)
• Key : max 250 chars.
• Values: max 1MB
Why Memcached ?
• Scale-out
  – Machine
  – Process (Use different ports)
• Memory faster than Disk
• Allows for efficient use of your database
• Can utilize existing network
  – Uses non-blocking network I/O (TCP/IP)
• Very flexible
• Client libraries in all major languages
“We use more than 800 servers supplying over
     28 terabytes of memory to our users.”

     “total throughput achieved is 300,000 UDP req/s”
                                       by Paul Saab Saturday, December 13, 2008 at 2:43am
 •   8-core machines
 •   20-30% CPU usage.
 •   scale memcached to 8 threads on an 8-core system
 •   moved to UDP for get operations to reduce network traffic


http://www.facebook.com/note.php?note_id=39391378919
Architecture practical ?




http://barry.files.wordpress.com/2007/04/new-servers-back-04-2007.jpg
Cache
                   Memcached
     APC            Memcached
                    Instance                 Reverse
                      Memcached
                      Instance
                         Memcached
                        Instance              Proxy
                          Instance
                                                                            I
                                                                            n
                                                                            t
                                                                            e
     PHP Web App
                                             Web Server                     r
                                                                            n
                                                                            e
                                       Session                      Files
                                                                            t
                           Memcached               Memcached
                            Memcached
                            Instance                Memcached
                                                    Instance
 Master    Slave              Memcached
                              Instance                Memcached
                                                      Instance
                                 Memcached
                                Instance                Instance
                                                          CDN/DFS
                                  Instance
DB
Installation & Used
memcached binary packages
• http://labs.northscale.com/memcached-packages/

1.   Unzip into a directory of choice
2.   Open the shell of your choice (i.e. cmd.exe); cd into the directory
3.   Run memcached.exe passing standard arguments.


Sample
C:memcachedmemcached.exe -m 128 -p 11211 -l 127.0.0.1 -d
PHP Session w/Memcached
session.save_handler = files
session.save_path = “C:/Windows/temp”

TO

session.save_handler = memcache
session.save_path = “tcp://server:port “

OR

ini_set('session.save_handler', 'memcache');
ini_set('session.save_path', 'tcp://server:port,tcp://server:port');
Coding ? (in PHP)
/* OO API */
$memcacheObj = new Memcache;
$memcacheObj->connect('memcache_host', 11211);

/* set */
$memcacheObj->set('key', 'data', MEMCACHE_COMPRESSED, 50);
/ * get w/single key */
$var = $memcacheObj->get('key');
/ * get w/multiple key */
$var = $memcacheObj->get(array('key1', 'key2'));

$memcacheObj->close();
CMS ?
• Drupal has Memcache API and Integration
  http://drupal.org/project/memcache
• Wordpress has object cache
  http://mohanjith.net/blog/2008/10/using-memcached-with-
  wordpress-object-cache.html
Tips
Two Level Caching with Zend_Cache

• Tagging System in Files Cache
• Memcached Key used Tagging System
Two Level Caching - Workflow

                 Req



 Compute       Files Cache

                                       Memcached




     Output

                        1. Check   3. Store
                        2. Miss    4. Hit
Implement with Zend_Cache
Used Two Level with Zend_Cache
Ref.
• Improving PHP Application Performance with APC
     http://www.slideshare.net/vortexau/improving-php-application-
     performance-with-apc-presentation
• PHP Accelerators : APC vs Zend vs XCache with Zend
  Framework
     http://blog.digitalstruct.com/2007/12/23/php-accelerators-apc-vs-zend-vs-
     xcache-with-zend-framework/
• Scaling with memcached
     http://www.slideshare.net/acme/scaling-with-memcached
• Gear6 and Scaling Website Performance: Caching Session and
  Profile Data with Memcached
     http://www.slideshare.net/gear6memcached/gear6-and-scaling-website-
     performance-caching-session-and-profile-data-with-memcached
Ref. (2)
• PHP: Memcache - Manual
  http://th.php.net/manual/en/book.memcache.php
• http://danga.com/memcached/
• http://pecl.php.net/package/memcache
• http://www.socialtext.net/memcached/
Discussion
   Q&A
Thank you
           @FordAntiTrust
http://www.slideshare.net/FordAntiTrust

Más contenido relacionado

La actualidad más candente

WE18_Performance_Up.ppt
WE18_Performance_Up.pptWE18_Performance_Up.ppt
WE18_Performance_Up.pptwebhostingguy
 
[MathWorks] Versioning Infrastructure
[MathWorks] Versioning Infrastructure[MathWorks] Versioning Infrastructure
[MathWorks] Versioning InfrastructurePerforce
 
WordPress Performance & Scalability
WordPress Performance & ScalabilityWordPress Performance & Scalability
WordPress Performance & ScalabilityJoseph Scott
 
Apache Performance Tuning: Scaling Up
Apache Performance Tuning: Scaling UpApache Performance Tuning: Scaling Up
Apache Performance Tuning: Scaling UpSander Temme
 
Nginx Internals
Nginx InternalsNginx Internals
Nginx InternalsJoshua Zhu
 
Web Server Load Balancer
Web Server Load BalancerWeb Server Load Balancer
Web Server Load BalancerMobME Technical
 
Supercharging your PHP pages with mod_lsapi in CloudLinux OS
Supercharging your PHP pages with mod_lsapi in CloudLinux OSSupercharging your PHP pages with mod_lsapi in CloudLinux OS
Supercharging your PHP pages with mod_lsapi in CloudLinux OSCloudLinux
 
Apache Traffic Server & Lua
Apache Traffic Server & LuaApache Traffic Server & Lua
Apache Traffic Server & LuaKit Chan
 
NginX - good practices, tips and advanced techniques
NginX - good practices, tips and advanced techniquesNginX - good practices, tips and advanced techniques
NginX - good practices, tips and advanced techniquesClaudio Borges
 
Memcached B box presentation
Memcached B box presentationMemcached B box presentation
Memcached B box presentationNagesh Chinkeri
 
Apache httpd 2.4: The Cloud Killer App
Apache httpd 2.4: The Cloud Killer AppApache httpd 2.4: The Cloud Killer App
Apache httpd 2.4: The Cloud Killer AppJim Jagielski
 
Php psr standard 2014 01-22
Php psr standard 2014 01-22Php psr standard 2014 01-22
Php psr standard 2014 01-22Võ Duy Tuấn
 
J Ruby Whirlwind Tour
J Ruby Whirlwind TourJ Ruby Whirlwind Tour
J Ruby Whirlwind Touroscon2007
 
Zendcon scaling magento
Zendcon scaling magentoZendcon scaling magento
Zendcon scaling magentoMathew Beane
 
MNPHP Scalable Architecture 101 - Feb 3 2011
MNPHP Scalable Architecture 101 - Feb 3 2011MNPHP Scalable Architecture 101 - Feb 3 2011
MNPHP Scalable Architecture 101 - Feb 3 2011Mike Willbanks
 

La actualidad más candente (20)

WE18_Performance_Up.ppt
WE18_Performance_Up.pptWE18_Performance_Up.ppt
WE18_Performance_Up.ppt
 
are available here
are available hereare available here
are available here
 
[MathWorks] Versioning Infrastructure
[MathWorks] Versioning Infrastructure[MathWorks] Versioning Infrastructure
[MathWorks] Versioning Infrastructure
 
Performance_Up.ppt
Performance_Up.pptPerformance_Up.ppt
Performance_Up.ppt
 
WordPress Performance & Scalability
WordPress Performance & ScalabilityWordPress Performance & Scalability
WordPress Performance & Scalability
 
Apache Performance Tuning: Scaling Up
Apache Performance Tuning: Scaling UpApache Performance Tuning: Scaling Up
Apache Performance Tuning: Scaling Up
 
Nginx Internals
Nginx InternalsNginx Internals
Nginx Internals
 
Web Server Load Balancer
Web Server Load BalancerWeb Server Load Balancer
Web Server Load Balancer
 
Supercharging your PHP pages with mod_lsapi in CloudLinux OS
Supercharging your PHP pages with mod_lsapi in CloudLinux OSSupercharging your PHP pages with mod_lsapi in CloudLinux OS
Supercharging your PHP pages with mod_lsapi in CloudLinux OS
 
ReplacingSquidWithATS
ReplacingSquidWithATSReplacingSquidWithATS
ReplacingSquidWithATS
 
Apache Traffic Server & Lua
Apache Traffic Server & LuaApache Traffic Server & Lua
Apache Traffic Server & Lua
 
NginX - good practices, tips and advanced techniques
NginX - good practices, tips and advanced techniquesNginX - good practices, tips and advanced techniques
NginX - good practices, tips and advanced techniques
 
Memcached B box presentation
Memcached B box presentationMemcached B box presentation
Memcached B box presentation
 
Fastest Servlets in the West
Fastest Servlets in the WestFastest Servlets in the West
Fastest Servlets in the West
 
Os Harkins
Os HarkinsOs Harkins
Os Harkins
 
Apache httpd 2.4: The Cloud Killer App
Apache httpd 2.4: The Cloud Killer AppApache httpd 2.4: The Cloud Killer App
Apache httpd 2.4: The Cloud Killer App
 
Php psr standard 2014 01-22
Php psr standard 2014 01-22Php psr standard 2014 01-22
Php psr standard 2014 01-22
 
J Ruby Whirlwind Tour
J Ruby Whirlwind TourJ Ruby Whirlwind Tour
J Ruby Whirlwind Tour
 
Zendcon scaling magento
Zendcon scaling magentoZendcon scaling magento
Zendcon scaling magento
 
MNPHP Scalable Architecture 101 - Feb 3 2011
MNPHP Scalable Architecture 101 - Feb 3 2011MNPHP Scalable Architecture 101 - Feb 3 2011
MNPHP Scalable Architecture 101 - Feb 3 2011
 

Similar a /* pOrt80BKK */ - PHP Day - PHP Performance with APC + Memcached for Windows

Host and Boast: Best Practices for Magento Hosting | Imagine 2013 Technolog…
Host and Boast: Best Practices for Magento Hosting | Imagine 2013 Technolog…Host and Boast: Best Practices for Magento Hosting | Imagine 2013 Technolog…
Host and Boast: Best Practices for Magento Hosting | Imagine 2013 Technolog…Atwix
 
php & performance
 php & performance php & performance
php & performancesimon8410
 
PHP & Performance
PHP & PerformancePHP & Performance
PHP & Performance毅 吕
 
Site Performance - From Pinto to Ferrari
Site Performance - From Pinto to FerrariSite Performance - From Pinto to Ferrari
Site Performance - From Pinto to FerrariJoseph Scott
 
Introduction to memcached
Introduction to memcachedIntroduction to memcached
Introduction to memcachedJurriaan Persyn
 
Northeast PHP - High Performance PHP
Northeast PHP - High Performance PHPNortheast PHP - High Performance PHP
Northeast PHP - High Performance PHPJonathan Klein
 
Memcached, presented to LCA2010
Memcached, presented to LCA2010Memcached, presented to LCA2010
Memcached, presented to LCA2010Mark Atwood
 
WebCamp 2016: PHP.Алексей Петров.PHP at Scale: System Architect Toolbox
WebCamp 2016: PHP.Алексей Петров.PHP at Scale: System Architect ToolboxWebCamp 2016: PHP.Алексей Петров.PHP at Scale: System Architect Toolbox
WebCamp 2016: PHP.Алексей Петров.PHP at Scale: System Architect ToolboxWebCamp
 
Full Stack Load Testing
Full Stack Load Testing Full Stack Load Testing
Full Stack Load Testing Terral R Jordan
 
Dutch php conference_2010_opm
Dutch php conference_2010_opmDutch php conference_2010_opm
Dutch php conference_2010_opmisnull
 
Caching and tuning fun for high scalability @ FOSDEM 2012
Caching and tuning fun for high scalability @ FOSDEM 2012Caching and tuning fun for high scalability @ FOSDEM 2012
Caching and tuning fun for high scalability @ FOSDEM 2012Wim Godden
 
EECI 2013 - ExpressionEngine Performance & Optimization - Laying a Solid Foun...
EECI 2013 - ExpressionEngine Performance & Optimization - Laying a Solid Foun...EECI 2013 - ExpressionEngine Performance & Optimization - Laying a Solid Foun...
EECI 2013 - ExpressionEngine Performance & Optimization - Laying a Solid Foun...Nexcess.net LLC
 
A Tale of 2 Systems
A Tale of 2 SystemsA Tale of 2 Systems
A Tale of 2 SystemsDavid Newman
 
Application Caching: The Hidden Microservice (SAConf)
Application Caching: The Hidden Microservice (SAConf)Application Caching: The Hidden Microservice (SAConf)
Application Caching: The Hidden Microservice (SAConf)Scott Mansfield
 
High Performance Drupal Sites
High Performance Drupal SitesHigh Performance Drupal Sites
High Performance Drupal SitesAbayomi Ayoola
 

Similar a /* pOrt80BKK */ - PHP Day - PHP Performance with APC + Memcached for Windows (20)

Host and Boast: Best Practices for Magento Hosting | Imagine 2013 Technolog…
Host and Boast: Best Practices for Magento Hosting | Imagine 2013 Technolog…Host and Boast: Best Practices for Magento Hosting | Imagine 2013 Technolog…
Host and Boast: Best Practices for Magento Hosting | Imagine 2013 Technolog…
 
php & performance
 php & performance php & performance
php & performance
 
PHP & Performance
PHP & PerformancePHP & Performance
PHP & Performance
 
Site Performance - From Pinto to Ferrari
Site Performance - From Pinto to FerrariSite Performance - From Pinto to Ferrari
Site Performance - From Pinto to Ferrari
 
Introduction to memcached
Introduction to memcachedIntroduction to memcached
Introduction to memcached
 
Northeast PHP - High Performance PHP
Northeast PHP - High Performance PHPNortheast PHP - High Performance PHP
Northeast PHP - High Performance PHP
 
EVCache & Moneta (GoSF)
EVCache & Moneta (GoSF)EVCache & Moneta (GoSF)
EVCache & Moneta (GoSF)
 
Memcached, presented to LCA2010
Memcached, presented to LCA2010Memcached, presented to LCA2010
Memcached, presented to LCA2010
 
Nginx pres
Nginx presNginx pres
Nginx pres
 
WebCamp 2016: PHP.Алексей Петров.PHP at Scale: System Architect Toolbox
WebCamp 2016: PHP.Алексей Петров.PHP at Scale: System Architect ToolboxWebCamp 2016: PHP.Алексей Петров.PHP at Scale: System Architect Toolbox
WebCamp 2016: PHP.Алексей Петров.PHP at Scale: System Architect Toolbox
 
Qcon
QconQcon
Qcon
 
Full Stack Load Testing
Full Stack Load Testing Full Stack Load Testing
Full Stack Load Testing
 
Dutch php conference_2010_opm
Dutch php conference_2010_opmDutch php conference_2010_opm
Dutch php conference_2010_opm
 
EVCache Builderscon
EVCache BuildersconEVCache Builderscon
EVCache Builderscon
 
PostgreSQL Query Cache - "pqc"
PostgreSQL Query Cache - "pqc"PostgreSQL Query Cache - "pqc"
PostgreSQL Query Cache - "pqc"
 
Caching and tuning fun for high scalability @ FOSDEM 2012
Caching and tuning fun for high scalability @ FOSDEM 2012Caching and tuning fun for high scalability @ FOSDEM 2012
Caching and tuning fun for high scalability @ FOSDEM 2012
 
EECI 2013 - ExpressionEngine Performance & Optimization - Laying a Solid Foun...
EECI 2013 - ExpressionEngine Performance & Optimization - Laying a Solid Foun...EECI 2013 - ExpressionEngine Performance & Optimization - Laying a Solid Foun...
EECI 2013 - ExpressionEngine Performance & Optimization - Laying a Solid Foun...
 
A Tale of 2 Systems
A Tale of 2 SystemsA Tale of 2 Systems
A Tale of 2 Systems
 
Application Caching: The Hidden Microservice (SAConf)
Application Caching: The Hidden Microservice (SAConf)Application Caching: The Hidden Microservice (SAConf)
Application Caching: The Hidden Microservice (SAConf)
 
High Performance Drupal Sites
High Performance Drupal SitesHigh Performance Drupal Sites
High Performance Drupal Sites
 

Más de Ford AntiTrust

Drupal in the Cloud with Windows Azure
Drupal in the Cloud with Windows AzureDrupal in the Cloud with Windows Azure
Drupal in the Cloud with Windows AzureFord AntiTrust
 
Web Design, Running A Website And Hosting
Web Design, Running A Website And HostingWeb Design, Running A Website And Hosting
Web Design, Running A Website And HostingFord AntiTrust
 
PHP Hoffman Framework (HMF) at Barcamp Bangkok 2
PHP Hoffman Framework(HMF) at Barcamp Bangkok 2PHP Hoffman Framework(HMF) at Barcamp Bangkok 2
PHP Hoffman Framework (HMF) at Barcamp Bangkok 2Ford AntiTrust
 
GoOO->PHP [5] at Barcamp Bangkok 2
GoOO->PHP [5]  at Barcamp Bangkok 2GoOO->PHP [5]  at Barcamp Bangkok 2
GoOO->PHP [5] at Barcamp Bangkok 2Ford AntiTrust
 

Más de Ford AntiTrust (9)

Google calendar
Google calendarGoogle calendar
Google calendar
 
Qbasic
QbasicQbasic
Qbasic
 
Drupal in the Cloud with Windows Azure
Drupal in the Cloud with Windows AzureDrupal in the Cloud with Windows Azure
Drupal in the Cloud with Windows Azure
 
Web Design, Running A Website And Hosting
Web Design, Running A Website And HostingWeb Design, Running A Website And Hosting
Web Design, Running A Website And Hosting
 
PHP Hoffman Framework (HMF) at Barcamp Bangkok 2
PHP Hoffman Framework(HMF) at Barcamp Bangkok 2PHP Hoffman Framework(HMF) at Barcamp Bangkok 2
PHP Hoffman Framework (HMF) at Barcamp Bangkok 2
 
GoOO->PHP [5] at Barcamp Bangkok 2
GoOO->PHP [5]  at Barcamp Bangkok 2GoOO->PHP [5]  at Barcamp Bangkok 2
GoOO->PHP [5] at Barcamp Bangkok 2
 
MySQL Tuning
MySQL TuningMySQL Tuning
MySQL Tuning
 
PHP on AJAX
PHP on AJAXPHP on AJAX
PHP on AJAX
 
PHP Hoffman Framework
PHP Hoffman FrameworkPHP Hoffman Framework
PHP Hoffman Framework
 

Último

Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
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
 
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
 

Último (20)

Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
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
 
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
 

/* pOrt80BKK */ - PHP Day - PHP Performance with APC + Memcached for Windows

  • 1. <?PHP Performance ?> w/APC + Memcached for Windows @FordAntiTrust thaicyberpoint.com thaithinkpad.com thaihi5.com
  • 3. Cache Theory ? Req 1 Check 2 Miss Compute Store 3 Cache 4 Hit Output Miss - [Store] - Hit
  • 4. Type ? Fast Slow http://ralphlosey.files.wordpress.com/2007/06/ram.jpg http://www.pctechguide.com/images/31HardDrive.jpg
  • 6. Opcode Cache and Variables Cache Automatic update w/code changes Code not changes request and Simply Installation
  • 7. Free & Open Source
  • 8. PHP Flow Req • Scanning and Lexing (Plain Text to Tokens) • Parsing • Scanning • Lexing (Tokens to Expressions) • Parsing • Compilation • Compilation (Translated Expressions to Opcode) • Execution Execution (Opcode stacks are processed) Output
  • 10. Normal PHP vs APC Req • Scanning • Lexing • Parsing • Compilation Execution Output
  • 11. Normal PHP vs APC Req APC hook • Scanning • Lexing • Parsing Miss • Compilation APC hook Store Opcode cache Execution Hit Output
  • 12. Why ?
  • 13. Why ? http://ralphschindler.com/
  • 14. Why ? http://ralphschindler.com/
  • 16. Installation • Windows (http://downloads.php.net/pierre/) – extension=php_apc.dll • Basic PECL (http://pecl.php.net) – pecl install apc
  • 17. Installation • Windows (http://downloads.php.net/pierre/) – extension=php_apc.dll Conf • Basic PECL (http://pecl.php.net) – pecl install apc
  • 18.
  • 19. Benchmark PHP Native PHP w/APC Concurrency Level 10 Time taken for tests 60 seconds Complete requests 298 914 Total transferred 643,149 bytes 1,962,675 bytes HTML transferred 516,971 bytes 1,582,035 bytes Requests per second 4.91 [#/sec] (mean) 15.21 [#/sec] (mean) Time per request 2035.405 [ms] (mean) 657.623 [ms] (mean) Time per request 203.541 [ms] 65.762 [ms] (mean, across all concurrent requests) Transfer rate 10.35 [KB/s] received 31.88 [KB/s] received
  • 21. History “Developed by Danga Interactive for LiveJournal.com”
  • 22. Memcached ? • a distributed memory object caching system with hash table
  • 23. Memcached ? • a distributed memory object caching system with hash table
  • 24. Memcached ? • a distributed memory object caching system with hash table • a generic two stage hashing system (clients and servers). Clients are written for specific application languages. Server is written in C
  • 25. Memcached ? • a distributed memory object caching system with hash table • a generic two stage hashing system (clients and servers). Clients are written for specific application languages. Server is written in C
  • 26. Memcached ? • a distributed memory object caching system with hash table • a generic two stage hashing system (clients and servers). Clients are written for specific application languages. Server is written in C • 85% of top 20 sites use memcached; 50%+ of top 5k sites uses Memcached
  • 27. Memcached ? • a distributed memory object caching system with hash table • a generic two stage hashing system (clients and servers). Clients are written for specific application languages. Server is written in C • 85% of top 20 sites use memcached; 50%+ of top 5k sites uses Memcached
  • 28. Limits (c/Hash Table) • Key : max 250 chars. • Values: max 1MB
  • 29. Why Memcached ? • Scale-out – Machine – Process (Use different ports) • Memory faster than Disk • Allows for efficient use of your database • Can utilize existing network – Uses non-blocking network I/O (TCP/IP) • Very flexible • Client libraries in all major languages
  • 30.
  • 31. “We use more than 800 servers supplying over 28 terabytes of memory to our users.” “total throughput achieved is 300,000 UDP req/s” by Paul Saab Saturday, December 13, 2008 at 2:43am • 8-core machines • 20-30% CPU usage. • scale memcached to 8 threads on an 8-core system • moved to UDP for get operations to reduce network traffic http://www.facebook.com/note.php?note_id=39391378919
  • 33. Cache Memcached APC Memcached Instance Reverse Memcached Instance Memcached Instance Proxy Instance I n t e PHP Web App Web Server r n e Session Files t Memcached Memcached Memcached Instance Memcached Instance Master Slave Memcached Instance Memcached Instance Memcached Instance Instance CDN/DFS Instance DB
  • 34. Installation & Used memcached binary packages • http://labs.northscale.com/memcached-packages/ 1. Unzip into a directory of choice 2. Open the shell of your choice (i.e. cmd.exe); cd into the directory 3. Run memcached.exe passing standard arguments. Sample C:memcachedmemcached.exe -m 128 -p 11211 -l 127.0.0.1 -d
  • 35. PHP Session w/Memcached session.save_handler = files session.save_path = “C:/Windows/temp” TO session.save_handler = memcache session.save_path = “tcp://server:port “ OR ini_set('session.save_handler', 'memcache'); ini_set('session.save_path', 'tcp://server:port,tcp://server:port');
  • 36. Coding ? (in PHP) /* OO API */ $memcacheObj = new Memcache; $memcacheObj->connect('memcache_host', 11211); /* set */ $memcacheObj->set('key', 'data', MEMCACHE_COMPRESSED, 50); / * get w/single key */ $var = $memcacheObj->get('key'); / * get w/multiple key */ $var = $memcacheObj->get(array('key1', 'key2')); $memcacheObj->close();
  • 37. CMS ? • Drupal has Memcache API and Integration http://drupal.org/project/memcache • Wordpress has object cache http://mohanjith.net/blog/2008/10/using-memcached-with- wordpress-object-cache.html
  • 38. Tips
  • 39. Two Level Caching with Zend_Cache • Tagging System in Files Cache • Memcached Key used Tagging System
  • 40. Two Level Caching - Workflow Req Compute Files Cache Memcached Output 1. Check 3. Store 2. Miss 4. Hit
  • 42. Used Two Level with Zend_Cache
  • 43. Ref. • Improving PHP Application Performance with APC http://www.slideshare.net/vortexau/improving-php-application- performance-with-apc-presentation • PHP Accelerators : APC vs Zend vs XCache with Zend Framework http://blog.digitalstruct.com/2007/12/23/php-accelerators-apc-vs-zend-vs- xcache-with-zend-framework/ • Scaling with memcached http://www.slideshare.net/acme/scaling-with-memcached • Gear6 and Scaling Website Performance: Caching Session and Profile Data with Memcached http://www.slideshare.net/gear6memcached/gear6-and-scaling-website- performance-caching-session-and-profile-data-with-memcached
  • 44. Ref. (2) • PHP: Memcache - Manual http://th.php.net/manual/en/book.memcache.php • http://danga.com/memcached/ • http://pecl.php.net/package/memcache • http://www.socialtext.net/memcached/
  • 45. Discussion Q&A
  • 46. Thank you @FordAntiTrust http://www.slideshare.net/FordAntiTrust