SlideShare une entreprise Scribd logo
1  sur  48
Télécharger pour lire hors ligne
PHP at 5000 Requests / Sec 
Hootsuite’s Scaling Story 
Bill Monkman 
Lead Technical Engineer - Platform 
@bmonkman
Overview - Selected Current Architecture 
Users lb1 lb2 lb3 ... Nginx Load balancers 
web1 web2 web3 ... Nginx web servers 
PHP-FPM PHP-FPM PHP-FPM PHP-FPM 
Memcached cluster 
mem1 ... 
Mysql cluster 
master slave 
MongoDB cluster 
master slave 
master slave 
shard1 
shard2 
Gearman cluster 
geard1 geard2 
worker1 ... ... 
... 
Services
Technologies - at first 
• Apache 
• PHP 
• MySQL
Then...
Problem 
It’s hard to scale MySQL horizontally
Solution - Caching 
Memcached. 
● Distributed cache, cluster of boxes with lots of RAM, trivial to scale 
● Cache as much as possible, invalidate only when necessary 
● Use cache instead of DB 
● No joins - decouple entities (collection caching) 
● Twemproxy!
“There are only two hard things in 
Computer Science: cache invalidation and 
naming things.” 
• Phil Karlton
Solution - Caching 
MvcModelBaseCaching 
MvcModelBase 
MvcModelMysql 
SocialNetwork
Solution - Caching 
SELECT * FROM member WHERE org_id=888 
set individual cache records 
member_1 {data} 
member_5 {data} 
member_9 {data} 
set collection cache 
member_org_888 [1,5,9] 
Automatic invalidation of collection cache
Solution - Caching 
It’s hard to scale MySQL horizontally 
Now: 
● No need to scale MySQL 
● Able to serve the whole site on 1 MySQL server 
● 500 MySQL SELECTs per second. 50,000 Memcached GETs. 
● 99+% hit rate
Then...
Problem 
Need a way to perform asynchronous, distributed tasks using a 
single-threaded language.
Solution - Gearman 
Gearman. 
● Distribute work to other servers to handle (workers also using 
PHP, same codebase) 
● Precursor to SOA where everything is truly distributed 
● Many other solutions, queueing systems.
Solution - Gearman 
geard1 geard2 
gearworker1 gearworker2 gearworker6
Solution - Gearman 
Need a way to perform asynchronous, distributed tasks using a 
single-threaded language. 
Now: 
● Moved key tasks to Gearman 
● Another cluster, scalable separately from web 
● Discrete tasks, callable sync or async
Then...
Problem 
Need to store data with the potential to grow too big to handle 
effectively with MySQL.
Solution - MongoDB 
MongoDB. 
● Certain data did not need to be highly relational 
● NoSQL DB, many other solutions these days 
● Mongo can be a pain, lots of moving parts 
● Had to make our own sequencer where auto-incremented ids were 
necessary
Solution - MongoDB 
Need to store data with the potential to grow too big to handle 
effectively with MySQL. 
Now: 
● Multiple clusters containing amounts of data that likely would 
have crushed MySQL 
● Billions of rows per collection, many TB of data on disk
Technologies 
• Apache 
• PHP 
• MySQL 
• Memcached 
• Gearman 
• MongoDB
Then...
Problem 
With a codebase and an engineering team increasing in size, how do 
we keep up the pace of development and maintain control of the 
system? 
(SVN, big branches, merge hell)
Solution - Dark Launching 
Dark Launching. 
● Wrap code in block with a specific name 
● That name will appear in a management page 
● Can control whether or not that block is executed by modifying it’s value 
● Boolean , random percentage, session-based, member list, organization 
list, etc.
Solution - Dark Launching 
if (In_Feature::isEnabled(‘TWITTER_ADS’)) { 
// execute new code 
} else { 
// execute old code 
}
Dark Launching - Reasons 
• Control your code 
• Limit risk -> raise confidence -> speed up pace of releases 
• “Branching in Production” 
• Learning happens in Production
Solution - Dark Launching 
With a codebase and an engineering team increasing in size, how do 
we keep up the pace of development and maintain control of the 
system? 
Now: 
● Work fast with more confidence 
● Huge amount of control over production systems 
● Typically 10+ code releases to production per day 
● Push-based distribution with Consul
Then...
Problem 
With a rapidly increasing codebase and amount of users / traffic 
how do we keep visibility into the performance of the code?
Solution - Monitoring 
Statsd / Graphite. 
Logstash / Elasticsearch / Kibana. 
Sensu 
● Statsd for metrics 
● Logstash for log events 
● Sensu for monitoring / alerting
Solution - Monitoring 
Statsd::timing('apiCall.facebookGraph', microtime(true) - $startTime);
Solution - Monitoring 
Logger::event('user liked from in-stream', In_Log::CATEGORY_UX, $logData);
Solution - Monitoring 
• Visibility into the performance and behaviour of your application 
• Iterate upon your code, measure results 
• Pairs well with dark launching 
• Also systems like New Relic
Solution - Monitoring 
With a rapidly increasing codebase and amount of users / traffic 
how do we keep visibility into the performance of the code? 
Now: 
● Able to watch performance / behaviour in real time. 
● Able to view important events both in the aggregate or very 
granular 
● Able to control the system and watch the effect of changes
Optimizations
Optimizations 
• Things expand beyond their initial scope 
• Case in point: Translations
Optimizations - Push work to users 
• Within reason, push work up to users 
• Make your users into a distributed processing grid 
• e.g. Stream rendering
Optimizations - Performance / Risks 
• Performance is more important than clean code, business reqts 
(in the instances where they may be mutually exclusive) 
• Fine line between future proofing and premature optimization 
• Don’t add burdensome processes, but make it easy for your team 
to do things the right way 
• Know your weak spots, protect against abuse
Technologies 
Linux 
Nginx 
ElasticSearch Varnish 
PHP-FPM 
MySQL 
Jenkins 
Scala 
MongoDB 
Consul 
Gearman 
Redis 
Akka 
Python 
Memcached 
HAProxy 
jQuery 
ZeroMQ 
Backbone RabbitMQ 
EC2 
Zend 
Docker 
Cloudfront CDN 
Logstash 
Zookeeper 
Kibana 
Statsd/Graphite 
Packer 
Vagrant 
Nagios 
VirtualBox 
Spark/Shark 
Sensu 
Symfony 
Riak 
Composer 
Websockets 
Comet 
Hadoop 
Ansible 
Git 
Webpack Redshift
Problem 
With a huge and growing monolithic codebase and over 80 
engineers, how to keep scaling in a manageable way?
Solution - SOA 
SOA. 
● Split up the system into independent services which communicate only via APIs 
● Teams can work on their own services with encapsulated business logic and have their own 
deployment schedules. 
● We chose to use Scala/Akka for services, communicating via ZeroMQ 
● SOA transition made easier by the “no joins” philosophy 
● Tons of work
Solution - SOA 
SOM. 
● “Service Oriented Monolith” 
● When splitting up a monolithic codebase, dependencies are what kill you 
● Fulfill dependencies by writing interim services using existing PHP code 
● Maintain the contract and future scala services will be drop-in 
replacements
Solution - SOA 
With a huge and growing monolithic codebase and over 130 
engineers, how to keep scaling in a manageable way? 
Today: 
● Transitioning to Scala SOA 
● PHP will still be used as the Façade, a thin layer built on top of 
the business logic of the services it interacts with.
Conclusion
Thank You! 
Bill Monkman 
@bmonkman 
More Info: 
code.hootsuite.com

