SlideShare a Scribd company logo
1 of 20
Download to read offline
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

More Related Content

Viewers also liked

Zing Database – Distributed Key-Value Database
Zing Database – Distributed Key-Value DatabaseZing Database – Distributed Key-Value Database
Zing Database – Distributed Key-Value Databasezingopen
 
Tất tần tật về zalo page
Tất tần tật về zalo pageTất tần tật về zalo page
Tất tần tật về zalo pageAnh Tên Yêu
 
The pharmacists role in drug induced nutrient depletion n. jones
The pharmacists role in drug induced nutrient depletion   n. jonesThe pharmacists role in drug induced nutrient depletion   n. jones
The pharmacists role in drug induced nutrient depletion n. jonesPASaskatchewan
 
Stream upload and asynchronous job processing in large scale systems
Stream upload and asynchronous job processing  in large scale systemsStream upload and asynchronous job processing  in large scale systems
Stream upload and asynchronous job processing in large scale systemsZalo_app
 
AWS: How to deploy and scale your web application in the cloud
AWS: How to deploy and scale your web application in the cloudAWS: How to deploy and scale your web application in the cloud
AWS: How to deploy and scale your web application in the cloudBarcamp Saigon
 
Server log, monitoring and qo s platform of a messaging app
Server   log, monitoring and qo s platform of a messaging appServer   log, monitoring and qo s platform of a messaging app
Server log, monitoring and qo s platform of a messaging appZalo_app
 
Construcción de los números naturales
Construcción de los números naturalesConstrucción de los números naturales
Construcción de los números naturalesInstituto Von Neumann
 
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
 
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
 
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 ...Quang Diệu Nguyễn
 

Viewers also liked (10)

Zing Database – Distributed Key-Value Database
Zing Database – Distributed Key-Value DatabaseZing Database – Distributed Key-Value Database
Zing Database – Distributed Key-Value Database
 
Tất tần tật về zalo page
Tất tần tật về zalo pageTất tần tật về zalo page
Tất tần tật về zalo page
 
The pharmacists role in drug induced nutrient depletion n. jones
The pharmacists role in drug induced nutrient depletion   n. jonesThe pharmacists role in drug induced nutrient depletion   n. jones
The pharmacists role in drug induced nutrient depletion n. jones
 
Stream upload and asynchronous job processing in large scale systems
Stream upload and asynchronous job processing  in large scale systemsStream upload and asynchronous job processing  in large scale systems
Stream upload and asynchronous job processing in large scale systems
 
AWS: How to deploy and scale your web application in the cloud
AWS: How to deploy and scale your web application in the cloudAWS: How to deploy and scale your web application in the cloud
AWS: How to deploy and scale your web application in the cloud
 
Server log, monitoring and qo s platform of a messaging app
Server   log, monitoring and qo s platform of a messaging appServer   log, monitoring and qo s platform of a messaging app
Server log, monitoring and qo s platform of a messaging app
 
Construcción de los números naturales
Construcción de los números naturalesConstrucción de los números naturales
Construcción de los números naturales
 
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
 
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 ...
 
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 ...
 

Similar to 02 vng thanhnt-speedup_ntvv2_by_ph_pextmodule_

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
 
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
 

