+ All Categories
Home > Technology > Services Oriented Architecture with PHP and MySQL

Services Oriented Architecture with PHP and MySQL

Date post: 15-Jan-2015
Category:
Upload: joe-stump
View: 10,013 times
Download: 0 times
Share this document with a friend
Description:
Talk from MySQL Conference 2008 about scaling your data layer by running your requests in parallel and asynchronously over a services layer.
Popular Tags:
21
Services Oriented Architecture with PHP and MySQL Joe Stump, Lead Architect, Digg
Transcript
Page 1: Services Oriented Architecture with PHP and MySQL

Services Oriented Architecture with PHP

and MySQLJoe Stump, Lead Architect, Digg

Page 2: Services Oriented Architecture with PHP and MySQL

Introductions

I’m Joe Stump, Lead Architect for Digg.

Page 3: Services Oriented Architecture with PHP and MySQL

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

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

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

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

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

Grouping Data Requests

Page 9: Services Oriented Architecture with PHP and MySQL

Opening the Sockets

Page 10: Services Oriented Architecture with PHP and MySQL

Opening the Sockets

Page 11: Services Oriented Architecture with PHP and MySQL

Returning Data

Page 12: Services Oriented Architecture with PHP and MySQL

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

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

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

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

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

DO WANT!

Intelligently group data into endpoints Version your endpoints Bundle and group requests

Page 18: Services Oriented Architecture with PHP and MySQL

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

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

Questions?!


Recommended