Contenu connexe

Tendances

Hadoop Administration pdf
Hadoop Administration pdfHadoop Administration pdf
Hadoop Administration pdf
Edureka!
 
Dell VMware Virtual SAN Ready Nodes
Dell VMware Virtual SAN Ready NodesDell VMware Virtual SAN Ready Nodes
Dell VMware Virtual SAN Ready Nodes
Andrew McDaniel
 

Tendances (20)

[온라인교육시리즈] 글로벌 서비스를 위한 인프라 구축방법(남용현 클라우드 솔루션 아키텍트)
[온라인교육시리즈] 글로벌 서비스를 위한 인프라 구축방법(남용현 클라우드 솔루션 아키텍트)[온라인교육시리즈] 글로벌 서비스를 위한 인프라 구축방법(남용현 클라우드 솔루션 아키텍트)
[온라인교육시리즈] 글로벌 서비스를 위한 인프라 구축방법(남용현 클라우드 솔루션 아키텍트)
 
i-VOC (Voice of the Customer Big Data Analytics Solution) 고객의소리 분석
i-VOC (Voice of the Customer Big Data Analytics Solution) 고객의소리 분석i-VOC (Voice of the Customer Big Data Analytics Solution) 고객의소리 분석
i-VOC (Voice of the Customer Big Data Analytics Solution) 고객의소리 분석
 
