SlideShare a Scribd company logo
ZingMe Practice
For Building Scalable PHP Website




                  By Chau Nguyen Nhat Thanh
                    ZingMe Technical Manager
                         Web Technical - VNG
Agenda

●
    About ZingMe
●
    Scaling PHP application
    ●
        Scalability definition
    ●
        Scaling up vs scaling out
    ●
        Load balancing
    ●
        Problem with PHP when using load balancer
    ●
        User session management
    ●
        Problem with code deployment
                                                    2
Agenda(cont.)
●   ZingMe practice in building scalable PHP
    applications
    ●   Choosing scale out
    ●   Load balancing model
    ●   User session management system
    ●   Code deployment system
●   ZingMe more
    ●   Open social API
About ZingMe
●   A social network
About ZingMe
●   25M registered accounts
●   1.7M daily active users
●   5M monthly active users
●   > 300 servers (1.2 K cores)
    ●   50 DB servers, >40 Memcached servers
    ●   ~ 100 Web servers
    ●   40 servers for Hadoop farm
    ●   Others (storage, ...)
About ZingMe
●   Load balancing: HA proxy, LVS, hardware (?)
●   Web server: Nginx, lighttpd, apache, hardware (?)
●   Web caching: squid, varnish, hardware (?)
●   Caching: Redis, memcached
●   Programming language: PHP, C++,Java, python,
    bash script
●   Searching: Solr, lucene
●   DB: MySQL , NOSQL
●   Log system: Scriber + Hadoop
Scaling PHP application
●   Scalability definition
●   Scaling up vs scaling out
●   Load balancing
●   User session management
●   Code deployment
Scalability definition
“Scalability is a desirable property of a system,
a network, or a process, which indicates its
ability to either handle growing amounts of work
in a graceful manner or to be enlarged” from
Wikipedia
”A web application is scalable when is able to
manage a growing traffic with additional
resources (CPU, RAM) without software
changes” by Jan Burkl, Enrico Zimuel (Zend
Technologies)
Scaling up vs scaling out
●   Scaling up (vertically)
    ●   Add more resources to single node in a
        system
    ●   Resources can be software or hardware
    ●   Make system more powerful by increase node
        powerful
    ●   Has an upper limit
    ●   Hard to implement HA solution
    ●   Cost: expensive
Scaling up vs scaling out
●   Scaling out (horizontally)
    ●   Add more nodes to a system
    ●   Make system more powerful by increase
        number of nodes in the system
    ●   Maybe has no upper limit
    ●   Easy to implement HA solution
    ●   Cost: cheap
Scaling up vs scaling out




          •
            From slide ”How to scale PHP application”
     •
       by Jan Burkl, Enrico Zimuel (Zend Technologies)
Load balancing
●   The need of a load balancer
    ●   Most of big web site choose scale out
    ●   Need a component for distribute load among
        the nodes
    ●   Such component called load balancer
Load balancing




   •
      from ”Server load balancing architectures”
   •
     by Gregor Roth, JavaWorld.com, 10/21/08
Load balancing
●   How load balancer work?
    ●   Has 2 interfaces: Back-end, Front-end
    ●   Front-end receive the request from client
    ●   Back-end forward request to internal node
    ●   Back-end receive the response from node
    ●   Front-end response to client
    ●   Status monitor for monitoring the back-end
        interface
Load balancing
●   Web application load balancer
    ●   Work in layer 7
    ●   Can filter HTTP header and body in both
        request and response
    ●   Can be hardware or software
    ●   F5 BIG-IP, Citrix Netscale, Cisco
    ●   HA Proxy, Nginx, lighttpd
Problem with PHP when using
           load balancer
●   PHP stores session info into local disk by
    default
●   How to scale session to 2 nodes ?
●   Can be scaled if:
    ●   Load balancer has a method for routing the
        same user requests into the same nodes (1)
    ●   Override the default PHP mechanism for
        storing session of all nodes in the same
        storage (2)
Problem with PHP when using
           load balancer
●   Method (1)
    ●   Load balancer must keep state for connection
    ●   Overhead for routing request
    ●   Not balancing
●   Method (2)
    ●   Must change software
    ●   No overhead for routing request
    ●   More balancer than (1)
PHP session management
●   Choose method (2)
●   Centralize storage among web server
    ●   Storage can be NFS, DB, memcached...
    ●   All web servers access the same storage
●   Override the default behavior of PHP
    session functions