Similar to 02 vng thanhnt-speedup_ntvv2_by_ph_pextmodule_ (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
 

More from Nguyen Duc Phu

iOS Gaming with Cocos2d
iOS Gaming with Cocos2diOS Gaming with Cocos2d
iOS Gaming with Cocos2dNguyen Duc Phu
 
05 - Phan Thai Trung - Tu dong dat hang tu he thong ban le lon nhat Trung Quoc
05 - Phan Thai Trung - Tu dong dat hang tu he thong ban le lon nhat Trung Quoc05 - Phan Thai Trung - Tu dong dat hang tu he thong ban le lon nhat Trung Quoc
05 - Phan Thai Trung - Tu dong dat hang tu he thong ban le lon nhat Trung QuocNguyen Duc Phu
 
8 - Javascript unit testing framework
8 - Javascript unit testing framework8 - Javascript unit testing framework
8 - Javascript unit testing frameworkNguyen Duc Phu
 
Hanoi php day 2008 - 05. nguyen hai nhat huy - building-restful-web-service-w...
Hanoi php day 2008 - 05. nguyen hai nhat huy - building-restful-web-service-w...Hanoi php day 2008 - 05. nguyen hai nhat huy - building-restful-web-service-w...
Hanoi php day 2008 - 05. nguyen hai nhat huy - building-restful-web-service-w...Nguyen Duc Phu
 
Hanoi php day 2008 - 03. dang minh tuan - html, css, javascript
Hanoi php day 2008 - 03. dang minh tuan - html, css, javascriptHanoi php day 2008 - 03. dang minh tuan - html, css, javascript
Hanoi php day 2008 - 03. dang minh tuan - html, css, javascriptNguyen Duc Phu
 
Hanoi php day 2008 - 01.pham cong dinh - how.to.build.your.own.framework
Hanoi php day 2008 - 01.pham cong dinh - how.to.build.your.own.frameworkHanoi php day 2008 - 01.pham cong dinh - how.to.build.your.own.framework
Hanoi php day 2008 - 01.pham cong dinh - how.to.build.your.own.frameworkNguyen Duc Phu
 
Hanoi php day 2008 - 02. phan thai trung - drupal
Hanoi php day 2008 - 02. phan thai trung - drupalHanoi php day 2008 - 02. phan thai trung - drupal
Hanoi php day 2008 - 02. phan thai trung - drupalNguyen Duc Phu
 
13 social network game
13 social network game13 social network game
13 social network gameNguyen Duc Phu
 
12 trung-oss-magento-overview
12 trung-oss-magento-overview12 trung-oss-magento-overview
12 trung-oss-magento-overviewNguyen Duc Phu
 
11 building joomla! extensions with flex integration
11 building joomla! extensions with flex integration11 building joomla! extensions with flex integration
11 building joomla! extensions with flex integrationNguyen Duc Phu
 
10 su dung drupal xay dung mang xa hoi
10 su dung drupal xay dung mang xa hoi10 su dung drupal xay dung mang xa hoi
10 su dung drupal xay dung mang xa hoiNguyen Duc Phu
 
09 html5 css3-the_future_of_web_technology
09 html5 css3-the_future_of_web_technology09 html5 css3-the_future_of_web_technology
09 html5 css3-the_future_of_web_technologyNguyen Duc Phu
 
07 build your-own_php_extension
07 build your-own_php_extension07 build your-own_php_extension
07 build your-own_php_extensionNguyen Duc Phu
 
01 zingme practice for building scalable website with php
01 zingme practice for building scalable website with php01 zingme practice for building scalable website with php
01 zingme practice for building scalable website with phpNguyen Duc Phu
 
14 how startups can benefit from launch community
14 how startups can benefit from launch community14 how startups can benefit from launch community
14 how startups can benefit from launch communityNguyen Duc Phu
 
Hanoi PHP Day 2008 - 04 - Nguyen Duc Phu - Search Engine: New Collection S...
Hanoi PHP Day 2008 -  04 - Nguyen Duc Phu  -  Search Engine: New Collection S...Hanoi PHP Day 2008 -  04 - Nguyen Duc Phu  -  Search Engine: New Collection S...
Hanoi PHP Day 2008 - 04 - Nguyen Duc Phu - Search Engine: New Collection S...Nguyen Duc Phu
 

More from Nguyen Duc Phu (17)

iOS Gaming with Cocos2d
iOS Gaming with Cocos2diOS Gaming with Cocos2d
iOS Gaming with Cocos2d
 
05 - Phan Thai Trung - Tu dong dat hang tu he thong ban le lon nhat Trung Quoc
05 - Phan Thai Trung - Tu dong dat hang tu he thong ban le lon nhat Trung Quoc05 - Phan Thai Trung - Tu dong dat hang tu he thong ban le lon nhat Trung Quoc
05 - Phan Thai Trung - Tu dong dat hang tu he thong ban le lon nhat Trung Quoc
 
8 - Javascript unit testing framework
8 - Javascript unit testing framework8 - Javascript unit testing framework
8 - Javascript unit testing framework
 
Hanoi php day 2008 - 05. nguyen hai nhat huy - building-restful-web-service-w...
Hanoi php day 2008 - 05. nguyen hai nhat huy - building-restful-web-service-w...Hanoi php day 2008 - 05. nguyen hai nhat huy - building-restful-web-service-w...
Hanoi php day 2008 - 05. nguyen hai nhat huy - building-restful-web-service-w...
 
Hanoi php day 2008 - 03. dang minh tuan - html, css, javascript
Hanoi php day 2008 - 03. dang minh tuan - html, css, javascriptHanoi php day 2008 - 03. dang minh tuan - html, css, javascript
Hanoi php day 2008 - 03. dang minh tuan - html, css, javascript
 
Hanoi php day 2008 - 01.pham cong dinh - how.to.build.your.own.framework
Hanoi php day 2008 - 01.pham cong dinh - how.to.build.your.own.frameworkHanoi php day 2008 - 01.pham cong dinh - how.to.build.your.own.framework
Hanoi php day 2008 - 01.pham cong dinh - how.to.build.your.own.framework
 
Hanoi php day 2008 - 02. phan thai trung - drupal
Hanoi php day 2008 - 02. phan thai trung - drupalHanoi php day 2008 - 02. phan thai trung - drupal
Hanoi php day 2008 - 02. phan thai trung - drupal
 
13 social network game
13 social network game13 social network game
13 social network game
 
12 trung-oss-magento-overview
12 trung-oss-magento-overview12 trung-oss-magento-overview
12 trung-oss-magento-overview
 
11 building joomla! extensions with flex integration
11 building joomla! extensions with flex integration11 building joomla! extensions with flex integration
11 building joomla! extensions with flex integration
 
10 su dung drupal xay dung mang xa hoi
10 su dung drupal xay dung mang xa hoi10 su dung drupal xay dung mang xa hoi
10 su dung drupal xay dung mang xa hoi
 
09 html5 css3-the_future_of_web_technology
09 html5 css3-the_future_of_web_technology09 html5 css3-the_future_of_web_technology
09 html5 css3-the_future_of_web_technology
 
07 build your-own_php_extension
07 build your-own_php_extension07 build your-own_php_extension
07 build your-own_php_extension
 
04 web optimization
04 web optimization04 web optimization
04 web optimization
 
01 zingme practice for building scalable website with php
01 zingme practice for building scalable website with php01 zingme practice for building scalable website with php
01 zingme practice for building scalable website with php
 
14 how startups can benefit from launch community
14 how startups can benefit from launch community14 how startups can benefit from launch community
14 how startups can benefit from launch community
 
Hanoi PHP Day 2008 - 04 - Nguyen Duc Phu - Search Engine: New Collection S...
Hanoi PHP Day 2008 -  04 - Nguyen Duc Phu  -  Search Engine: New Collection S...Hanoi PHP Day 2008 -  04 - Nguyen Duc Phu  -  Search Engine: New Collection S...
Hanoi PHP Day 2008 - 04 - Nguyen Duc Phu - Search Engine: New Collection S...
 

Recently uploaded

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
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
 
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
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
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
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Principled Technologies
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
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
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
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
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 

Recently uploaded (20)

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
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...
 
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
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
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
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
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
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
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
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 

02 vng thanhnt-speedup_ntvv2_by_ph_pextmodule_

  • 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