Snowflake: The Good, the Bad, and the Ugly
Snowflake: The Good, the Bad, and the UglySnowflake: The Good, the Bad, and the Ugly
Snowflake: The Good, the Bad, and the Ugly
 
Delivering the Composable Enterprise
Delivering the Composable EnterpriseDelivering the Composable Enterprise
Delivering the Composable Enterprise
 
Hadoop Administration pdf
Hadoop Administration pdfHadoop Administration pdf
Hadoop Administration pdf
 
IBM Hybrid integration reference architecture for digital transformation
IBM Hybrid integration reference architecture for digital transformationIBM Hybrid integration reference architecture for digital transformation
IBM Hybrid integration reference architecture for digital transformation
 
Splunk: Druid on Kubernetes with Druid-operator
Splunk: Druid on Kubernetes with Druid-operatorSplunk: Druid on Kubernetes with Druid-operator
Splunk: Druid on Kubernetes with Druid-operator
 
Standards in Machine Learning Models
Standards in Machine Learning ModelsStandards in Machine Learning Models
Standards in Machine Learning Models
 
AWS의 블록체인 서비스 활용 방법 - 박혜영 솔루션즈 아키텍트, AWS / 박선준 솔루션즈 아키텍트, AWS :: AWS Summit S...
AWS의 블록체인 서비스 활용 방법 - 박혜영 솔루션즈 아키텍트, AWS / 박선준 솔루션즈 아키텍트, AWS :: AWS Summit S...AWS의 블록체인 서비스 활용 방법 - 박혜영 솔루션즈 아키텍트, AWS / 박선준 솔루션즈 아키텍트, AWS :: AWS Summit S...
AWS의 블록체인 서비스 활용 방법 - 박혜영 솔루션즈 아키텍트, AWS / 박선준 솔루션즈 아키텍트, AWS :: AWS Summit S...
 
data warehouse vs data lake
data warehouse vs data lakedata warehouse vs data lake
data warehouse vs data lake
 
Block Storage For VMs With Ceph
Block Storage For VMs With CephBlock Storage For VMs With Ceph
Block Storage For VMs With Ceph
 
Taxonomy Governance Through Metrics
Taxonomy Governance Through MetricsTaxonomy Governance Through Metrics
Taxonomy Governance Through Metrics
 
[오픈테크넷서밋2022] 국내 PaaS(Kubernetes) Best Practice 및 DevOps 환경 구축 사례.pdf
[오픈테크넷서밋2022] 국내 PaaS(Kubernetes) Best Practice 및 DevOps 환경 구축 사례.pdf[오픈테크넷서밋2022] 국내 PaaS(Kubernetes) Best Practice 및 DevOps 환경 구축 사례.pdf
[오픈테크넷서밋2022] 국내 PaaS(Kubernetes) Best Practice 및 DevOps 환경 구축 사례.pdf
 
A Technical Introduction to WiredTiger
A Technical Introduction to WiredTigerA Technical Introduction to WiredTiger
A Technical Introduction to WiredTiger
 
So You Think You Need A Digital Strategy
So You Think You Need A Digital StrategySo You Think You Need A Digital Strategy
So You Think You Need A Digital Strategy
 
Replicate Elasticsearch Data with Cross-Cluster Replication (CCR)
Replicate Elasticsearch Data with Cross-Cluster Replication (CCR)Replicate Elasticsearch Data with Cross-Cluster Replication (CCR)
Replicate Elasticsearch Data with Cross-Cluster Replication (CCR)
 
Distributed Databases Deconstructed: CockroachDB, TiDB and YugaByte DB
Distributed Databases Deconstructed: CockroachDB, TiDB and YugaByte DBDistributed Databases Deconstructed: CockroachDB, TiDB and YugaByte DB
Distributed Databases Deconstructed: CockroachDB, TiDB and YugaByte DB
 