●   Bottleneck can be in storage
PHP session management
●   Call session_set_save_handler( callback
    $open , callback $close , callback $read ,
    callback $write , callback $destroy ,
    callback $gc ) to override default behavior
●   More infos:
    ●   http://php.net/manual/en/function.sessio
        n-set-save-handler.php
Problem with code deployment
●   Adding new server to system:
    ●   What kind of configuration must be changed?
    ●   Which code will be deployed ? In which
        server?
    ●   How can we monitor them?
Problem with PHP code
               deployment
●   What will we change in PHP code ?
    ●   Separate all configuration to configuration file
    ●   Do not hard code any configuration
    ●   Put the code in a central server like SVN
    ●   Use scripts to pull all code to production
        server
    ●   Build profiler system for monitor the code
ZingMe practice for building
         scalable web site
●   Choose Scale out
●   Use HA proxy for load balancing
●   Use Memcached for session storage
●   Simple code deployment system base on
    SVN and bash script
ZingMe practice for building
         scalable web site
●   Divide into small services
●   Use commodity hardwares
●   Use open source software
●   Server has the same environment
●   Add new server < 5mins
ZingMe load balancing model
ZingMe load balancing model
●   Use HA proxy
    ●   HTTP based proxy
    ●   High availability
    ●   Use epoll
●   Use content switching to divide the service
    into group
●   Define load balancing factors based on the
    power of the back-end server
ZingMe load balancing model
Normal traffic
ZingMe load balancing model
ZingMe traffic
ZingMe user session
              management
●   Use memcached for high performance
●   Override Zend_Session
●   3K hits/s
Why we choose memcache?
●   L1 cache reference                          0.5 ns
●   Branch mispredict                             5 ns
●   L2 cache reference                            7 ns
●   Mutex lock/unlock                            25 ns
●   Main memory reference                       100 ns
●   Compress 1K bytes with Zippy              3,000 ns
●   Send 2K bytes over 1 Gbps network        20,000 ns
●   Read 1 MB sequentially from memory      250,000 ns
●   Round trip within same datacenter       500,000 ns
●   Disk seek                              10,000,000 ns
●   Read 1 MB sequentially from disk     20,000,000 ns
●   Send packet CA->Netherlands->CA      150,000,000 ns

                                           From Jeff Dean - google.com
ZingMe code deployment
●   Developer upload code to SVN
●   SO runs scripts to deploy code to production server
●   Has staging server for real environment test
●   Dev cannot touch to production environment
●   Using environment parameter
    ●   Nginx: fastcgi_param
    ●   Apache: setenv
ZingMe more
●   Standard latency for server side code
    processing < 200ms
●   Live demos Profiler system
●   Open social API updated infos
    ●   Sandbox for developer
    ●   Will be open soon
ZingMe more
●   Optimize node before scale it up
    ●   Performance C++ > Java > PHP
    ●   Why PHP ?
        –   Easy to implement business
        –   Easy to deploy
    ●   Why C++?
        –   Performance
    ●   Can we mix PHP and C++?
        –   Next session will answer
Q&A




Contact info:
Chau Nguyen Nhat Thanh
thanhcnn@vinagame.com.vn
me.zing.vn/thanhcnn2000

More Related Content

What's hot

Screaming Fast Wpmu
Screaming Fast WpmuScreaming Fast Wpmu
Screaming Fast Wpmudjcp
 
ZaloPay Merchant Platform on K8S on-premise
ZaloPay Merchant Platform on K8S on-premiseZaloPay Merchant Platform on K8S on-premise
ZaloPay Merchant Platform on K8S on-premise
Chau Thanh
 
Mailerqnewpresentation
MailerqnewpresentationMailerqnewpresentation
MailerqnewpresentationCopernica BV
 
ZaloPay Merchant Platform on K8S on-premise
ZaloPay Merchant Platform on K8S on-premiseZaloPay Merchant Platform on K8S on-premise
ZaloPay Merchant Platform on K8S on-premise
Chau Thanh
 
SPDY @Zynga
SPDY @ZyngaSPDY @Zynga
SPDY @Zynga
Mike Belshe
 
Moodle performance and stress testing
Moodle performance and stress testingMoodle performance and stress testing
Moodle performance and stress testing
moorejon
 
Cache hcm-topdev
Cache hcm-topdevCache hcm-topdev
Cache hcm-topdev
Thanh Chau
 
