SlideShare ist ein Scribd-Unternehmen logo
1 von 20
Downloaden Sie, um offline zu lesen
18/12/2010


Speed up ZingMe-NTVV2 with
PHP extension module




                     By Nguyen Trung Thanh
                        ZingMe Team leader
                       Web Technical - VNG
Contents

Introduction
Why?
PHP extension basic
SWIG
Sample
INTRODUCTION - ntvv2
Introduction

‱ Ntvv2 (http://me.zing.vn/apps/ntvv2)
  – 1.M daily active user
  – Average 800 rps (per webserver) max 1100
    rps
  – 9300 rps (all database servers)
  – 3 webservers
‱ Use Membase for cache and storage
‱ Use other db for secondary storage
‱ All bussiness function is moved to PHP
  extension
Why to write PHP module?
Make complicated Bussiness functions run
 faster, consume less memory

PHP high-level overhead cpu/mem

Advance facility with PHP-FPM
    Cache something in PHP process


Strictly Confidential – Do Not Distribute
PHP extension basic

What is an extension?

Lifecycle

Setting up a build environment
http://devzone.zend.com/article/4486
http://devzone.zend.com/article/1021-Extension-Writing-Part-I-
   Introduction-to-PHP-and-Zend
What is an extension?

Have you ever used PHP extension?

PHP consist of many extensions

All function we used is from extensions
Lifecycle
Setting up build environment

- Setup PHP-devel
- Sample extension
Is it complicated?


●
 Is there any sexier and easier way?
●
 We can use SWIG
SWIG
SWIG is an interface compiler that connects
  programs written in C and C++ with
  scripting languages such as PHP, Python,
  Ruby...
How SWIG works
Using SWIG
Install module to PHP extensions
Sample


Strictly Confidential – Do Not Distribute
How SWIG works
What does SWIG do for you ?

Namespace
Constants
Type conversion
  For simple types (int, float, char *, enum)
Wraps complex types
  Pointers to structs and classes
Exposes functions
Using SWIG

Defile module in swig file
Generate source code
Create module project, build it
Define module

Data type
Wrapper class/functions
                                            %module ntvv2module
                                            %{
                                            #include <string>
                                            #include <vector>
                                            #include <list>
                                            #include <string>
                                            #include “ntvvgame.h"
                                            %}
                                            struct LandInfo{
                                               int id;
                                               std::string data;
                                            }            ;
Strictly Confidential – Do Not Distribute   LandInfo updateLandInfo(int uid, int landID);
Exposure


‱Swig recognizes C/C++ declarations
'struct' or 'class'
functions
‱Hiding elements
%ignore solver::noupdate;
%include “satsolver/solver.h”
Useful commands
‱Renaming
%rename("to_s") asString();
%rename( "name=" ) set_name( const char *name );
%rename("empty?") empty();
‱Aliasing
%alias get "[]";
‱Constants
%constant int Script = C_CONSTANT;
‱Defines
%define YUILogComponent "bindings"
%enddef
%define %macro(PARAMETER)
SWIG steps

Generate code

Create project, compiling
    – Add genterated code to project
Running
    – Add extension module to PHP
Sample

Cache data in PHP module




Strictly Confidential – Do Not Distribute
Q&A

Weitere Àhnliche Inhalte

Andere mochten auch

Mysql HandleSocketæŠ€æœŻćœšSNS Feed歘悹侭的ćș”甚
Mysql HandleSocketæŠ€æœŻćœšSNS Feed歘悹侭的ćș”甚Mysql HandleSocketæŠ€æœŻćœšSNS Feed歘悹侭的ćș”甚
Mysql HandleSocketæŠ€æœŻćœšSNS Feed歘悹侭的ćș”甚iammutex
 
Mobilemonday.vn momo-monetize thinking_tu do tai chinh_v1.2
Mobilemonday.vn   momo-monetize thinking_tu do tai chinh_v1.2Mobilemonday.vn   momo-monetize thinking_tu do tai chinh_v1.2
Mobilemonday.vn momo-monetize thinking_tu do tai chinh_v1.2Quang Anh Le
 
Mobilemonday.vn adflex
Mobilemonday.vn   adflexMobilemonday.vn   adflex
Mobilemonday.vn adflexQuang Anh Le
 
Mobilemonday.vn mobile interaction - mr ng cuu long goldsun focus media
Mobilemonday.vn   mobile interaction - mr ng cuu long goldsun focus mediaMobilemonday.vn   mobile interaction - mr ng cuu long goldsun focus media
Mobilemonday.vn mobile interaction - mr ng cuu long goldsun focus mediaQuang Anh Le
 

Andere mochten auch (6)

Redoxsignalingmolecules
RedoxsignalingmoleculesRedoxsignalingmolecules
Redoxsignalingmolecules
 
Giao trinh java script
Giao trinh java scriptGiao trinh java script
Giao trinh java script
 
Mysql HandleSocketæŠ€æœŻćœšSNS Feed歘悹侭的ćș”甚
Mysql HandleSocketæŠ€æœŻćœšSNS Feed歘悹侭的ćș”甚Mysql HandleSocketæŠ€æœŻćœšSNS Feed歘悹侭的ćș”甚
Mysql HandleSocketæŠ€æœŻćœšSNS Feed歘悹侭的ćș”甚
 
Mobilemonday.vn momo-monetize thinking_tu do tai chinh_v1.2
Mobilemonday.vn   momo-monetize thinking_tu do tai chinh_v1.2Mobilemonday.vn   momo-monetize thinking_tu do tai chinh_v1.2
Mobilemonday.vn momo-monetize thinking_tu do tai chinh_v1.2
 
Mobilemonday.vn adflex
Mobilemonday.vn   adflexMobilemonday.vn   adflex
Mobilemonday.vn adflex
 
Mobilemonday.vn mobile interaction - mr ng cuu long goldsun focus media
Mobilemonday.vn   mobile interaction - mr ng cuu long goldsun focus mediaMobilemonday.vn   mobile interaction - mr ng cuu long goldsun focus media
Mobilemonday.vn mobile interaction - mr ng cuu long goldsun focus media
 

Ähnlich wie 02. php ext module vng

GWT MVP Case Study
GWT MVP Case StudyGWT MVP Case Study
GWT MVP Case StudyDavid Chandler
 
Node.js for enterprise - JS Conference
Node.js for enterprise - JS ConferenceNode.js for enterprise - JS Conference
Node.js for enterprise - JS ConferenceTimur Shemsedinov
 
Taming Deployment With Smart Frog
Taming Deployment With Smart FrogTaming Deployment With Smart Frog
Taming Deployment With Smart FrogSteve Loughran
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.jsorkaplan
 
Twig, the flexible, fast, and secure template language for PHP
Twig, the flexible, fast, and secure template language for PHPTwig, the flexible, fast, and secure template language for PHP
Twig, the flexible, fast, and secure template language for PHPFabien Potencier
 
How to Write Node.js Module
How to Write Node.js ModuleHow to Write Node.js Module
How to Write Node.js ModuleFred Chien
 
Hack Like It's 2013 (The Workshop)
Hack Like It's 2013 (The Workshop)Hack Like It's 2013 (The Workshop)
Hack Like It's 2013 (The Workshop)Itzik Kotler
 
Swift profiling middleware and tools
Swift profiling middleware and toolsSwift profiling middleware and tools
Swift profiling middleware and toolszhang hua
 
SOA with C, C++, PHP and more
SOA with C, C++, PHP and moreSOA with C, C++, PHP and more
SOA with C, C++, PHP and moreWSO2
 
Node js meetup
Node js meetupNode js meetup
Node js meetupAnsuman Roy
 
Twig for Drupal @ Frontendunited Amsterdam 2012
Twig for Drupal @ Frontendunited Amsterdam 2012Twig for Drupal @ Frontendunited Amsterdam 2012
Twig for Drupal @ Frontendunited Amsterdam 2012Rene Bakx
 
Secure Programming
Secure ProgrammingSecure Programming
Secure Programmingalpha0
 
Portland Puppet User Group June 2014: Writing and publishing puppet modules
Portland Puppet User Group June 2014: Writing and publishing puppet modulesPortland Puppet User Group June 2014: Writing and publishing puppet modules
Portland Puppet User Group June 2014: Writing and publishing puppet modulesPuppet
 
June 2014 PDX PUG: Writing and Publishing Puppet Modules
June 2014 PDX PUG: Writing and Publishing Puppet Modules June 2014 PDX PUG: Writing and Publishing Puppet Modules
June 2014 PDX PUG: Writing and Publishing Puppet Modules Puppet
 
Attacking Pipelines--Security meets Continuous Delivery
Attacking Pipelines--Security meets Continuous DeliveryAttacking Pipelines--Security meets Continuous Delivery
Attacking Pipelines--Security meets Continuous DeliveryJames Wickett
 
Build Your Own HiveMQ Extension
Build Your Own HiveMQ ExtensionBuild Your Own HiveMQ Extension
Build Your Own HiveMQ ExtensionHiveMQ
 
Use Symfony2 components inside WordPress
Use Symfony2 components inside WordPress Use Symfony2 components inside WordPress
Use Symfony2 components inside WordPress Maurizio Pelizzone
 
Groovy Introduction - JAX Germany - 2008
Groovy Introduction - JAX Germany - 2008Groovy Introduction - JAX Germany - 2008
Groovy Introduction - JAX Germany - 2008Guillaume Laforge
 
Knolx session
Knolx sessionKnolx session
Knolx sessionKnoldus Inc.
 

Ähnlich wie 02. php ext module vng (20)

GWT MVP Case Study
GWT MVP Case StudyGWT MVP Case Study
GWT MVP Case Study
 
Node.js for enterprise - JS Conference
Node.js for enterprise - JS ConferenceNode.js for enterprise - JS Conference
Node.js for enterprise - JS Conference
 
NodeJS for Beginner
NodeJS for BeginnerNodeJS for Beginner
NodeJS for Beginner
 
Taming Deployment With Smart Frog
Taming Deployment With Smart FrogTaming Deployment With Smart Frog
Taming Deployment With Smart Frog
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
 
Twig, the flexible, fast, and secure template language for PHP
Twig, the flexible, fast, and secure template language for PHPTwig, the flexible, fast, and secure template language for PHP
Twig, the flexible, fast, and secure template language for PHP
 
How to Write Node.js Module
How to Write Node.js ModuleHow to Write Node.js Module
How to Write Node.js Module
 
Hack Like It's 2013 (The Workshop)
Hack Like It's 2013 (The Workshop)Hack Like It's 2013 (The Workshop)
Hack Like It's 2013 (The Workshop)
 
Swift profiling middleware and tools
Swift profiling middleware and toolsSwift profiling middleware and tools
Swift profiling middleware and tools
 
SOA with C, C++, PHP and more
SOA with C, C++, PHP and moreSOA with C, C++, PHP and more
SOA with C, C++, PHP and more
 
Node js meetup
Node js meetupNode js meetup
Node js meetup
 
Twig for Drupal @ Frontendunited Amsterdam 2012
Twig for Drupal @ Frontendunited Amsterdam 2012Twig for Drupal @ Frontendunited Amsterdam 2012
Twig for Drupal @ Frontendunited Amsterdam 2012
 
Secure Programming
Secure ProgrammingSecure Programming
Secure Programming
 
Portland Puppet User Group June 2014: Writing and publishing puppet modules
Portland Puppet User Group June 2014: Writing and publishing puppet modulesPortland Puppet User Group June 2014: Writing and publishing puppet modules
Portland Puppet User Group June 2014: Writing and publishing puppet modules
 
June 2014 PDX PUG: Writing and Publishing Puppet Modules
June 2014 PDX PUG: Writing and Publishing Puppet Modules June 2014 PDX PUG: Writing and Publishing Puppet Modules
June 2014 PDX PUG: Writing and Publishing Puppet Modules
 
Attacking Pipelines--Security meets Continuous Delivery
Attacking Pipelines--Security meets Continuous DeliveryAttacking Pipelines--Security meets Continuous Delivery
Attacking Pipelines--Security meets Continuous Delivery
 
Build Your Own HiveMQ Extension
Build Your Own HiveMQ ExtensionBuild Your Own HiveMQ Extension
Build Your Own HiveMQ Extension
 
Use Symfony2 components inside WordPress
Use Symfony2 components inside WordPress Use Symfony2 components inside WordPress
Use Symfony2 components inside WordPress
 
Groovy Introduction - JAX Germany - 2008
Groovy Introduction - JAX Germany - 2008Groovy Introduction - JAX Germany - 2008
Groovy Introduction - JAX Germany - 2008
 
Knolx session
Knolx sessionKnolx session
Knolx session
 

Mehr von Quang Anh Le

02 mobile monday hanoi april 2013 vinova
02 mobile monday hanoi april 2013   vinova02 mobile monday hanoi april 2013   vinova
02 mobile monday hanoi april 2013 vinovaQuang Anh Le
 
01 mobile monday hanoi april 2013 mobile game - afoli
01 mobile monday hanoi april 2013   mobile game - afoli01 mobile monday hanoi april 2013   mobile game - afoli
01 mobile monday hanoi april 2013 mobile game - afoliQuang Anh Le
 
03 mobile monday hanoi april 2013 monetize thinking g mo m-work
03 mobile monday hanoi april 2013 monetize thinking g mo   m-work03 mobile monday hanoi april 2013 monetize thinking g mo   m-work
03 mobile monday hanoi april 2013 monetize thinking g mo m-workQuang Anh Le
 
2. minh chau momo t4
2. minh chau momo t42. minh chau momo t4
2. minh chau momo t4Quang Anh Le
 
0. mobilemonday.vn hcm 20130424
0. mobilemonday.vn hcm 201304240. mobilemonday.vn hcm 20130424
0. mobilemonday.vn hcm 20130424Quang Anh Le
 
Vietnam mobile day 2012 phan mem cho phai dep - mana
Vietnam mobile day 2012   phan mem cho phai dep - manaVietnam mobile day 2012   phan mem cho phai dep - mana
Vietnam mobile day 2012 phan mem cho phai dep - manaQuang Anh Le
 
Vietnam mobile day 2012 i os memory management - techmaster
Vietnam mobile day 2012   i os memory management - techmasterVietnam mobile day 2012   i os memory management - techmaster
Vietnam mobile day 2012 i os memory management - techmasterQuang Anh Le
 
Vietnam mobile day 2012 monetizing mobile apps games - rubycell
Vietnam mobile day 2012   monetizing mobile apps games - rubycellVietnam mobile day 2012   monetizing mobile apps games - rubycell
Vietnam mobile day 2012 monetizing mobile apps games - rubycellQuang Anh Le
 
Vietnam mobile day 2012 cuoc cach mang thoi ky hau mobile - misfit
Vietnam mobile day 2012   cuoc cach mang thoi ky hau mobile - misfitVietnam mobile day 2012   cuoc cach mang thoi ky hau mobile - misfit
Vietnam mobile day 2012 cuoc cach mang thoi ky hau mobile - misfitQuang Anh Le
 
Vietnam mobile day 2012 multi platform development - game loft
Vietnam mobile day 2012   multi platform development - game loftVietnam mobile day 2012   multi platform development - game loft
Vietnam mobile day 2012 multi platform development - game loftQuang Anh Le
 
Vietnam mobile day 2012 developer opportunity - nokia
Vietnam mobile day 2012   developer opportunity - nokiaVietnam mobile day 2012   developer opportunity - nokia
Vietnam mobile day 2012 developer opportunity - nokiaQuang Anh Le
 
Vietnam mobile day 2012 building a mobile linux firmware for your router - ...
Vietnam mobile day 2012   building a mobile linux firmware for your router - ...Vietnam mobile day 2012   building a mobile linux firmware for your router - ...
Vietnam mobile day 2012 building a mobile linux firmware for your router - ...Quang Anh Le
 
Vietnam mobile day 2012 ban quyen mobile contents - vsm
Vietnam mobile day 2012   ban quyen mobile contents - vsmVietnam mobile day 2012   ban quyen mobile contents - vsm
Vietnam mobile day 2012 ban quyen mobile contents - vsmQuang Anh Le
 
Vietnam mobile day 2012 platform mo va ung dung de phat trien mang xa hoi m...
Vietnam mobile day 2012   platform mo va ung dung de phat trien mang xa hoi m...Vietnam mobile day 2012   platform mo va ung dung de phat trien mang xa hoi m...
Vietnam mobile day 2012 platform mo va ung dung de phat trien mang xa hoi m...Quang Anh Le
 
Vietnam mobile day 2012 co hoi mobile tai vietnam - cyber agent
Vietnam mobile day 2012   co hoi mobile tai vietnam - cyber agentVietnam mobile day 2012   co hoi mobile tai vietnam - cyber agent
Vietnam mobile day 2012 co hoi mobile tai vietnam - cyber agentQuang Anh Le
 
Vietnam mobile day 2012 html5 game using impact js - aiti-aptech
Vietnam mobile day 2012   html5 game using impact js - aiti-aptechVietnam mobile day 2012   html5 game using impact js - aiti-aptech
Vietnam mobile day 2012 html5 game using impact js - aiti-aptechQuang Anh Le
 
Vietnam mobile day 2012 tuong lai cho nha phat trien nds - share plus
Vietnam mobile day 2012   tuong lai cho nha phat trien nds - share plusVietnam mobile day 2012   tuong lai cho nha phat trien nds - share plus
Vietnam mobile day 2012 tuong lai cho nha phat trien nds - share plusQuang Anh Le
 
Vietnam mobile day 2012 trends in mobile marketing - fifth i media
Vietnam mobile day 2012   trends in mobile marketing - fifth i mediaVietnam mobile day 2012   trends in mobile marketing - fifth i media
Vietnam mobile day 2012 trends in mobile marketing - fifth i mediaQuang Anh Le
 
Vietnam mobile day 2012 thi hieu nguoi dung mobile - app storevn
Vietnam mobile day 2012   thi hieu nguoi dung mobile - app storevnVietnam mobile day 2012   thi hieu nguoi dung mobile - app storevn
Vietnam mobile day 2012 thi hieu nguoi dung mobile - app storevnQuang Anh Le
 
Vietnam mobile day 2012 new platform - new opportunity - appota
Vietnam mobile day 2012   new platform - new opportunity - appotaVietnam mobile day 2012   new platform - new opportunity - appota
Vietnam mobile day 2012 new platform - new opportunity - appotaQuang Anh Le
 

Mehr von Quang Anh Le (20)

02 mobile monday hanoi april 2013 vinova
02 mobile monday hanoi april 2013   vinova02 mobile monday hanoi april 2013   vinova
02 mobile monday hanoi april 2013 vinova
 
01 mobile monday hanoi april 2013 mobile game - afoli
01 mobile monday hanoi april 2013   mobile game - afoli01 mobile monday hanoi april 2013   mobile game - afoli
01 mobile monday hanoi april 2013 mobile game - afoli
 
03 mobile monday hanoi april 2013 monetize thinking g mo m-work
03 mobile monday hanoi april 2013 monetize thinking g mo   m-work03 mobile monday hanoi april 2013 monetize thinking g mo   m-work
03 mobile monday hanoi april 2013 monetize thinking g mo m-work
 
2. minh chau momo t4
2. minh chau momo t42. minh chau momo t4
2. minh chau momo t4
 
0. mobilemonday.vn hcm 20130424
0. mobilemonday.vn hcm 201304240. mobilemonday.vn hcm 20130424
0. mobilemonday.vn hcm 20130424
 
Vietnam mobile day 2012 phan mem cho phai dep - mana
Vietnam mobile day 2012   phan mem cho phai dep - manaVietnam mobile day 2012   phan mem cho phai dep - mana
Vietnam mobile day 2012 phan mem cho phai dep - mana
 
Vietnam mobile day 2012 i os memory management - techmaster
Vietnam mobile day 2012   i os memory management - techmasterVietnam mobile day 2012   i os memory management - techmaster
Vietnam mobile day 2012 i os memory management - techmaster
 
Vietnam mobile day 2012 monetizing mobile apps games - rubycell
Vietnam mobile day 2012   monetizing mobile apps games - rubycellVietnam mobile day 2012   monetizing mobile apps games - rubycell
Vietnam mobile day 2012 monetizing mobile apps games - rubycell
 
Vietnam mobile day 2012 cuoc cach mang thoi ky hau mobile - misfit
Vietnam mobile day 2012   cuoc cach mang thoi ky hau mobile - misfitVietnam mobile day 2012   cuoc cach mang thoi ky hau mobile - misfit
Vietnam mobile day 2012 cuoc cach mang thoi ky hau mobile - misfit
 
Vietnam mobile day 2012 multi platform development - game loft
Vietnam mobile day 2012   multi platform development - game loftVietnam mobile day 2012   multi platform development - game loft
Vietnam mobile day 2012 multi platform development - game loft
 
Vietnam mobile day 2012 developer opportunity - nokia
Vietnam mobile day 2012   developer opportunity - nokiaVietnam mobile day 2012   developer opportunity - nokia
Vietnam mobile day 2012 developer opportunity - nokia
 
Vietnam mobile day 2012 building a mobile linux firmware for your router - ...
Vietnam mobile day 2012   building a mobile linux firmware for your router - ...Vietnam mobile day 2012   building a mobile linux firmware for your router - ...
Vietnam mobile day 2012 building a mobile linux firmware for your router - ...
 
Vietnam mobile day 2012 ban quyen mobile contents - vsm
Vietnam mobile day 2012   ban quyen mobile contents - vsmVietnam mobile day 2012   ban quyen mobile contents - vsm
Vietnam mobile day 2012 ban quyen mobile contents - vsm
 
Vietnam mobile day 2012 platform mo va ung dung de phat trien mang xa hoi m...
Vietnam mobile day 2012   platform mo va ung dung de phat trien mang xa hoi m...Vietnam mobile day 2012   platform mo va ung dung de phat trien mang xa hoi m...
Vietnam mobile day 2012 platform mo va ung dung de phat trien mang xa hoi m...
 
Vietnam mobile day 2012 co hoi mobile tai vietnam - cyber agent
Vietnam mobile day 2012   co hoi mobile tai vietnam - cyber agentVietnam mobile day 2012   co hoi mobile tai vietnam - cyber agent
Vietnam mobile day 2012 co hoi mobile tai vietnam - cyber agent
 
Vietnam mobile day 2012 html5 game using impact js - aiti-aptech
Vietnam mobile day 2012   html5 game using impact js - aiti-aptechVietnam mobile day 2012   html5 game using impact js - aiti-aptech
Vietnam mobile day 2012 html5 game using impact js - aiti-aptech
 
Vietnam mobile day 2012 tuong lai cho nha phat trien nds - share plus
Vietnam mobile day 2012   tuong lai cho nha phat trien nds - share plusVietnam mobile day 2012   tuong lai cho nha phat trien nds - share plus
Vietnam mobile day 2012 tuong lai cho nha phat trien nds - share plus
 
Vietnam mobile day 2012 trends in mobile marketing - fifth i media
Vietnam mobile day 2012   trends in mobile marketing - fifth i mediaVietnam mobile day 2012   trends in mobile marketing - fifth i media
Vietnam mobile day 2012 trends in mobile marketing - fifth i media
 
Vietnam mobile day 2012 thi hieu nguoi dung mobile - app storevn
Vietnam mobile day 2012   thi hieu nguoi dung mobile - app storevnVietnam mobile day 2012   thi hieu nguoi dung mobile - app storevn
Vietnam mobile day 2012 thi hieu nguoi dung mobile - app storevn
 
Vietnam mobile day 2012 new platform - new opportunity - appota
Vietnam mobile day 2012   new platform - new opportunity - appotaVietnam mobile day 2012   new platform - new opportunity - appota
Vietnam mobile day 2012 new platform - new opportunity - appota
 

KĂŒrzlich hochgeladen

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
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
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
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
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
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
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
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
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
 
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
 
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
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
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
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 

KĂŒrzlich hochgeladen (20)

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
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
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...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
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
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
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
 
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
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
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
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 

02. php ext module vng

  • 1. 18/12/2010 Speed up ZingMe-NTVV2 with PHP extension module By Nguyen Trung Thanh ZingMe Team leader Web Technical - VNG
  • 4. Introduction ‱ Ntvv2 (http://me.zing.vn/apps/ntvv2) – 1.M daily active user – Average 800 rps (per webserver) max 1100 rps – 9300 rps (all database servers) – 3 webservers ‱ Use Membase for cache and storage ‱ Use other db for secondary storage ‱ All bussiness function is moved to PHP extension
  • 5. Why to write PHP module? Make complicated Bussiness functions run faster, consume less memory PHP high-level overhead cpu/mem Advance facility with PHP-FPM Cache something in PHP process Strictly Confidential – Do Not Distribute
  • 6. PHP extension basic What is an extension? Lifecycle Setting up a build environment http://devzone.zend.com/article/4486 http://devzone.zend.com/article/1021-Extension-Writing-Part-I- Introduction-to-PHP-and-Zend
  • 7. What is an extension? Have you ever used PHP extension? PHP consist of many extensions All function we used is from extensions
  • 9. Setting up build environment - Setup PHP-devel - Sample extension
  • 10. Is it complicated? ● Is there any sexier and easier way? ● We can use SWIG
  • 11. SWIG SWIG is an interface compiler that connects programs written in C and C++ with scripting languages such as PHP, Python, Ruby... How SWIG works Using SWIG Install module to PHP extensions Sample Strictly Confidential – Do Not Distribute
  • 13. What does SWIG do for you ? Namespace Constants Type conversion For simple types (int, float, char *, enum) Wraps complex types Pointers to structs and classes Exposes functions
  • 14. Using SWIG Defile module in swig file Generate source code Create module project, build it
  • 15. Define module Data type Wrapper class/functions %module ntvv2module %{ #include <string> #include <vector> #include <list> #include <string> #include “ntvvgame.h" %} struct LandInfo{ int id; std::string data; } ; Strictly Confidential – Do Not Distribute LandInfo updateLandInfo(int uid, int landID);
  • 16. Exposure ‱Swig recognizes C/C++ declarations 'struct' or 'class' functions ‱Hiding elements %ignore solver::noupdate; %include “satsolver/solver.h”
  • 17. Useful commands ‱Renaming %rename("to_s") asString(); %rename( "name=" ) set_name( const char *name ); %rename("empty?") empty(); ‱Aliasing %alias get "[]"; ‱Constants %constant int Script = C_CONSTANT; ‱Defines %define YUILogComponent "bindings" %enddef %define %macro(PARAMETER)
  • 18. SWIG steps Generate code Create project, compiling – Add genterated code to project Running – Add extension module to PHP
  • 19. Sample Cache data in PHP module Strictly Confidential – Do Not Distribute
  • 20. Q&A