SlideShare ist ein Scribd-Unternehmen logo
1 von 15
Downloaden Sie, um offline zu lesen
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?

Weitere ähnliche Inhalte

Was ist angesagt?

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

Was ist angesagt? (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, что ты такое?"
 

Ähnlich wie 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
 

Ähnlich wie 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
 

Kürzlich hochgeladen

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
+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@
 

Kürzlich hochgeladen (20)

Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
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...
 
+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...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
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
 
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
 
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, ...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 

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...)