MongoDB backup service overview Boston MUG
MongoDB backup service overview Boston MUGMongoDB backup service overview Boston MUG
MongoDB backup service overview Boston MUGMongoDB
 
Webinar slides: Become a MongoDB DBA - What to Monitor (if you’re really a My...
Webinar slides: Become a MongoDB DBA - What to Monitor (if you’re really a My...Webinar slides: Become a MongoDB DBA - What to Monitor (if you’re really a My...
Webinar slides: Become a MongoDB DBA - What to Monitor (if you’re really a My...
Severalnines
 
High-performance high-availability Plone
High-performance high-availability PloneHigh-performance high-availability Plone
High-performance high-availability Plone
Guido Stevens
 
Warsaw MuleSoft Meetup #12 Effective Streaming
Warsaw MuleSoft Meetup #12 Effective StreamingWarsaw MuleSoft Meetup #12 Effective Streaming
Warsaw MuleSoft Meetup #12 Effective Streaming
Patryk Bandurski
 
Welcome to NPM search 2.0
Welcome to NPM search 2.0Welcome to NPM search 2.0
Welcome to NPM search 2.0
Dejan Toteff
 
Managing and Scaling Puppet - PuppetConf 2014
Managing and Scaling Puppet - PuppetConf 2014Managing and Scaling Puppet - PuppetConf 2014
Managing and Scaling Puppet - PuppetConf 2014
Puppet
 
FEUC Tec 2016 - Desacoplando WorkFlows com RabbitMQ
FEUC Tec 2016 - Desacoplando WorkFlows com RabbitMQFEUC Tec 2016 - Desacoplando WorkFlows com RabbitMQ
FEUC Tec 2016 - Desacoplando WorkFlows com RabbitMQ
Alexandre Brandão Lustosa
 

What's hot (16)

Screaming Fast Wpmu
Screaming Fast WpmuScreaming Fast Wpmu
Screaming Fast Wpmu
 
ZaloPay Merchant Platform on K8S on-premise
ZaloPay Merchant Platform on K8S on-premiseZaloPay Merchant Platform on K8S on-premise
ZaloPay Merchant Platform on K8S on-premise
 
Mailerqnewpresentation
MailerqnewpresentationMailerqnewpresentation
Mailerqnewpresentation
 
WordCamp RVA
WordCamp RVAWordCamp RVA
WordCamp RVA
 
ZaloPay Merchant Platform on K8S on-premise
ZaloPay Merchant Platform on K8S on-premiseZaloPay Merchant Platform on K8S on-premise
ZaloPay Merchant Platform on K8S on-premise
 
SPDY @Zynga
SPDY @ZyngaSPDY @Zynga
SPDY @Zynga
 
04 web optimization
04 web optimization04 web optimization
04 web optimization
 
Moodle performance and stress testing
Moodle performance and stress testingMoodle performance and stress testing
Moodle performance and stress testing
 
Cache hcm-topdev
Cache hcm-topdevCache hcm-topdev
Cache hcm-topdev
 
MongoDB backup service overview Boston MUG
MongoDB backup service overview Boston MUGMongoDB backup service overview Boston MUG
MongoDB backup service overview Boston MUG
 
Webinar slides: Become a MongoDB DBA - What to Monitor (if you’re really a My...
Webinar slides: Become a MongoDB DBA - What to Monitor (if you’re really a My...Webinar slides: Become a MongoDB DBA - What to Monitor (if you’re really a My...
Webinar slides: Become a MongoDB DBA - What to Monitor (if you’re really a My...
 
High-performance high-availability Plone
High-performance high-availability PloneHigh-performance high-availability Plone
High-performance high-availability Plone
 
Warsaw MuleSoft Meetup #12 Effective Streaming
Warsaw MuleSoft Meetup #12 Effective StreamingWarsaw MuleSoft Meetup #12 Effective Streaming
Warsaw MuleSoft Meetup #12 Effective Streaming
 
Welcome to NPM search 2.0
Welcome to NPM search 2.0Welcome to NPM search 2.0
Welcome to NPM search 2.0
 
Managing and Scaling Puppet - PuppetConf 2014
Managing and Scaling Puppet - PuppetConf 2014Managing and Scaling Puppet - PuppetConf 2014
Managing and Scaling Puppet - PuppetConf 2014
 
FEUC Tec 2016 - Desacoplando WorkFlows com RabbitMQ
FEUC Tec 2016 - Desacoplando WorkFlows com RabbitMQFEUC Tec 2016 - Desacoplando WorkFlows com RabbitMQ
FEUC Tec 2016 - Desacoplando WorkFlows com RabbitMQ
 

Viewers also liked

Design a scalable social network: Problems and solutions
Design a scalable social network: Problems and solutionsDesign a scalable social network: Problems and solutions
Design a scalable social network: Problems and solutions
Chau Thanh
 
Inside Zalo: Developing a mobile messenger for the audience of millions - VN ...
Inside Zalo: Developing a mobile messenger for the audience of millions - VN ...Inside Zalo: Developing a mobile messenger for the audience of millions - VN ...
Inside Zalo: Developing a mobile messenger for the audience of millions - VN ...
Zalo_app
 
Experience lessons from architecture of zalo real time system
Experience lessons from architecture of zalo real time systemExperience lessons from architecture of zalo real time system
Experience lessons from architecture of zalo real time systemZalo_app
 
7 Stages of Scaling Web Applications
7 Stages of Scaling Web Applications7 Stages of Scaling Web Applications
7 Stages of Scaling Web Applications
David Mitzenmacher
 
Design a scalable site: Problem and solutions
Design a scalable site: Problem and solutionsDesign a scalable site: Problem and solutions
Design a scalable site: Problem and solutions
Chau Thanh
 
Architecture Patterns - Open Discussion
Architecture Patterns - Open DiscussionArchitecture Patterns - Open Discussion
Architecture Patterns - Open Discussion
Nguyen Tung
 
facebook architecture for 600M users
facebook architecture for 600M usersfacebook architecture for 600M users
facebook architecture for 600M users
Jongyoon Choi
 
Design a scalable social network: Problems and Solutions
Design a scalable social network: Problems and SolutionsDesign a scalable social network: Problems and Solutions
Design a scalable social network: Problems and Solutions
Chau Thanh
 
Zing Me Launch Meetup July 2011
Zing Me Launch Meetup July 2011Zing Me Launch Meetup July 2011
Zing Me Launch Meetup July 2011Nguyen Trong
 
Zing me build brand engagement with zing me aug 2011
Zing me   build brand engagement with zing me aug 2011Zing me   build brand engagement with zing me aug 2011
Zing me build brand engagement with zing me aug 2011
Binny Ngo
 
Zing me overview
Zing me overviewZing me overview
Zing me overview
Ohay TV
 
Zing me credential
Zing me credentialZing me credential
Zing me credential
zingopen
 
Giving Your Presentations Zing!
Giving Your Presentations Zing!Giving Your Presentations Zing!
Giving Your Presentations Zing!
Daniel J. Lewis
 
Zing Me - Open Platform Introduction
Zing Me - Open Platform IntroductionZing Me - Open Platform Introduction
Zing Me - Open Platform Introductionkhaivq
 
megastar - zing me social network story
megastar - zing me social network storymegastar - zing me social network story
megastar - zing me social network storyzingopen
 
ZING: the Next Generation of Z39.50
ZING: the Next Generation of Z39.50ZING: the Next Generation of Z39.50
ZING: the Next Generation of Z39.50
horvadam
 
Buiding and Deploying SaaS with WSO2 as as-a-Service
Buiding and Deploying SaaS with WSO2 as as-a-ServiceBuiding and Deploying SaaS with WSO2 as as-a-Service
Buiding and Deploying SaaS with WSO2 as as-a-ServiceWSO2
 
Zing Database – Distributed Key-Value Database
Zing Database – Distributed Key-Value DatabaseZing Database – Distributed Key-Value Database
Zing Database – Distributed Key-Value Databasezingopen
 
Eptica Webinar: Unlock Revenue with Proactive Web Chat
Eptica Webinar: Unlock Revenue with Proactive  Web ChatEptica Webinar: Unlock Revenue with Proactive  Web Chat
Eptica Webinar: Unlock Revenue with Proactive Web Chat
Eptica UK Ltd
 
Machine translation
Machine translationMachine translation
Machine translation
Yamagata Europe
 

Viewers also liked (20)

Design a scalable social network: Problems and solutions
Design a scalable social network: Problems and solutionsDesign a scalable social network: Problems and solutions
Design a scalable social network: Problems and solutions
 
Inside Zalo: Developing a mobile messenger for the audience of millions - VN ...
Inside Zalo: Developing a mobile messenger for the audience of millions - VN ...Inside Zalo: Developing a mobile messenger for the audience of millions - VN ...
Inside Zalo: Developing a mobile messenger for the audience of millions - VN ...
 
Experience lessons from architecture of zalo real time system
Experience lessons from architecture of zalo real time systemExperience lessons from architecture of zalo real time system
Experience lessons from architecture of zalo real time system
 
7 Stages of Scaling Web Applications
7 Stages of Scaling Web Applications7 Stages of Scaling Web Applications
7 Stages of Scaling Web Applications
 
Design a scalable site: Problem and solutions
Design a scalable site: Problem and solutionsDesign a scalable site: Problem and solutions
Design a scalable site: Problem and solutions
 
Architecture Patterns - Open Discussion
Architecture Patterns - Open DiscussionArchitecture Patterns - Open Discussion
Architecture Patterns - Open Discussion
 
facebook architecture for 600M users
facebook architecture for 600M usersfacebook architecture for 600M users
facebook architecture for 600M users
 
Design a scalable social network: Problems and Solutions
Design a scalable social network: Problems and SolutionsDesign a scalable social network: Problems and Solutions
Design a scalable social network: Problems and Solutions
 
Zing Me Launch Meetup July 2011
Zing Me Launch Meetup July 2011Zing Me Launch Meetup July 2011
Zing Me Launch Meetup July 2011
 
Zing me build brand engagement with zing me aug 2011
Zing me   build brand engagement with zing me aug 2011Zing me   build brand engagement with zing me aug 2011
Zing me build brand engagement with zing me aug 2011
 
Zing me overview
Zing me overviewZing me overview
Zing me overview
 
Zing me credential
Zing me credentialZing me credential
Zing me credential
 
Giving Your Presentations Zing!
Giving Your Presentations Zing!Giving Your Presentations Zing!
Giving Your Presentations Zing!
 
Zing Me - Open Platform Introduction
Zing Me - Open Platform IntroductionZing Me - Open Platform Introduction
Zing Me - Open Platform Introduction
 
megastar - zing me social network story
megastar - zing me social network storymegastar - zing me social network story
megastar - zing me social network story
 
ZING: the Next Generation of Z39.50
ZING: the Next Generation of Z39.50ZING: the Next Generation of Z39.50
ZING: the Next Generation of Z39.50
 
Buiding and Deploying SaaS with WSO2 as as-a-Service
Buiding and Deploying SaaS with WSO2 as as-a-ServiceBuiding and Deploying SaaS with WSO2 as as-a-Service
Buiding and Deploying SaaS with WSO2 as as-a-Service
 
Zing Database – Distributed Key-Value Database
Zing Database – Distributed Key-Value DatabaseZing Database – Distributed Key-Value Database
Zing Database – Distributed Key-Value Database
 
Eptica Webinar: Unlock Revenue with Proactive Web Chat
Eptica Webinar: Unlock Revenue with Proactive  Web ChatEptica Webinar: Unlock Revenue with Proactive  Web Chat
Eptica Webinar: Unlock Revenue with Proactive Web Chat
 
Machine translation
Machine translationMachine translation
Machine translation
 

Similar to Zingme practice for building scalable website with PHP

Maximizing PHP Performance with NGINX
Maximizing PHP Performance with NGINXMaximizing PHP Performance with NGINX
Maximizing PHP Performance with NGINX
NGINX, Inc.
 
Подталкиваем PHP к пределу возможностей, Michael Armstrong (lite speed techno...
Подталкиваем PHP к пределу возможностей, Michael Armstrong (lite speed techno...Подталкиваем PHP к пределу возможностей, Michael Armstrong (lite speed techno...
Подталкиваем PHP к пределу возможностей, Michael Armstrong (lite speed techno...
Ontico
 
Silverstripe at scale - design & architecture for silverstripe applications
Silverstripe at scale - design & architecture for silverstripe applicationsSilverstripe at scale - design & architecture for silverstripe applications
Silverstripe at scale - design & architecture for silverstripe applications
BrettTasker
 
USENIX LISA15: How TubeMogul Handles over One Trillion HTTP Requests a Month
USENIX LISA15: How TubeMogul Handles over One Trillion HTTP Requests a MonthUSENIX LISA15: How TubeMogul Handles over One Trillion HTTP Requests a Month
USENIX LISA15: How TubeMogul Handles over One Trillion HTTP Requests a Month
Nicolas Brousse
 
Beginners Node.js
Beginners Node.jsBeginners Node.js
Beginners Node.js
Khaled Mosharraf
 
High performance PHP: Scaling and getting the most out of your infrastructure
High performance PHP: Scaling and getting the most out of your infrastructureHigh performance PHP: Scaling and getting the most out of your infrastructure
High performance PHP: Scaling and getting the most out of your infrastructure
mkherlakian
 
Drupal Performance and Scaling
Drupal Performance and ScalingDrupal Performance and Scaling
Drupal Performance and ScalingGerald Villorente
 
Optimizing performance
Optimizing performanceOptimizing performance
Optimizing performance
Zend by Rogue Wave Software
 
Zendcon scaling magento
Zendcon scaling magentoZendcon scaling magento
Zendcon scaling magento
Mathew Beane
 
PHP At 5000 Requests Per Second: Hootsuite’s Scaling Story
PHP At 5000 Requests Per Second: Hootsuite’s Scaling StoryPHP At 5000 Requests Per Second: Hootsuite’s Scaling Story
PHP At 5000 Requests Per Second: Hootsuite’s Scaling Story
vanphp
 
Scaling Magento
Scaling MagentoScaling Magento
Scaling Magento
Copious
 
Node.js Presentation
Node.js PresentationNode.js Presentation
Node.js Presentation
Exist
 
(phpconftw2012) PHP as a Middleware in Embedded Systems
(phpconftw2012) PHP as a Middleware in Embedded Systems(phpconftw2012) PHP as a Middleware in Embedded Systems
(phpconftw2012) PHP as a Middleware in Embedded Systems
sosorry
 
Scalable Architecture 101
Scalable Architecture 101Scalable Architecture 101
Scalable Architecture 101ConFoo
 
Dynomite @ RedisConf 2017
Dynomite @ RedisConf 2017Dynomite @ RedisConf 2017
Dynomite @ RedisConf 2017
Ioannis Papapanagiotou
 
RedisConf17 - Dynomite - Making Non-distributed Databases Distributed
RedisConf17 - Dynomite - Making Non-distributed Databases DistributedRedisConf17 - Dynomite - Making Non-distributed Databases Distributed
RedisConf17 - Dynomite - Making Non-distributed Databases Distributed
Redis Labs
 
Zero Downtime JEE Architectures
Zero Downtime JEE ArchitecturesZero Downtime JEE Architectures
Zero Downtime JEE Architectures
Alexander Penev
 
Instruments to play microservice
Instruments to play microserviceInstruments to play microservice
Instruments to play microservice
Chandresh Pancholi
 

Similar to Zingme practice for building scalable website with PHP (20)

Maximizing PHP Performance with NGINX
Maximizing PHP Performance with NGINXMaximizing PHP Performance with NGINX
Maximizing PHP Performance with NGINX
 
Подталкиваем PHP к пределу возможностей, Michael Armstrong (lite speed techno...
Подталкиваем PHP к пределу возможностей, Michael Armstrong (lite speed techno...Подталкиваем PHP к пределу возможностей, Michael Armstrong (lite speed techno...
Подталкиваем PHP к пределу возможностей, Michael Armstrong (lite speed techno...
 
Silverstripe at scale - design & architecture for silverstripe applications
Silverstripe at scale - design & architecture for silverstripe applicationsSilverstripe at scale - design & architecture for silverstripe applications
Silverstripe at scale - design & architecture for silverstripe applications
 
USENIX LISA15: How TubeMogul Handles over One Trillion HTTP Requests a Month
USENIX LISA15: How TubeMogul Handles over One Trillion HTTP Requests a MonthUSENIX LISA15: How TubeMogul Handles over One Trillion HTTP Requests a Month
USENIX LISA15: How TubeMogul Handles over One Trillion HTTP Requests a Month
 
Beginners Node.js
Beginners Node.jsBeginners Node.js
Beginners Node.js
 
High performance PHP: Scaling and getting the most out of your infrastructure
High performance PHP: Scaling and getting the most out of your infrastructureHigh performance PHP: Scaling and getting the most out of your infrastructure
High performance PHP: Scaling and getting the most out of your infrastructure
 
Drupal Performance and Scaling
Drupal Performance and ScalingDrupal Performance and Scaling
Drupal Performance and Scaling
 
Optimizing performance
Optimizing performanceOptimizing performance
Optimizing performance
 
Zendcon scaling magento
Zendcon scaling magentoZendcon scaling magento
Zendcon scaling magento
 
Nginx pres
Nginx presNginx pres
Nginx pres
 
PHP At 5000 Requests Per Second: Hootsuite’s Scaling Story
PHP At 5000 Requests Per Second: Hootsuite’s Scaling StoryPHP At 5000 Requests Per Second: Hootsuite’s Scaling Story
PHP At 5000 Requests Per Second: Hootsuite’s Scaling Story
 
Scaling Magento
Scaling MagentoScaling Magento
Scaling Magento
 
Node.js Presentation
Node.js PresentationNode.js Presentation
Node.js Presentation
 
(phpconftw2012) PHP as a Middleware in Embedded Systems
(phpconftw2012) PHP as a Middleware in Embedded Systems(phpconftw2012) PHP as a Middleware in Embedded Systems
(phpconftw2012) PHP as a Middleware in Embedded Systems
 
Scalable Architecture 101
Scalable Architecture 101Scalable Architecture 101
Scalable Architecture 101
 
Dynomite @ RedisConf 2017
Dynomite @ RedisConf 2017Dynomite @ RedisConf 2017
Dynomite @ RedisConf 2017
 
RedisConf17 - Dynomite - Making Non-distributed Databases Distributed
RedisConf17 - Dynomite - Making Non-distributed Databases DistributedRedisConf17 - Dynomite - Making Non-distributed Databases Distributed
RedisConf17 - Dynomite - Making Non-distributed Databases Distributed
 
Zero Downtime JEE Architectures
Zero Downtime JEE ArchitecturesZero Downtime JEE Architectures
Zero Downtime JEE Architectures
 
Daniel Sloof: Magento on HHVM
Daniel Sloof: Magento on HHVMDaniel Sloof: Magento on HHVM
Daniel Sloof: Magento on HHVM
 
Instruments to play microservice
Instruments to play microserviceInstruments to play microservice
Instruments to play microservice
 

Recently uploaded

Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 

Recently uploaded (20)

Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 

Zingme practice for building scalable website with PHP

  • 1. ZingMe Practice For Building Scalable PHP Website By Chau Nguyen Nhat Thanh ZingMe Technical Manager Web Technical - VNG
  • 2. Agenda ● About ZingMe ● Scaling PHP application ● Scalability definition ● Scaling up vs scaling out ● Load balancing ● Problem with PHP when using load balancer ● User session management ● Problem with code deployment 2
  • 3. Agenda(cont.) ● ZingMe practice in building scalable PHP applications ● Choosing scale out ● Load balancing model ● User session management system ● Code deployment system ● ZingMe more ● Open social API
  • 4. About ZingMe ● A social network
  • 5. About ZingMe ● 25M registered accounts ● 1.7M daily active users ● 5M monthly active users ● > 300 servers (1.2 K cores) ● 50 DB servers, >40 Memcached servers ● ~ 100 Web servers ● 40 servers for Hadoop farm ● Others (storage, ...)
  • 6. About ZingMe ● Load balancing: HA proxy, LVS, hardware (?) ● Web server: Nginx, lighttpd, apache, hardware (?) ● Web caching: squid, varnish, hardware (?) ● Caching: Redis, memcached ● Programming language: PHP, C++,Java, python, bash script ● Searching: Solr, lucene ● DB: MySQL , NOSQL ● Log system: Scriber + Hadoop
  • 7. Scaling PHP application ● Scalability definition ● Scaling up vs scaling out ● Load balancing ● User session management ● Code deployment
  • 8. Scalability definition “Scalability is a desirable property of a system, a network, or a process, which indicates its ability to either handle growing amounts of work in a graceful manner or to be enlarged” from Wikipedia ”A web application is scalable when is able to manage a growing traffic with additional resources (CPU, RAM) without software changes” by Jan Burkl, Enrico Zimuel (Zend Technologies)
  • 9. Scaling up vs scaling out ● Scaling up (vertically) ● Add more resources to single node in a system ● Resources can be software or hardware ● Make system more powerful by increase node powerful ● Has an upper limit ● Hard to implement HA solution ● Cost: expensive
  • 10. Scaling up vs scaling out ● Scaling out (horizontally) ● Add more nodes to a system ● Make system more powerful by increase number of nodes in the system ● Maybe has no upper limit ● Easy to implement HA solution ● Cost: cheap
  • 11. Scaling up vs scaling out • From slide ”How to scale PHP application” • by Jan Burkl, Enrico Zimuel (Zend Technologies)
  • 12. Load balancing ● The need of a load balancer ● Most of big web site choose scale out ● Need a component for distribute load among the nodes ● Such component called load balancer
  • 13. Load balancing • from ”Server load balancing architectures” • by Gregor Roth, JavaWorld.com, 10/21/08
  • 14. Load balancing ● How load balancer work? ● Has 2 interfaces: Back-end, Front-end ● Front-end receive the request from client ● Back-end forward request to internal node ● Back-end receive the response from node ● Front-end response to client ● Status monitor for monitoring the back-end interface
  • 15. Load balancing ● Web application load balancer ● Work in layer 7 ● Can filter HTTP header and body in both request and response ● Can be hardware or software ● F5 BIG-IP, Citrix Netscale, Cisco ● HA Proxy, Nginx, lighttpd
  • 16. Problem with PHP when using load balancer ● PHP stores session info into local disk by default ● How to scale session to 2 nodes ? ● Can be scaled if: ● Load balancer has a method for routing the same user requests into the same nodes (1) ● Override the default PHP mechanism for storing session of all nodes in the same storage (2)
  • 17. Problem with PHP when using load balancer ● Method (1) ● Load balancer must keep state for connection ● Overhead for routing request ● Not balancing ● Method (2) ● Must change software ● No overhead for routing request ● More balancer than (1)
  • 18. PHP session management ● Choose method (2) ● Centralize storage among web server ● Storage can be NFS, DB, memcached... ● All web servers access the same storage ● Override the default behavior of PHP session functions ● Bottleneck can be in storage
  • 19. PHP session management ● Call session_set_save_handler( callback $open , callback $close , callback $read , callback $write , callback $destroy , callback $gc ) to override default behavior ● More infos: ● http://php.net/manual/en/function.sessio n-set-save-handler.php
  • 20. Problem with code deployment ● Adding new server to system: ● What kind of configuration must be changed? ● Which code will be deployed ? In which server? ● How can we monitor them?
  • 21. Problem with PHP code deployment ● What will we change in PHP code ? ● Separate all configuration to configuration file ● Do not hard code any configuration ● Put the code in a central server like SVN ● Use scripts to pull all code to production server ● Build profiler system for monitor the code
  • 22. ZingMe practice for building scalable web site ● Choose Scale out ● Use HA proxy for load balancing ● Use Memcached for session storage ● Simple code deployment system base on SVN and bash script
  • 23. ZingMe practice for building scalable web site ● Divide into small services ● Use commodity hardwares ● Use open source software ● Server has the same environment ● Add new server < 5mins
  • 25. ZingMe load balancing model ● Use HA proxy ● HTTP based proxy ● High availability ● Use epoll ● Use content switching to divide the service into group ● Define load balancing factors based on the power of the back-end server
  • 26. ZingMe load balancing model Normal traffic
  • 27. ZingMe load balancing model ZingMe traffic
  • 28. ZingMe user session management ● Use memcached for high performance ● Override Zend_Session ● 3K hits/s
  • 29. Why we choose memcache? ● L1 cache reference 0.5 ns ● Branch mispredict 5 ns ● L2 cache reference 7 ns ● Mutex lock/unlock 25 ns ● Main memory reference 100 ns ● Compress 1K bytes with Zippy 3,000 ns ● Send 2K bytes over 1 Gbps network 20,000 ns ● Read 1 MB sequentially from memory 250,000 ns ● Round trip within same datacenter 500,000 ns ● Disk seek 10,000,000 ns ● Read 1 MB sequentially from disk 20,000,000 ns ● Send packet CA->Netherlands->CA 150,000,000 ns From Jeff Dean - google.com
  • 30. ZingMe code deployment ● Developer upload code to SVN ● SO runs scripts to deploy code to production server ● Has staging server for real environment test ● Dev cannot touch to production environment ● Using environment parameter ● Nginx: fastcgi_param ● Apache: setenv
  • 31. ZingMe more ● Standard latency for server side code processing < 200ms ● Live demos Profiler system ● Open social API updated infos ● Sandbox for developer ● Will be open soon
  • 32. ZingMe more ● Optimize node before scale it up ● Performance C++ > Java > PHP ● Why PHP ? – Easy to implement business – Easy to deploy ● Why C++? – Performance ● Can we mix PHP and C++? – Next session will answer
  • 33. Q&A Contact info: Chau Nguyen Nhat Thanh thanhcnn@vinagame.com.vn me.zing.vn/thanhcnn2000