Services Oriented Architecture with PHP and MySQL
-
Upload
joe-stump -
Category
Technology
-
view
10.013 -
download
0
description
Transcript of Services Oriented Architecture with PHP and MySQL
![Page 1: Services Oriented Architecture with PHP and MySQL](https://reader034.fdocuments.in/reader034/viewer/2022042714/54b78da04a7959b12c8b46db/html5/thumbnails/1.jpg)
Services Oriented Architecture with PHP
and MySQLJoe Stump, Lead Architect, Digg
![Page 2: Services Oriented Architecture with PHP and MySQL](https://reader034.fdocuments.in/reader034/viewer/2022042714/54b78da04a7959b12c8b46db/html5/thumbnails/2.jpg)
Introductions
I’m Joe Stump, Lead Architect for Digg.
![Page 3: Services Oriented Architecture with PHP and MySQL](https://reader034.fdocuments.in/reader034/viewer/2022042714/54b78da04a7959b12c8b46db/html5/thumbnails/3.jpg)
Reduce HTTP Requests
Bundle JavaScript and CSS Use sprites for images Reduce images / outside objects
This talk doesn’t cover MySQL details. The point of this discussion is how to minimize MySQL’s impact on your company’s data layer.
![Page 4: Services Oriented Architecture with PHP and MySQL](https://reader034.fdocuments.in/reader034/viewer/2022042714/54b78da04a7959b12c8b46db/html5/thumbnails/4.jpg)
Old habits die hard
Data requests are sequential Data requests are blocking Tightly coupled Scaling is not abstracted
![Page 5: Services Oriented Architecture with PHP and MySQL](https://reader034.fdocuments.in/reader034/viewer/2022042714/54b78da04a7959b12c8b46db/html5/thumbnails/5.jpg)
Services Oriented Architecture (SOA)
Data is requested from a service Data requests are ran in parallel Data requests are asynchronous Data layer is loosely coupled Scalability is abstracted
![Page 6: Services Oriented Architecture with PHP and MySQL](https://reader034.fdocuments.in/reader034/viewer/2022042714/54b78da04a7959b12c8b46db/html5/thumbnails/6.jpg)
What are my options?
Running requests over HTTP New York Times’ DBSlayer Danga’s Gearman DIY
![Page 7: Services Oriented Architecture with PHP and MySQL](https://reader034.fdocuments.in/reader034/viewer/2022042714/54b78da04a7959b12c8b46db/html5/thumbnails/7.jpg)
HTTP w/ PHP
1. Group requests for data at the top2. Open a socket for each request
1. Sockets must be non-blocking2. Make sure to TCP_NODELAY
3. Use __get() to block for results4. See Services_Digg_Request
![Page 8: Services Oriented Architecture with PHP and MySQL](https://reader034.fdocuments.in/reader034/viewer/2022042714/54b78da04a7959b12c8b46db/html5/thumbnails/8.jpg)
Grouping Data Requests
![Page 9: Services Oriented Architecture with PHP and MySQL](https://reader034.fdocuments.in/reader034/viewer/2022042714/54b78da04a7959b12c8b46db/html5/thumbnails/9.jpg)
Opening the Sockets
![Page 10: Services Oriented Architecture with PHP and MySQL](https://reader034.fdocuments.in/reader034/viewer/2022042714/54b78da04a7959b12c8b46db/html5/thumbnails/10.jpg)
Opening the Sockets
![Page 11: Services Oriented Architecture with PHP and MySQL](https://reader034.fdocuments.in/reader034/viewer/2022042714/54b78da04a7959b12c8b46db/html5/thumbnails/11.jpg)
Returning Data
![Page 12: Services Oriented Architecture with PHP and MySQL](https://reader034.fdocuments.in/reader034/viewer/2022042714/54b78da04a7959b12c8b46db/html5/thumbnails/12.jpg)
HTTP Conclusions
HTTP is widely supported in all languages Easy to get up and running Lots of options for servers / tuning Lots of overhead in protocol Apache has a lot of overhead
![Page 13: Services Oriented Architecture with PHP and MySQL](https://reader034.fdocuments.in/reader034/viewer/2022042714/54b78da04a7959b12c8b46db/html5/thumbnails/13.jpg)
DBSlayer
Small HTTP daemon written in C Uses JSON for communications Connection pooling Load balancing and failover Tightly coupled to MySQL (for now) Tightly coupled to SQL No intelligence
![Page 14: Services Oriented Architecture with PHP and MySQL](https://reader034.fdocuments.in/reader034/viewer/2022042714/54b78da04a7959b12c8b46db/html5/thumbnails/14.jpg)
Gearman
Highly scalable queuing system Simple/Efficient binary protocol Jobs can return results (e.g. data) Sets of jobs are ran in parallel Queue can scale linearly PHP, Perl, Python, Ruby, C clients Poorly documented Not very “robust”
![Page 15: Services Oriented Architecture with PHP and MySQL](https://reader034.fdocuments.in/reader034/viewer/2022042714/54b78da04a7959b12c8b46db/html5/thumbnails/15.jpg)
Do It Yourself
Highly customized solutions (Flickr) Extremely efficient for custom cases Customize your protocols Requires more resources
![Page 16: Services Oriented Architecture with PHP and MySQL](https://reader034.fdocuments.in/reader034/viewer/2022042714/54b78da04a7959b12c8b46db/html5/thumbnails/16.jpg)
What goes in the Service layer?
Smart caching strategies Data mapping and distribution Intelligent grouping of data results Partitioning logic
![Page 17: Services Oriented Architecture with PHP and MySQL](https://reader034.fdocuments.in/reader034/viewer/2022042714/54b78da04a7959b12c8b46db/html5/thumbnails/17.jpg)
DO WANT!
Intelligently group data into endpoints Version your endpoints Bundle and group requests
![Page 18: Services Oriented Architecture with PHP and MySQL](https://reader034.fdocuments.in/reader034/viewer/2022042714/54b78da04a7959b12c8b46db/html5/thumbnails/18.jpg)
EPIC FAIL!
Don’t just send SQL over for translation Hundreds of teeny tiny endpoints Not running SOA requests in parallel
![Page 19: Services Oriented Architecture with PHP and MySQL](https://reader034.fdocuments.in/reader034/viewer/2022042714/54b78da04a7959b12c8b46db/html5/thumbnails/19.jpg)
ResourcesServices_Digghttp://pear.php.net/package/Services_Digg
Danga’s Gearmanhttp://www.danga.com/gearman/
Net_Gearmanhttp://code.google.com/p/netgearman/
New York Timesʼ DBSlayerhttp://code.nytimes.com/projects/dbslayer
![Page 20: Services Oriented Architecture with PHP and MySQL](https://reader034.fdocuments.in/reader034/viewer/2022042714/54b78da04a7959b12c8b46db/html5/thumbnails/20.jpg)
Questions?!