Dell VMware Virtual SAN Ready Nodes
Dell VMware Virtual SAN Ready NodesDell VMware Virtual SAN Ready Nodes
Dell VMware Virtual SAN Ready Nodes
 
[2018] 고객 사례를 통해 본 클라우드 전환 전략
[2018] 고객 사례를 통해 본 클라우드 전환 전략[2018] 고객 사례를 통해 본 클라우드 전환 전략
[2018] 고객 사례를 통해 본 클라우드 전환 전략
 
Modern data warehouse presentation
Modern data warehouse presentationModern data warehouse presentation
Modern data warehouse presentation
 

Similaire à PHP At 5000 Requests Per Second: Hootsuite’s Scaling Story

Choosing the right parallel compute architecture
Choosing the right parallel compute architecture Choosing the right parallel compute architecture
Choosing the right parallel compute architecture
corehard_by
 

Similaire à PHP At 5000 Requests Per Second: Hootsuite’s Scaling Story (20)

Choosing the right parallel compute architecture
Choosing the right parallel compute architecture Choosing the right parallel compute architecture
Choosing the right parallel compute architecture
 
About VisualDNA Architecture @ Rubyslava 2014
About VisualDNA Architecture @ Rubyslava 2014About VisualDNA Architecture @ Rubyslava 2014
About VisualDNA Architecture @ Rubyslava 2014
 
Monitoring with Clickhouse
Monitoring with ClickhouseMonitoring with Clickhouse
Monitoring with Clickhouse
 
3450 - Writing and optimising applications for performance in a hybrid messag...
3450 - Writing and optimising applications for performance in a hybrid messag...3450 - Writing and optimising applications for performance in a hybrid messag...
3450 - Writing and optimising applications for performance in a hybrid messag...
 
Dori Exterman, Considerations for choosing the parallel computing strategy th...
Dori Exterman, Considerations for choosing the parallel computing strategy th...Dori Exterman, Considerations for choosing the parallel computing strategy th...
Dori Exterman, Considerations for choosing the parallel computing strategy th...
 
Eko10 Workshop Opensource Database Auditing
Eko10  Workshop Opensource Database AuditingEko10  Workshop Opensource Database Auditing
Eko10 Workshop Opensource Database Auditing
 
Mongo db - How we use Go and MongoDB by Sam Helman
Mongo db - How we use Go and MongoDB by Sam HelmanMongo db - How we use Go and MongoDB by Sam Helman
Mongo db - How we use Go and MongoDB by Sam Helman
 
JSFest 2019: Technology agnostic microservices at SPA frontend
JSFest 2019: Technology agnostic microservices at SPA frontendJSFest 2019: Technology agnostic microservices at SPA frontend
JSFest 2019: Technology agnostic microservices at SPA frontend
 
Big Data Streams Architectures. Why? What? How?
Big Data Streams Architectures. Why? What? How?Big Data Streams Architectures. Why? What? How?
Big Data Streams Architectures. Why? What? How?
 
Scaling symfony apps
Scaling symfony appsScaling symfony apps
Scaling symfony apps
 
From prototype to production - The journey of re-designing SmartUp.io
From prototype to production - The journey of re-designing SmartUp.ioFrom prototype to production - The journey of re-designing SmartUp.io
From prototype to production - The journey of re-designing SmartUp.io
 
Scaling Monitoring At Databricks From Prometheus to M3
Scaling Monitoring At Databricks From Prometheus to M3Scaling Monitoring At Databricks From Prometheus to M3
Scaling Monitoring At Databricks From Prometheus to M3
 
Eko10 workshop - OPEN SOURCE DATABASE MONITORING
Eko10 workshop - OPEN SOURCE DATABASE MONITORINGEko10 workshop - OPEN SOURCE DATABASE MONITORING
Eko10 workshop - OPEN SOURCE DATABASE MONITORING
 
Not my problem - Delegating responsibility to infrastructure
Not my problem - Delegating responsibility to infrastructureNot my problem - Delegating responsibility to infrastructure
Not my problem - Delegating responsibility to infrastructure
 
