SlideShare una empresa de Scribd logo
1 de 15
Descargar para leer sin conexión
Scala @foursquare
     Jorge Ortiz
    @jorgeortiz85
foursquare runs on...

• Scala 2.8.0
• Lift 2.1
• MongoDB
• Twitter open source projects
• ~46k lines of Scala
foursquare server team


• 9 out of 11 had no major prior Scala experience
• Previously: Java, Python, C#
• Most exposed to: ML, Lisp
foursquare loves Scala

• Pimped: Option, List, Map
• Type-safe equality: =?
• BackgroundOperation { ... }
• Throttle(“secret feature!”) { ... }
• Any Java library
2.7.7 => 2.8.0
           (painless migration)

• Compile: 2.7.7 with -deprecation
• Branch
• Compile 2.8.0 without -deprecation
• Compile 2.8.0 with -Xmigration
• Compile 2.8.0 with -Xwarninit
• Switch
foursquare on Lift

• REST API
• Out-of-the-box:
  • Rich Ajax/Comet support
  • ORMs for PostgresQL, MongoDB
  • Random: Email, Facebook, JSON, utils...
Lift Deployment


• nginx
• HAProxy
• API machines - stateless
• WWW machines - stateful
GC issues


• Stateless API machines
  • Tens of millions of requests per day
  • Only a dozen or so servers
  • 12 GB heap => 15sec GCs *ouch*
GC issues
• GC tuning?
  • “There's no way to get around the fact that
    we're allocating faster than we can collect.”

• Allocating ~200 MB/s
  • Opportunity to reduce wasteful allocations
• Better load-balancing strategy
  • Cap # of concurrent connections
GC issues

• Stateful WWW machines
  • Stateful Lift + Scala closures + Java GC
  • Lots of variables getting caught in Session
  •   val venues: RequestCache[List[Venue]] =

         RequestCache(Venue.findAll(...))
MongoDB in Scala

• Some support built-in to Lift
• No expressive query language, so we wrote one:
 Venue where (_.mayor eqs userid)
       modify (_.tags push “I’m mayor!”)
       updateMulti
Twitter open source


• Kestrel
• Ostrich
• GrabbyHands
• (probably more soon...)
We’re hiring
http://foursquare.com/jobs
Questions?

Más contenido relacionado

La actualidad más candente

OSOM Operations in the Cloud
OSOM Operations in the CloudOSOM Operations in the Cloud
OSOM Operations in the Cloud
mstuparu
 

La actualidad más candente (18)

Thrift
ThriftThrift
Thrift
 
Voldemortの紹介
Voldemortの紹介Voldemortの紹介
Voldemortの紹介
 
Spark Streamingによるリアルタイムユーザ属性推定
Spark Streamingによるリアルタイムユーザ属性推定Spark Streamingによるリアルタイムユーザ属性推定
Spark Streamingによるリアルタイムユーザ属性推定
 
Using ELK-Stack (Elasticsearch, Logstash and Kibana) with BizTalk Server
Using ELK-Stack (Elasticsearch, Logstash and Kibana) with BizTalk ServerUsing ELK-Stack (Elasticsearch, Logstash and Kibana) with BizTalk Server
Using ELK-Stack (Elasticsearch, Logstash and Kibana) with BizTalk Server
 
Javantura v4 - Java or Scala – Web development with Playframework 2.5.x - Kre...
Javantura v4 - Java or Scala – Web development with Playframework 2.5.x - Kre...Javantura v4 - Java or Scala – Web development with Playframework 2.5.x - Kre...
Javantura v4 - Java or Scala – Web development with Playframework 2.5.x - Kre...
 
Service stack all the things
Service stack all the thingsService stack all the things
Service stack all the things
 
Sinatra Introduction
Sinatra IntroductionSinatra Introduction
Sinatra Introduction
 
Ansible and CloudStack
Ansible and CloudStackAnsible and CloudStack
Ansible and CloudStack
 
Introduction to RethinkDB and Horizon.js
Introduction to RethinkDB and Horizon.jsIntroduction to RethinkDB and Horizon.js
Introduction to RethinkDB and Horizon.js
 
