SlideShare a Scribd company logo
Building a horizontally scalable API in PHPyada...yada...title was really too long wasn’t it?
Presumptions
Working with MySQL5.1 + InnoDBPlugin or 5.5Binary hashesLearn the configuration optionsSeparation of data logically (e.g. user data vs. analytical data)
CouchDBCouchDB, Couchbase, BigCouch...Stale viewsNatural keysDocument update handlersDesign doc modification = rebuild
Example update functionfunction (doc, req) {    try {        varobj = eval('(' + req.body + ')');    } catch (err) {        return [null, {            headers: {                'X-Status-Code': '400'            },            body: 'Invalid JSON'        }];    }    if (!doc) {        if (!obj.url) return [null, {            headers: {                'X-Status-Code': '422'            },            body: 'No URL'        }];         doc = {            _id: req.path[5],            url: obj.url,             statistics: []        };    }    if (obj.url) delete obj.url;    doc.statistics.push(obj);    return [doc, 'OK'];}
CachingVarnishMembase (distributed Memcache)Op code caching (disable file check)
Zend FrameworkDoes have a REST Controller (albeit pants, but it’s a starting point) – and we don’t call it Rest, we just call it an API Extend the controller as your baseGET/PUT/POST/DELETE/HEAD/OPTIONS on the extensionReflection allows automatic use of Allow headerOPTIONS can parse doc block for automation (@property)A global error controller is great for centralised management of errors.Re-use modules – you’ve got an API you can use.
Example of implemented Methods public function implementedMethods()    {        if(!isset($this->_actionController))            return array();        $class              = get_class($this->_actionController);        $oReflector         = new ReflectionClass($class);        $methods            = $oReflector->getMethods(ReflectionMethod::IS_PUBLIC);        $implementedMethods = array();foreach($methods as $i => $method) /* @var $method ReflectionMethod */        {            if($method->getDeclaringClass()->getName() == $class)                $implementedMethods[] = str_replace('Action', '', $method->getName());        }        return array_intersect($implementedMethods, array('get', 'put', 'post', 'delete', 'head', 'options', 'trace'));    }
PHPRequests using date ranges – break down using DateInterval then cachefopen(‘php://input’, ‘r’) for PUT data.Exception($message, $code, $previous)text/uri-list
BuildingSSH keysCI tool (Hudson/Jenkins) for testing and uploadingLots of boxes = distribution server
Testing (Stress)Apache JMeter is a great java GUI/CLI tool for both testing requests and stress testingAPI’s should inherently allow independent testing of minimal components at the user request level
Linkshttp://jakarta.apache.org/jmeter/http://www.xcitestudios.com/https://cloudant.com/http://couchdb.apache.org/http://www.membase.org/Twitter@wadewomersley
                   Questions?

More Related Content

What's hot (20)

PPT
Arrays in PHP
Compare Infobase Limited
 
PDF
Php array
Nikul Shah
 
PPTX
Array in php
ilakkiya
 
TXT
Threading
b290572
 
PDF
Nickolay Shmalenuk.Render api eng.DrupalCamp Kyiv 2011
camp_drupal_ua
 
PPTX
13. CodeIgniter vederea inregistrarilor3
Razvan Raducanu, PhD
 
PPT
Class 4 - PHP Arrays
Ahmed Swilam
 
PPT
Php Using Arrays
mussawir20
 
PPTX
12. CodeIgniter vederea inregistrarilor2
Razvan Raducanu, PhD
 
PDF
WordCamp Portland 2018: PHP for WordPress
Alena Holligan
 
PDF
Puppet Camp Amsterdam 2015: Manifests of Future Past
Puppet
 
PPTX
15. CodeIgniter editarea inregistrarilor
Razvan Raducanu, PhD
 
PDF
3 u-mpb2u2na
judith Steffan
 
PDF
Drupal - dbtng 25th Anniversary Edition
ddiers
 
PDF
ランダム文字ぽいものをつくる
Tetsuji Koyama
 
PPTX
MS SQL Database basic
wali1195189
 
PPTX
Database Management - Lecture 4 - PHP and Mysql
Al-Mamun Sarkar
 
PPSX
CodeIgniter L4 file upload & image manipulation & language
Mohammad Tahsin Alshalabi
 
PDF
GDI Seattle - Intro to JavaScript Class 2
Heather Rock
 
Php array
Nikul Shah
 
Array in php
ilakkiya
 
Threading
b290572
 
Nickolay Shmalenuk.Render api eng.DrupalCamp Kyiv 2011
camp_drupal_ua
 
13. CodeIgniter vederea inregistrarilor3
Razvan Raducanu, PhD
 
Class 4 - PHP Arrays
Ahmed Swilam
 
Php Using Arrays
mussawir20
 
12. CodeIgniter vederea inregistrarilor2
Razvan Raducanu, PhD
 
WordCamp Portland 2018: PHP for WordPress
Alena Holligan
 
Puppet Camp Amsterdam 2015: Manifests of Future Past
Puppet
 
15. CodeIgniter editarea inregistrarilor
Razvan Raducanu, PhD
 
3 u-mpb2u2na
judith Steffan
 
Drupal - dbtng 25th Anniversary Edition
ddiers
 
ランダム文字ぽいものをつくる
Tetsuji Koyama
 
MS SQL Database basic
wali1195189
 
Database Management - Lecture 4 - PHP and Mysql
Al-Mamun Sarkar
 
CodeIgniter L4 file upload & image manipulation & language
Mohammad Tahsin Alshalabi
 
GDI Seattle - Intro to JavaScript Class 2
Heather Rock
 

Viewers also liked (6)

PDF
Evolving Infrastructure and Management for Business Agility
Red Hat India Pvt. Ltd.
 
PPT
Redis in Practice: Scenarios, Performance and Practice with PHP
Chen Huang
 
PDF
Modern software architectures - PHP UK Conference 2015
Ricard Clau
 
PPTX
From distributed caches to in-memory data grids
Max Alexejev
 
PDF
Handling 10k requests per second with Symfony and Varnish - SymfonyCon Berlin...
Alexander Lisachenko
 
KEY
Redis in Practice
Noah Davis
 
Evolving Infrastructure and Management for Business Agility
Red Hat India Pvt. Ltd.
 
Redis in Practice: Scenarios, Performance and Practice with PHP
Chen Huang
 
Modern software architectures - PHP UK Conference 2015
Ricard Clau
 
From distributed caches to in-memory data grids
Max Alexejev
 
Handling 10k requests per second with Symfony and Varnish - SymfonyCon Berlin...
Alexander Lisachenko
 
Redis in Practice
Noah Davis
 
Ad

Similar to Building a horizontally scalable API in php (20)

PPT
Easy rest service using PHP reflection api
Matthieu Aubry
 
PDF
Api Design
sumithra jonnalagadda
 
PDF
Building a fully API-based platform on top of cPanel
Dominic Lüchinger
 
PPTX
Introduction to Monsoon PHP framework
Krishna Srikanth Manda
 
PPTX
Modularizing RESTful Web Service Management with Aspect Oriented Programming
Widhian Bramantya
 
PDF
Api guide
Deepak Rai
 
PDF
Zendcon 2007 Api Design
unodelostrece
 
PPTX
Creating web APIs with apigility
Kaloyan Raev
 
ODP
Building Web Services with Zend Framework (PHP Benelux meeting 20100713 Vliss...
King Foo
 
KEY
Future of PHP
Richard McIntyre
 
KEY
Scaling php applications with redis
jimbojsb
 
PDF
Charla EHU Noviembre 2014 - Desarrollo Web
Mikel Torres Ugarte
 
PDF
Tiery Eyed
ZendCon
 
PPTX
Day01 api
ABDEL RAHMAN KARIM
 
PDF
PHP At 5000 Requests Per Second: Hootsuite’s Scaling Story
vanphp
 
PPTX
Test driven APIs with Laravel
Michael Peacock
 
ODP
Intro to CouchDB
sbisbee
 
PPTX
Day02 a pi.
ABDEL RAHMAN KARIM
 
PDF
Building a Great Web API - Evan Cooke - QCON 2011
Twilio Inc
 
PDF
zingmepracticeforbuildingscalablewebsitewithphp
hazzaz
 
Easy rest service using PHP reflection api
Matthieu Aubry
 
Building a fully API-based platform on top of cPanel
Dominic Lüchinger
 
Introduction to Monsoon PHP framework
Krishna Srikanth Manda
 
Modularizing RESTful Web Service Management with Aspect Oriented Programming
Widhian Bramantya
 
Api guide
Deepak Rai
 
Zendcon 2007 Api Design
unodelostrece
 
Creating web APIs with apigility
Kaloyan Raev
 
Building Web Services with Zend Framework (PHP Benelux meeting 20100713 Vliss...
King Foo
 
Future of PHP
Richard McIntyre
 
Scaling php applications with redis
jimbojsb
 
Charla EHU Noviembre 2014 - Desarrollo Web
Mikel Torres Ugarte
 
Tiery Eyed
ZendCon
 
PHP At 5000 Requests Per Second: Hootsuite’s Scaling Story
vanphp
 
Test driven APIs with Laravel
Michael Peacock
 
Intro to CouchDB
sbisbee
 
Day02 a pi.
ABDEL RAHMAN KARIM
 
Building a Great Web API - Evan Cooke - QCON 2011
Twilio Inc
 
zingmepracticeforbuildingscalablewebsitewithphp
hazzaz
 
Ad

Recently uploaded (20)

PDF
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
PDF
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
PPTX
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PPTX
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PDF
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PPT
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
PDF
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PDF
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
PPTX
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 

Building a horizontally scalable API in php