JS Fest 2019/Autumn. Влад Федосов. Technology agnostic microservices at SPA f...
JS Fest 2019/Autumn. Влад Федосов. Technology agnostic microservices at SPA f...JS Fest 2019/Autumn. Влад Федосов. Technology agnostic microservices at SPA f...
JS Fest 2019/Autumn. Влад Федосов. Technology agnostic microservices at SPA f...
 
Microservices for performance - GOTO Chicago 2016
Microservices for performance - GOTO Chicago 2016Microservices for performance - GOTO Chicago 2016
Microservices for performance - GOTO Chicago 2016
 
There is something about serverless
There is something about serverlessThere is something about serverless
There is something about serverless
 
Realtime traffic analyser
Realtime traffic analyserRealtime traffic analyser
Realtime traffic analyser
 
Serverless for High Performance Computing
Serverless for High Performance ComputingServerless for High Performance Computing
Serverless for High Performance Computing
 
Building a high-performance, scalable ML & NLP platform with Python, Sheer El...
Building a high-performance, scalable ML & NLP platform with Python, Sheer El...Building a high-performance, scalable ML & NLP platform with Python, Sheer El...
Building a high-performance, scalable ML & NLP platform with Python, Sheer El...
 

Dernier

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
vu2urc
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Dernier (20)

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
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
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
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
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...
 
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
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
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...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
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
 
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
 
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
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
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
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
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...
 