Webinar - DreamObjects/Ceph Case Study
Webinar - DreamObjects/Ceph Case StudyWebinar - DreamObjects/Ceph Case Study
Webinar - DreamObjects/Ceph Case Study
 
Infrastructure, Hiphop for PHP, deploy @ Hyves
Infrastructure, Hiphop for PHP, deploy @ HyvesInfrastructure, Hiphop for PHP, deploy @ Hyves
Infrastructure, Hiphop for PHP, deploy @ Hyves
 
OSOM Operations in the Cloud
OSOM Operations in the CloudOSOM Operations in the Cloud
OSOM Operations in the Cloud
 
OSOM - Operations in the Cloud
OSOM - Operations in the CloudOSOM - Operations in the Cloud
OSOM - Operations in the Cloud
 
Grafana and MySQL - Benefits and Challenges
Grafana and MySQL - Benefits and ChallengesGrafana and MySQL - Benefits and Challenges
Grafana and MySQL - Benefits and Challenges
 
Auto-Generating Language-Specific Wrappers for Rust Libraries
Auto-Generating Language-Specific Wrappers for Rust LibrariesAuto-Generating Language-Specific Wrappers for Rust Libraries
Auto-Generating Language-Specific Wrappers for Rust Libraries
 
NRD: Nagios Result Distributor
NRD: Nagios Result DistributorNRD: Nagios Result Distributor
NRD: Nagios Result Distributor
 
Art of nodejs
Art of nodejsArt of nodejs
Art of nodejs
 
JS Lab`16. Роман Лютиков: "ClojureScript, что ты такое?"
JS Lab`16. Роман Лютиков: "ClojureScript, что ты такое?"JS Lab`16. Роман Лютиков: "ClojureScript, что ты такое?"
JS Lab`16. Роман Лютиков: "ClojureScript, что ты такое?"
 

Similar a Scala at foursquare

Counters with Riak on Amazon EC2 at Hackover
Counters with Riak on Amazon EC2 at HackoverCounters with Riak on Amazon EC2 at Hackover
Counters with Riak on Amazon EC2 at Hackover
Andrei Savu
 

Similar a Scala at foursquare (20)

Why ruby and rails
Why ruby and railsWhy ruby and rails
Why ruby and rails
 
Counters with Riak on Amazon EC2 at Hackover
Counters with Riak on Amazon EC2 at HackoverCounters with Riak on Amazon EC2 at Hackover
Counters with Riak on Amazon EC2 at Hackover
 
ログ収集プラットフォーム開発におけるElasticsearchの運用
ログ収集プラットフォーム開発におけるElasticsearchの運用ログ収集プラットフォーム開発におけるElasticsearchの運用
ログ収集プラットフォーム開発におけるElasticsearchの運用
 
High Performance Weibo QCon Beijing 2011
High Performance Weibo QCon Beijing 2011High Performance Weibo QCon Beijing 2011
High Performance Weibo QCon Beijing 2011
 
Mongo db admin_20110329
Mongo db admin_20110329Mongo db admin_20110329
Mongo db admin_20110329
 
Redis Day Keynote Salvatore Sanfillipo Redis Labs
Redis Day Keynote Salvatore Sanfillipo Redis LabsRedis Day Keynote Salvatore Sanfillipo Redis Labs
Redis Day Keynote Salvatore Sanfillipo Redis Labs
 
Scaling Social Games
Scaling Social GamesScaling Social Games
Scaling Social Games
 
KeyValue Stores
KeyValue StoresKeyValue Stores
KeyValue Stores
 
The Kubernetes Operator Pattern - ContainerConf Nov 2017
The Kubernetes Operator Pattern - ContainerConf Nov 2017The Kubernetes Operator Pattern - ContainerConf Nov 2017
The Kubernetes Operator Pattern - ContainerConf Nov 2017
 
Kubernetes Manchester - 6th December 2018
Kubernetes Manchester - 6th December 2018Kubernetes Manchester - 6th December 2018
Kubernetes Manchester - 6th December 2018
 
