SlideShare uma empresa Scribd logo
1 de 38
PHP Performance
                     w/APC + Memcached



@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
Free & Open Source
Simply Installation
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
Installation
• Basic PECL
  (http://pecl.php.net)
                               Conf
  – pecl install apc           extension=apc.so
                               apc.shm_segments=1
• Ubuntu                       apc.shm_size=256
  – apt-get install php5-apc   apc.optimization=0
                               apc.num_files_hint=2048
• Windows                      apc.ttl=3600
                               apc.user_ttl=3600
  (http://pecl4win.php.net)    apc.enable_cli=1
                               apc.max_file_size=1M
  – extension=php_apc.dll
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
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
Limits (c/Hash Table)
• Key : max 250 chars.
• Values: max 1MB
“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
Architecture practical ?


    “designing & implementing scalable
  applications with memcached and mysql”
            http://blog.thinkdiff.net/?p=419
Architecture practical ?




http://blog.thinkdiff.net/wp-content/uploads/2009/02/memcache_22-02-2009.png
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
code optimization is best
Discussion
   Q&A
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/
Thank you
           @FordAntiTrust
http://www.slideshare.net/FordAntiTrust

Mais conteúdo relacionado

Mais procurados

High Concurrency Architecture and Laravel Performance Tuning
High Concurrency Architecture and Laravel Performance TuningHigh Concurrency Architecture and Laravel Performance Tuning
High Concurrency Architecture and Laravel Performance TuningAlbert Chen
 
Apache Performance Tuning: Scaling Up
Apache Performance Tuning: Scaling UpApache Performance Tuning: Scaling Up
Apache Performance Tuning: Scaling UpSander Temme
 
Northeast PHP - High Performance PHP
Northeast PHP - High Performance PHPNortheast PHP - High Performance PHP
Northeast PHP - High Performance PHPJonathan Klein
 
Memcached Presentation
Memcached PresentationMemcached Presentation
Memcached PresentationAsif Ali
 
Apache Traffic Server & Lua
Apache Traffic Server & LuaApache Traffic Server & Lua
Apache Traffic Server & LuaKit Chan
 
Breaking the Sound Barrier with Persistent Memory
Breaking the Sound Barrier with Persistent Memory Breaking the Sound Barrier with Persistent Memory
Breaking the Sound Barrier with Persistent Memory HBaseCon
 
Using memcache to improve php performance
Using memcache to improve php performanceUsing memcache to improve php performance
Using memcache to improve php performanceSudar Muthu
 
Roy foubister (hosting high traffic sites on a tight budget)
Roy foubister (hosting high traffic sites on a tight budget)Roy foubister (hosting high traffic sites on a tight budget)
Roy foubister (hosting high traffic sites on a tight budget)WordCamp Cape Town
 
Web Server Load Balancer
Web Server Load BalancerWeb Server Load Balancer
Web Server Load BalancerMobME Technical
 
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
 
Performance scalability brandonlyon
Performance scalability brandonlyonPerformance scalability brandonlyon
Performance scalability brandonlyonDigitaria
 
Accelerate your ColdFusion Applications using Caching
Accelerate your ColdFusion Applications using CachingAccelerate your ColdFusion Applications using Caching
Accelerate your ColdFusion Applications using CachingColdFusionConference
 
Performance Tuning - MuraCon 2012
Performance Tuning - MuraCon 2012Performance Tuning - MuraCon 2012
Performance Tuning - MuraCon 2012eballisty
 

Mais procurados (19)

High Concurrency Architecture and Laravel Performance Tuning
High Concurrency Architecture and Laravel Performance TuningHigh Concurrency Architecture and Laravel Performance Tuning
High Concurrency Architecture and Laravel Performance Tuning
 
Usenix lisa 2011
Usenix lisa 2011Usenix lisa 2011
Usenix lisa 2011
 
Apache Performance Tuning: Scaling Up
Apache Performance Tuning: Scaling UpApache Performance Tuning: Scaling Up
Apache Performance Tuning: Scaling Up
 
Northeast PHP - High Performance PHP
Northeast PHP - High Performance PHPNortheast PHP - High Performance PHP
Northeast PHP - High Performance PHP
 
Memcached Presentation
Memcached PresentationMemcached Presentation
Memcached Presentation
 
ReplacingSquidWithATS
ReplacingSquidWithATSReplacingSquidWithATS
ReplacingSquidWithATS
 
Apache Traffic Server & Lua
Apache Traffic Server & LuaApache Traffic Server & Lua
Apache Traffic Server & Lua
 
Breaking the Sound Barrier with Persistent Memory
Breaking the Sound Barrier with Persistent Memory Breaking the Sound Barrier with Persistent Memory
Breaking the Sound Barrier with Persistent Memory
 
Using memcache to improve php performance
Using memcache to improve php performanceUsing memcache to improve php performance
Using memcache to improve php performance
 
Roy foubister (hosting high traffic sites on a tight budget)
Roy foubister (hosting high traffic sites on a tight budget)Roy foubister (hosting high traffic sites on a tight budget)
Roy foubister (hosting high traffic sites on a tight budget)
 
Web Server Load Balancer
Web Server Load BalancerWeb Server Load Balancer
Web Server Load Balancer
 
Memcache
MemcacheMemcache
Memcache
 
are available here
are available hereare available here
are available here
 
WE18_Performance_Up.ppt
WE18_Performance_Up.pptWE18_Performance_Up.ppt
WE18_Performance_Up.ppt
 
[MathWorks] Versioning Infrastructure
[MathWorks] Versioning Infrastructure[MathWorks] Versioning Infrastructure
[MathWorks] Versioning Infrastructure
 
Os Harkins
Os HarkinsOs Harkins
Os Harkins
 
Performance scalability brandonlyon
Performance scalability brandonlyonPerformance scalability brandonlyon
Performance scalability brandonlyon
 
Accelerate your ColdFusion Applications using Caching
Accelerate your ColdFusion Applications using CachingAccelerate your ColdFusion Applications using Caching
Accelerate your ColdFusion Applications using Caching
 
Performance Tuning - MuraCon 2012
Performance Tuning - MuraCon 2012Performance Tuning - MuraCon 2012
Performance Tuning - MuraCon 2012
 

Destaque

WordPress performance tuning
WordPress performance tuningWordPress performance tuning
WordPress performance tuningVladimír Smitka
 
Quick tour of PHP from inside
Quick tour of PHP from insideQuick tour of PHP from inside
Quick tour of PHP from insidejulien pauli
 
Tối ưu hóa việc ghi dữ liệu với Gearman
Tối ưu hóa việc ghi dữ liệu với GearmanTối ưu hóa việc ghi dữ liệu với Gearman
Tối ưu hóa việc ghi dữ liệu với GearmanMinh Nguyen Vo Cao
 
Low Latency Logging with RabbitMQ (PHP London - 4th Sep 2014)
Low Latency Logging with RabbitMQ (PHP London - 4th Sep 2014)Low Latency Logging with RabbitMQ (PHP London - 4th Sep 2014)
Low Latency Logging with RabbitMQ (PHP London - 4th Sep 2014)James Titcumb
 
PHP 7 performances from PHP 5
PHP 7 performances from PHP 5PHP 7 performances from PHP 5
PHP 7 performances from PHP 5julien pauli
 
Gearman and asynchronous processing in PHP applications
Gearman and asynchronous processing in PHP applicationsGearman and asynchronous processing in PHP applications
Gearman and asynchronous processing in PHP applicationsTeamskunkworks
 
Distributed RDBMS: Data Distribution Policy: Part 1 - What is a Data Distribu...
Distributed RDBMS: Data Distribution Policy: Part 1 - What is a Data Distribu...Distributed RDBMS: Data Distribution Policy: Part 1 - What is a Data Distribu...
Distributed RDBMS: Data Distribution Policy: Part 1 - What is a Data Distribu...ScaleBase
 
Gearman, Supervisor and PHP - Job Management with Sanity!
Gearman, Supervisor and PHP - Job Management with Sanity!Gearman, Supervisor and PHP - Job Management with Sanity!
Gearman, Supervisor and PHP - Job Management with Sanity!Abu Ashraf Masnun
 
Scale like a pro with Gearman
Scale like a pro with GearmanScale like a pro with Gearman
Scale like a pro with GearmanAmal Raghav
 
Distributed RDBMS: Challenges, Solutions & Trade-offs
Distributed RDBMS: Challenges, Solutions & Trade-offsDistributed RDBMS: Challenges, Solutions & Trade-offs
Distributed RDBMS: Challenges, Solutions & Trade-offsAhmed Magdy Ezzeldin, MSc.
 
Creating a WebSocket-Chat-Application with Jetty Embedded - Techcamp 2014
Creating a WebSocket-Chat-Application with Jetty Embedded - Techcamp 2014Creating a WebSocket-Chat-Application with Jetty Embedded - Techcamp 2014
Creating a WebSocket-Chat-Application with Jetty Embedded - Techcamp 2014Minh Nguyen Vo Cao
 
Distributed Queue System using Gearman
Distributed Queue System using GearmanDistributed Queue System using Gearman
Distributed Queue System using GearmanEric Cho
 
Gearman: A Job Server made for Scale
Gearman: A Job Server made for ScaleGearman: A Job Server made for Scale
Gearman: A Job Server made for ScaleMike Willbanks
 

Destaque (16)

Scaling php
Scaling phpScaling php
Scaling php
 
WordPress performance tuning
WordPress performance tuningWordPress performance tuning
WordPress performance tuning
 
Quick tour of PHP from inside
Quick tour of PHP from insideQuick tour of PHP from inside
Quick tour of PHP from inside
 
Tối ưu hóa việc ghi dữ liệu với Gearman
Tối ưu hóa việc ghi dữ liệu với GearmanTối ưu hóa việc ghi dữ liệu với Gearman
Tối ưu hóa việc ghi dữ liệu với Gearman
 
Low Latency Logging with RabbitMQ (PHP London - 4th Sep 2014)
Low Latency Logging with RabbitMQ (PHP London - 4th Sep 2014)Low Latency Logging with RabbitMQ (PHP London - 4th Sep 2014)
Low Latency Logging with RabbitMQ (PHP London - 4th Sep 2014)
 
PHP 7 performances from PHP 5
PHP 7 performances from PHP 5PHP 7 performances from PHP 5
PHP 7 performances from PHP 5
 
Gearman and asynchronous processing in PHP applications
Gearman and asynchronous processing in PHP applicationsGearman and asynchronous processing in PHP applications
Gearman and asynchronous processing in PHP applications
 
Distributed RDBMS: Data Distribution Policy: Part 1 - What is a Data Distribu...
Distributed RDBMS: Data Distribution Policy: Part 1 - What is a Data Distribu...Distributed RDBMS: Data Distribution Policy: Part 1 - What is a Data Distribu...
Distributed RDBMS: Data Distribution Policy: Part 1 - What is a Data Distribu...
 
Gearman, Supervisor and PHP - Job Management with Sanity!
Gearman, Supervisor and PHP - Job Management with Sanity!Gearman, Supervisor and PHP - Job Management with Sanity!
Gearman, Supervisor and PHP - Job Management with Sanity!
 
Scale like a pro with Gearman
Scale like a pro with GearmanScale like a pro with Gearman
Scale like a pro with Gearman
 
PHP 7 new engine
PHP 7 new enginePHP 7 new engine
PHP 7 new engine
 
Distributed RDBMS: Challenges, Solutions & Trade-offs
Distributed RDBMS: Challenges, Solutions & Trade-offsDistributed RDBMS: Challenges, Solutions & Trade-offs
Distributed RDBMS: Challenges, Solutions & Trade-offs
 
Gearman for MySQL
Gearman for MySQLGearman for MySQL
Gearman for MySQL
 
Creating a WebSocket-Chat-Application with Jetty Embedded - Techcamp 2014
Creating a WebSocket-Chat-Application with Jetty Embedded - Techcamp 2014Creating a WebSocket-Chat-Application with Jetty Embedded - Techcamp 2014
Creating a WebSocket-Chat-Application with Jetty Embedded - Techcamp 2014
 
Distributed Queue System using Gearman
Distributed Queue System using GearmanDistributed Queue System using Gearman
Distributed Queue System using Gearman
 
Gearman: A Job Server made for Scale
Gearman: A Job Server made for ScaleGearman: A Job Server made for Scale
Gearman: A Job Server made for Scale
 

Semelhante a PHP Performance with APC + Memcached

php & performance
 php & performance php & performance
php & performancesimon8410
 
PHP & Performance
PHP & PerformancePHP & Performance
PHP & Performance毅 吕
 
Dutch php conference_2010_opm
Dutch php conference_2010_opmDutch php conference_2010_opm
Dutch php conference_2010_opmisnull
 
Full Stack Load Testing
Full Stack Load Testing Full Stack Load Testing
Full Stack Load Testing Terral R Jordan
 
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
 
Site Performance - From Pinto to Ferrari
Site Performance - From Pinto to FerrariSite Performance - From Pinto to Ferrari
Site Performance - From Pinto to FerrariJoseph Scott
 
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
 
Varnish http accelerator
Varnish http acceleratorVarnish http accelerator
Varnish http acceleratorno no
 
Алексей Петров "PHP at Scale: Knowing enough to be dangerous!"
Алексей Петров "PHP at Scale: Knowing enough to be dangerous!"Алексей Петров "PHP at Scale: Knowing enough to be dangerous!"
Алексей Петров "PHP at Scale: Knowing enough to be dangerous!"Fwdays
 
Persistent Memory Programming with Pmemkv
Persistent Memory Programming with PmemkvPersistent Memory Programming with Pmemkv
Persistent Memory Programming with PmemkvIntel® Software
 
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
 
Accelerating Ceph with iWARP RDMA over Ethernet - Brien Porter, Haodong Tang
Accelerating Ceph with iWARP RDMA over Ethernet - Brien Porter, Haodong TangAccelerating Ceph with iWARP RDMA over Ethernet - Brien Porter, Haodong Tang
Accelerating Ceph with iWARP RDMA over Ethernet - Brien Porter, Haodong TangCeph Community
 
TestUpload
TestUploadTestUpload
TestUploadZarksaDS
 
Ceph: Open Source Storage Software Optimizations on Intel® Architecture for C...
Ceph: Open Source Storage Software Optimizations on Intel® Architecture for C...Ceph: Open Source Storage Software Optimizations on Intel® Architecture for C...
Ceph: Open Source Storage Software Optimizations on Intel® Architecture for C...Odinot Stanislas
 
DevoxxUK: Optimizating Application Performance on Kubernetes
DevoxxUK: Optimizating Application Performance on KubernetesDevoxxUK: Optimizating Application Performance on Kubernetes
DevoxxUK: Optimizating Application Performance on KubernetesDinakar Guniguntala
 
Zendcon scaling magento
Zendcon scaling magentoZendcon scaling magento
Zendcon scaling magentoMathew Beane
 
Evergreen Sysadmin Survival Skills
Evergreen Sysadmin Survival SkillsEvergreen Sysadmin Survival Skills
Evergreen Sysadmin Survival SkillsEvergreen ILS
 

Semelhante a PHP Performance with APC + Memcached (20)

php & performance
 php & performance php & performance
php & performance
 
PHP & Performance
PHP & PerformancePHP & Performance
PHP & Performance
 
Dutch php conference_2010_opm
Dutch php conference_2010_opmDutch php conference_2010_opm
Dutch php conference_2010_opm
 
Full Stack Load Testing
Full Stack Load Testing Full Stack Load Testing
Full Stack Load Testing
 
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
 
Site Performance - From Pinto to Ferrari
Site Performance - From Pinto to FerrariSite Performance - From Pinto to Ferrari
Site Performance - From Pinto to Ferrari
 
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…
 
Varnish http accelerator
Varnish http acceleratorVarnish http accelerator
Varnish http accelerator
 
Алексей Петров "PHP at Scale: Knowing enough to be dangerous!"
Алексей Петров "PHP at Scale: Knowing enough to be dangerous!"Алексей Петров "PHP at Scale: Knowing enough to be dangerous!"
Алексей Петров "PHP at Scale: Knowing enough to be dangerous!"
 
Persistent Memory Programming with Pmemkv
Persistent Memory Programming with PmemkvPersistent Memory Programming with Pmemkv
Persistent Memory Programming with Pmemkv
 
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
 
Introduction to APC
Introduction to APCIntroduction to APC
Introduction to APC
 
Accelerating Ceph with iWARP RDMA over Ethernet - Brien Porter, Haodong Tang
Accelerating Ceph with iWARP RDMA over Ethernet - Brien Porter, Haodong TangAccelerating Ceph with iWARP RDMA over Ethernet - Brien Porter, Haodong Tang
Accelerating Ceph with iWARP RDMA over Ethernet - Brien Porter, Haodong Tang
 
TestUpload
TestUploadTestUpload
TestUpload
 
Qcon
QconQcon
Qcon
 
Ceph
CephCeph
Ceph
 
Ceph: Open Source Storage Software Optimizations on Intel® Architecture for C...
Ceph: Open Source Storage Software Optimizations on Intel® Architecture for C...Ceph: Open Source Storage Software Optimizations on Intel® Architecture for C...
Ceph: Open Source Storage Software Optimizations on Intel® Architecture for C...
 
DevoxxUK: Optimizating Application Performance on Kubernetes
DevoxxUK: Optimizating Application Performance on KubernetesDevoxxUK: Optimizating Application Performance on Kubernetes
DevoxxUK: Optimizating Application Performance on Kubernetes
 
Zendcon scaling magento
Zendcon scaling magentoZendcon scaling magento
Zendcon scaling magento
 
Evergreen Sysadmin Survival Skills
Evergreen Sysadmin Survival SkillsEvergreen Sysadmin Survival Skills
Evergreen Sysadmin Survival Skills
 

Mais 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
 

Mais 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

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
 
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
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
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
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
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
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
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
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
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
 
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
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 

Último (20)

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
 
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?
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
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
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
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
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
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
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
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...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 

PHP Performance with APC + Memcached

  • 1. PHP Performance w/APC + Memcached @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
  • 7. Free & Open Source
  • 9. 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
  • 11. Normal PHP vs APC Req • Scanning • Lexing • Parsing • Compilation Execution Output
  • 12. Normal PHP vs APC Req APC hook • Scanning • Lexing • Parsing Miss • Compilation APC hook Store Opcode cache Execution Hit Output
  • 13. Installation • Basic PECL (http://pecl.php.net) Conf – pecl install apc extension=apc.so apc.shm_segments=1 • Ubuntu apc.shm_size=256 – apt-get install php5-apc apc.optimization=0 apc.num_files_hint=2048 • Windows apc.ttl=3600 apc.user_ttl=3600 (http://pecl4win.php.net) apc.enable_cli=1 apc.max_file_size=1M – extension=php_apc.dll
  • 14.
  • 15. 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
  • 17. History “Developed by Danga Interactive for LiveJournal.com”
  • 18. Memcached ? • a distributed memory object caching system with hash table
  • 19. Memcached ? • a distributed memory object caching system with hash table
  • 20. 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
  • 21. 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
  • 22. 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
  • 23. 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
  • 24. 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
  • 25. Limits (c/Hash Table) • Key : max 250 chars. • Values: max 1MB
  • 26.
  • 27. “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
  • 29. Architecture practical ? “designing & implementing scalable applications with memcached and mysql” http://blog.thinkdiff.net/?p=419
  • 30.
  • 32. 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();
  • 33. 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
  • 35. Discussion Q&A
  • 36. 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
  • 37. 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/
  • 38. Thank you @FordAntiTrust http://www.slideshare.net/FordAntiTrust