PHP At 5000 Requests Per Second: Hootsuite’s Scaling Story

  • 1. PHP at 5000 Requests / Sec Hootsuite’s Scaling Story Bill Monkman Lead Technical Engineer - Platform @bmonkman
  • 2.
  • 3. Overview - Selected Current Architecture Users lb1 lb2 lb3 ... Nginx Load balancers web1 web2 web3 ... Nginx web servers PHP-FPM PHP-FPM PHP-FPM PHP-FPM Memcached cluster mem1 ... Mysql cluster master slave MongoDB cluster master slave master slave shard1 shard2 Gearman cluster geard1 geard2 worker1 ... ... ... Services
  • 4. Technologies - at first • Apache • PHP • MySQL
  • 6. Problem It’s hard to scale MySQL horizontally
  • 7. Solution - Caching Memcached. ● Distributed cache, cluster of boxes with lots of RAM, trivial to scale ● Cache as much as possible, invalidate only when necessary ● Use cache instead of DB ● No joins - decouple entities (collection caching) ● Twemproxy!
  • 8. “There are only two hard things in Computer Science: cache invalidation and naming things.” • Phil Karlton
  • 9. Solution - Caching MvcModelBaseCaching MvcModelBase MvcModelMysql SocialNetwork
  • 10. Solution - Caching SELECT * FROM member WHERE org_id=888 set individual cache records member_1 {data} member_5 {data} member_9 {data} set collection cache member_org_888 [1,5,9] Automatic invalidation of collection cache
  • 11. Solution - Caching It’s hard to scale MySQL horizontally Now: ● No need to scale MySQL ● Able to serve the whole site on 1 MySQL server ● 500 MySQL SELECTs per second. 50,000 Memcached GETs. ● 99+% hit rate
  • 13. Problem Need a way to perform asynchronous, distributed tasks using a single-threaded language.
  • 14. Solution - Gearman Gearman. ● Distribute work to other servers to handle (workers also using PHP, same codebase) ● Precursor to SOA where everything is truly distributed ● Many other solutions, queueing systems.
  • 15. Solution - Gearman geard1 geard2 gearworker1 gearworker2 gearworker6
  • 16. Solution - Gearman Need a way to perform asynchronous, distributed tasks using a single-threaded language. Now: ● Moved key tasks to Gearman ● Another cluster, scalable separately from web ● Discrete tasks, callable sync or async
  • 18. Problem Need to store data with the potential to grow too big to handle effectively with MySQL.
  • 19. Solution - MongoDB MongoDB. ● Certain data did not need to be highly relational ● NoSQL DB, many other solutions these days ● Mongo can be a pain, lots of moving parts ● Had to make our own sequencer where auto-incremented ids were necessary
  • 20. Solution - MongoDB Need to store data with the potential to grow too big to handle effectively with MySQL. Now: ● Multiple clusters containing amounts of data that likely would have crushed MySQL ● Billions of rows per collection, many TB of data on disk
  • 21. Technologies • Apache • PHP • MySQL • Memcached • Gearman • MongoDB
  • 23. Problem With a codebase and an engineering team increasing in size, how do we keep up the pace of development and maintain control of the system? (SVN, big branches, merge hell)
  • 24. Solution - Dark Launching Dark Launching. ● Wrap code in block with a specific name ● That name will appear in a management page ● Can control whether or not that block is executed by modifying it’s value ● Boolean , random percentage, session-based, member list, organization list, etc.
  • 25. Solution - Dark Launching if (In_Feature::isEnabled(‘TWITTER_ADS’)) { // execute new code } else { // execute old code }
  • 26. Dark Launching - Reasons • Control your code • Limit risk -> raise confidence -> speed up pace of releases • “Branching in Production” • Learning happens in Production
  • 27. Solution - Dark Launching With a codebase and an engineering team increasing in size, how do we keep up the pace of development and maintain control of the system? Now: ● Work fast with more confidence ● Huge amount of control over production systems ● Typically 10+ code releases to production per day ● Push-based distribution with Consul
  • 29. Problem With a rapidly increasing codebase and amount of users / traffic how do we keep visibility into the performance of the code?
  • 30. Solution - Monitoring Statsd / Graphite. Logstash / Elasticsearch / Kibana. Sensu ● Statsd for metrics ● Logstash for log events ● Sensu for monitoring / alerting
  • 31. Solution - Monitoring Statsd::timing('apiCall.facebookGraph', microtime(true) - $startTime);
  • 32. Solution - Monitoring Logger::event('user liked from in-stream', In_Log::CATEGORY_UX, $logData);
  • 33. Solution - Monitoring • Visibility into the performance and behaviour of your application • Iterate upon your code, measure results • Pairs well with dark launching • Also systems like New Relic
  • 34. Solution - Monitoring With a rapidly increasing codebase and amount of users / traffic how do we keep visibility into the performance of the code? Now: ● Able to watch performance / behaviour in real time. ● Able to view important events both in the aggregate or very granular ● Able to control the system and watch the effect of changes
  • 36. Optimizations • Things expand beyond their initial scope • Case in point: Translations
  • 37.
  • 38.
  • 39. Optimizations - Push work to users • Within reason, push work up to users • Make your users into a distributed processing grid • e.g. Stream rendering
  • 40. Optimizations - Performance / Risks • Performance is more important than clean code, business reqts (in the instances where they may be mutually exclusive) • Fine line between future proofing and premature optimization • Don’t add burdensome processes, but make it easy for your team to do things the right way • Know your weak spots, protect against abuse
  • 41.
  • 42. Technologies Linux Nginx ElasticSearch Varnish PHP-FPM MySQL Jenkins Scala MongoDB Consul Gearman Redis Akka Python Memcached HAProxy jQuery ZeroMQ Backbone RabbitMQ EC2 Zend Docker Cloudfront CDN Logstash Zookeeper Kibana Statsd/Graphite Packer Vagrant Nagios VirtualBox Spark/Shark Sensu Symfony Riak Composer Websockets Comet Hadoop Ansible Git Webpack Redshift
  • 43. Problem With a huge and growing monolithic codebase and over 80 engineers, how to keep scaling in a manageable way?
  • 44. Solution - SOA SOA. ● Split up the system into independent services which communicate only via APIs ● Teams can work on their own services with encapsulated business logic and have their own deployment schedules. ● We chose to use Scala/Akka for services, communicating via ZeroMQ ● SOA transition made easier by the “no joins” philosophy ● Tons of work
  • 45. Solution - SOA SOM. ● “Service Oriented Monolith” ● When splitting up a monolithic codebase, dependencies are what kill you ● Fulfill dependencies by writing interim services using existing PHP code ● Maintain the contract and future scala services will be drop-in replacements
  • 46. Solution - SOA With a huge and growing monolithic codebase and over 130 engineers, how to keep scaling in a manageable way? Today: ● Transitioning to Scala SOA ● PHP will still be used as the Façade, a thin layer built on top of the business logic of the services it interacts with.
  • 48. Thank You! Bill Monkman @bmonkman More Info: code.hootsuite.com