High-Performance Storage Services with HailDB and Java
High-Performance Storage Services with HailDB and JavaHigh-Performance Storage Services with HailDB and Java
High-Performance Storage Services with HailDB and Java
 
H-Hypermap Heatmap Analytics at Scale
H-Hypermap Heatmap Analytics at ScaleH-Hypermap Heatmap Analytics at Scale
H-Hypermap Heatmap Analytics at Scale
 
Adding Riak to your NoSQL Bag of Tricks
Adding Riak to your NoSQL Bag of TricksAdding Riak to your NoSQL Bag of Tricks
Adding Riak to your NoSQL Bag of Tricks
 
Your backend architecture is what matters slideshare
Your backend architecture is what matters slideshareYour backend architecture is what matters slideshare
Your backend architecture is what matters slideshare
 
Rails 3.1
Rails 3.1Rails 3.1
Rails 3.1
 
Using Spring with NoSQL databases (SpringOne China 2012)
Using Spring with NoSQL databases (SpringOne China 2012)Using Spring with NoSQL databases (SpringOne China 2012)
Using Spring with NoSQL databases (SpringOne China 2012)
 
Fighting Against Chaotically Separated Values with Embulk
Fighting Against Chaotically Separated Values with EmbulkFighting Against Chaotically Separated Values with Embulk
Fighting Against Chaotically Separated Values with Embulk
 
Spring Camp 2016 - List query performance improvement using Couchbase
Spring Camp 2016 - List query performance improvement using CouchbaseSpring Camp 2016 - List query performance improvement using Couchbase
Spring Camp 2016 - List query performance improvement using Couchbase
 
[262] netflix 빅데이터 플랫폼
[262] netflix 빅데이터 플랫폼[262] netflix 빅데이터 플랫폼
[262] netflix 빅데이터 플랫폼
 
ActiveMQ 5.9.x new features
ActiveMQ 5.9.x new featuresActiveMQ 5.9.x new features
ActiveMQ 5.9.x new features
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Último (20)

MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
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
 
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
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
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...
 
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
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
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?
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
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
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 

Scala at foursquare

  • 1. Scala @foursquare Jorge Ortiz @jorgeortiz85
  • 2. foursquare runs on... • Scala 2.8.0 • Lift 2.1 • MongoDB • Twitter open source projects • ~46k lines of Scala
  • 3. foursquare server team • 9 out of 11 had no major prior Scala experience • Previously: Java, Python, C# • Most exposed to: ML, Lisp
  • 4. foursquare loves Scala • Pimped: Option, List, Map • Type-safe equality: =? • BackgroundOperation { ... } • Throttle(“secret feature!”) { ... } • Any Java library
  • 5. 2.7.7 => 2.8.0 (painless migration) • Compile: 2.7.7 with -deprecation • Branch • Compile 2.8.0 without -deprecation • Compile 2.8.0 with -Xmigration • Compile 2.8.0 with -Xwarninit • Switch
  • 6.
  • 7. foursquare on Lift • REST API • Out-of-the-box: • Rich Ajax/Comet support • ORMs for PostgresQL, MongoDB • Random: Email, Facebook, JSON, utils...
  • 8. Lift Deployment • nginx • HAProxy • API machines - stateless • WWW machines - stateful
  • 9. GC issues • Stateless API machines • Tens of millions of requests per day • Only a dozen or so servers • 12 GB heap => 15sec GCs *ouch*
  • 10. GC issues • GC tuning? • “There's no way to get around the fact that we're allocating faster than we can collect.” • Allocating ~200 MB/s • Opportunity to reduce wasteful allocations • Better load-balancing strategy • Cap # of concurrent connections
  • 11. GC issues • Stateful WWW machines • Stateful Lift + Scala closures + Java GC • Lots of variables getting caught in Session • val venues: RequestCache[List[Venue]] = RequestCache(Venue.findAll(...))
  • 12. MongoDB in Scala • Some support built-in to Lift • No expressive query language, so we wrote one: Venue where (_.mayor eqs userid) modify (_.tags push “I’m mayor!”) updateMulti
  • 13. Twitter open source • Kestrel • Ostrich • GrabbyHands • (probably more soon...)