SlideShare a Scribd company logo
WebObjects + Scala
Building Concurrent WebObjects applications with Scala
                     Ravi Mendis
Why Concurrent Programming?
2005
The year of Dual Core
Building Concurrent WebObjects applications with Scala
Building Concurrent WebObjects applications with Scala
2010
Today
Entry-Level


                    Cores   Threads

AMD Opteron            4       4


IBM Power7             4      16


 Intel Xeon            4       8
High-End


                   Cores   Threads

AMD Opteron          12      12


IBM Power7           8       32


 Intel Xeon          6       12
2011
Tomorrow
Roadmap


                  Cores   Threads

AMD Opteron         16      16


IBM Power7          ?       ??


 Intel Xeon         8       16
“By 2015 we will likely have over 100 cores on a many-
   core processing chip in our notebook computers.”
                  - Computerworld
Welcome to the world of Multi-cores!
Q: How do we take advantage of
    multi-core processors?
A: Concurrent Programming
#1 Threads & Locks
“Concurrency is hard. It involves a lot of problems that are very difficult
         to think about and reason about and understand”
                  - Tim Bray co-inventor of XML
#1 Threads & Locks
•   HARD to program

•   HARD to scale

•   Contentious
java.lang.IllegalArgumentException: Cannot determine primary key for entity ASCCarveout from row: {charge = 3027.00;
claimID = 321839138; }
! at com.webobjects.eoaccess.EODatabaseChannel._fetchObject(EODatabaseChannel.java:348)
! at com.webobjects.eoaccess.EODatabaseContext._objectsWithFetchSpecificationEditingContext
(EODatabaseContext.java:3071)
! at com.webobjects.eoaccess.EODatabaseContext.objectsWithFetchSpecification(EODatabaseContext.java:3195)
! at com.webobjects.eocontrol.EOObjectStoreCoordinator.objectsWithFetchSpecification(EOObjectStoreCoordinator.java:
488)
! at com.webobjects.eocontrol.EOEditingContext.objectsWithFetchSpecification(EOEditingContext.java:4069)

                                         ...Deadlock!
! at er.extensions.eof.ERXEC.objectsWithFetchSpecification(ERXEC.java:1211)
! at com.webobjects.eoaccess.EODatabaseContext.objectsForSourceGlobalID(EODatabaseContext.java:4084)
! at com.webobjects.eocontrol.EOObjectStoreCoordinator.objectsForSourceGlobalID(EOObjectStoreCoordinator.java:
634)
! at com.webobjects.eocontrol.EOEditingContext.objectsForSourceGlobalID(EOEditingContext.java:3923)
! at er.extensions.eof.ERXEC.objectsForSourceGlobalID(ERXEC.java:1169)
! at com.webobjects.eoaccess.EODatabaseContext._fireArrayFault(EODatabaseContext.java:4245)
! at com.webobjects.eoaccess.EOAccessArrayFaultHandler.completeInitializationOfObject
(EOAccessArrayFaultHandler.java:77)
! at com.webobjects.eocontrol._EOCheapCopyMutableArray.willRead(_EOCheapCopyMutableArray.java:37)
! at com.webobjects.eocontrol._EOCheapCopyMutableArray.count(_EOCheapCopyMutableArray.java:86)
! at com.mpv.evaluation.ClaimEvaluator.validateClaim(ClaimEvaluator.java:398)
! ...
BBC2, Top Gear - Series 15, Episode 1 - June 27 ’10
#2 Actor Model
  (A Share NOTHING Model)
Slowmation
Demo
html5 <video>
<video poster="/slowmation/screenshots/0/2/4/425.jpg">
!   <source type="video/ogg" src="/slowmation/videos/6/d/8/423.ogg" />
!   <source type="video/mp4" src="/slowmation/videos/d/6/4/424.mp4" />
</video>
HTML5 Video Conversion



                                Thumbnail (.jpg)




                             Screenshot (.jpg)




                      Video (.mp4)



       Video (.ogg)
Slowmation Actor
                           (Video Processor)



•   actor ! THUMBNAIL

•   actor ! GRAB

•   actor ! CONVERT2H264

•   actor ! CONVERT2OGG
!
Actor Messaging
•   Asynchronous

    •   Non-blocking


•   Immutable Messages

    •   NO shared data
Scala
Scala
•   Immutable/Mutable datatypes

•   Anonymous Functions (~Closures)

•   No Static variables and methods

•   Extensible
Scala
val greeting: String = “Hello World”;
Scala
val greeting = “Hello World”;
Scala
val greeting = “Hello World”
Scala
val greeting = “Hello World”   // immutable
var response = new String()    // mutable

response = “Hey!”
Java - Static Vars
public class _Talent extends EOGenericRecord {
	    public static final String ENTITY_NAME	 = "Talent";
}
Scala - Companion Object
object Talent extends EOGenericRecord {
	    val ENTITY_NAME = "Talent"
}
Thread-Safe
Scala - Pattern Matching
case a => {
   ...
}
Scala - Pattern Matching
try {
     var epi: EditPageInterface = D2W.factory.editPageForNewObjectWithEntityNamed(entityName, session)
} catch {
     case e: IllegalArgumentException => {
            var epf: ErrorPageInterface = D2W.factory.errorPage(session)
            epf.setMessage(e.toString)
     }
}
Scala - Case Classes
case class PING
case class PONG
Scala - Case Classes
actor ! PING
actor ! PONG
Scala - Case Classes
case PING => {
   ...
}

case PONG => {
   ...
}
Scala - Anonymous Functions
x => x^2
Scala - Anonymous Functions
x, y => x + y
Scala - Anonymous Functions
x, y => {x + y}
Scala - Anonymous Functions
case (PING => {...})

case (PONG => {...})
λ - Expressions
Scala Actors - Example
case class THUMBNAIL(filepath: String)	    // Actor msg case class

val processor = actor {
	    loop {
	    	    react() {
	    	         case THUMBNAIL(filepath: String) => {
	    	    	         ...
	    	          }
          }
	    }
}

// asynchronous
processor ! THUMBNAIL(“/Library/WebServer/Documents/slowmation/screenshots/0/2/4/422.jpg”)
#2 Actor Model
•   EASY to program

•   Scalable

•   NO Deadlocks!
Q: Why can Scala be used with WebObjects?
A: Scala compiles to Java Byte-code
WebObjects + Concurrency
Why?
Performance
•   Exploit multi-core processors
Ajax
•   More responsive UI
How?
Properties
WOAllowsConcurrentRequestHandling=true
Java - Synchronize Static Variables
private static String greeting = “Hello”;     // private

public void setGreeting(String aGreeting) {
    synchronized(greeting) {                  // synchronized block
        greeting = aGreeting;
    }
}
Free!
WO - What is Shared?
•   Application

•   Session (concurrent WO)
Use ERXEC
•   Project Wonder

•   Automatic lock/unlock handling
Properties
er.extensions.ERXEC.safeLocking=true
Debugging
Demo
Properties
-Dcom.sun.management.jmxremote=true
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false

// Specific port
-Dcom.sun.management.jmxremote.port=20102
Bottlenecks
EOF - Bottleneck
•   Shared Object-cache

    •   Antithesis to Share Nothing
        model

    •   Uses single database connection

    •   Single-Threaded
#3 STM
(Software Transactional Memory)
EOF + Scala
•   DOESN’T work in Scala Actors!

•
Solutions
•   Use Raw SQL

•   Alternative database access

    •   Squeryl

    •   ...
Squeryl
Demo
Squeryl
•   POSOs

•   Actor Compatible

•   Concurrent
“Scala as a concurrent programming language is
         powerful, safe and easy-to-use”
Benchmarks
The Test
•   ERWOAdaptor (Mina)

    •   WO Worker as Actor

•   Apache bench

    •   c = 5...65

    •   n = 500
Results
Time per req. (mean)

200 ms



150 ms



100 ms



 50 ms



  0 ms
         5   10   15   20   25   30   35   40   45   50   55   60   65

   WOAdaptor                ERWOScalaAdaptor                   ERWOAdaptor
Requests per second

800



600



400



200



  0
      5   10   15   20    25   30   35   40   45   50   55   60   65

WOAdaptor                ERWOScalaAdaptor                    ERWOAdaptor
“Scala as a concurrent programming language is powerful,
                  safe and easy-to-use”
The R&D Imperative
       In life long love
            The key
             Is R&D

   The ladder of invention
  Has eternal slide extension
          Rung by rung
 You’ll climb to heaven above.

     Constant innovation
    Guarantees a satiation
  Of that ever changing want
     And deepening need

    Nourishment and care
      To think anew…
     Makes passions flair
   And lets a culture breed
    Between the sheets…

      - by Emma Ahmad
Q&A
References

•   What will YOU do with 100 cores?
    http://www.computerworld.com.au/article/354261/

•   WebObjects with Scala
    http://wiki.objectstyle.org/confluence/display/WO/WebObjects+with+Scala

•   Case Study: Slowmation
    http://slowmation.uow.edu.au

•   Source: ERWOScalaAdaptor
    http://services.wocommunity.org/wowodc/ERWOScalaAdaptor

More Related Content

PDF
JavaOne 2017 - JNoSQL: The Definitive Solution for Java and NoSQL Database [C...
Leonardo De Moura Rocha Lima
 
PDF
JavaOne 2017 - Collections.compare:JDK, Eclipse, Guava, Apache... [CON1754]
Leonardo De Moura Rocha Lima
 
PDF
Solid And Sustainable Development in Scala
Kazuhiro Sera
 
PPTX
Collections.compare(JDK, Eclipse, Guava, Apache...);
Leonardo De Moura Rocha Lima
 
PDF
Scala, Akka, and Play: An Introduction on Heroku
Havoc Pennington
 
PDF
Reactive Web-Applications @ LambdaDays
Manuel Bernhardt
 
PPTX
Akka Actor presentation
Gene Chang
 
PDF
Node.js vs Play Framework (with Japanese subtitles)
Yevgeniy Brikman
 
JavaOne 2017 - JNoSQL: The Definitive Solution for Java and NoSQL Database [C...
Leonardo De Moura Rocha Lima
 
JavaOne 2017 - Collections.compare:JDK, Eclipse, Guava, Apache... [CON1754]
Leonardo De Moura Rocha Lima
 
Solid And Sustainable Development in Scala
Kazuhiro Sera
 
Collections.compare(JDK, Eclipse, Guava, Apache...);
Leonardo De Moura Rocha Lima
 
Scala, Akka, and Play: An Introduction on Heroku
Havoc Pennington
 
Reactive Web-Applications @ LambdaDays
Manuel Bernhardt
 
Akka Actor presentation
Gene Chang
 
Node.js vs Play Framework (with Japanese subtitles)
Yevgeniy Brikman
 

What's hot (20)

PDF
Xitrum Web Framework Live Coding Demos / Xitrum Web Framework ライブコーディング
scalaconfjp
 
PDF
Scala in a wild enterprise
Rafael Bagmanov
 
PPTX
Building a Unified Data Pipline in Spark / Apache Sparkを用いたBig Dataパイプラインの統一
scalaconfjp
 
PDF
Akka and the Zen of Reactive System Design
Lightbend
 
PDF
Actor Model Akka Framework
Harinath Krishnamoorthy
 
PPTX
JavaFX 2 and Scala - Like Milk and Cookies (33rd Degrees)
Stephen Chin
 
PPTX
Concurrency in Scala - the Akka way
Yardena Meymann
 
PDF
Scarab: SAT-based Constraint Programming System in Scala / Scala上で実現された制約プログラ...
scalaconfjp
 
PDF
SQLAlchemy Primer
泰 増田
 
PDF
Connect.Tech- Enhancing Your Workflow With Xcode Source Editor Extensions
stable|kernel
 
PDF
Objective-C Is Not Java
Chris Adamson
 
KEY
The Why and How of Scala at Twitter
Alex Payne
 
PDF
The Cloud-natives are RESTless @ JavaOne
Konrad Malawski
 
PPTX
Introduction to Akka - Atlanta Java Users Group
Roy Russo
 
PDF
Short intro to scala and the play framework
Felipe
 
PDF
Introduction to Spark SQL and Catalyst / Spark SQLおよびCalalystの紹介
scalaconfjp
 
PPTX
Mastering the Sling Rewriter
Justin Edelson
 
ZIP
Above the clouds: introducing Akka
nartamonov
 
PPTX
Demystifying Oak Search
Justin Edelson
 
PDF
Play vs Rails
Daniel Cukier
 
Xitrum Web Framework Live Coding Demos / Xitrum Web Framework ライブコーディング
scalaconfjp
 
Scala in a wild enterprise
Rafael Bagmanov
 
Building a Unified Data Pipline in Spark / Apache Sparkを用いたBig Dataパイプラインの統一
scalaconfjp
 
Akka and the Zen of Reactive System Design
Lightbend
 
Actor Model Akka Framework
Harinath Krishnamoorthy
 
JavaFX 2 and Scala - Like Milk and Cookies (33rd Degrees)
Stephen Chin
 
Concurrency in Scala - the Akka way
Yardena Meymann
 
Scarab: SAT-based Constraint Programming System in Scala / Scala上で実現された制約プログラ...
scalaconfjp
 
SQLAlchemy Primer
泰 増田
 
Connect.Tech- Enhancing Your Workflow With Xcode Source Editor Extensions
stable|kernel
 
Objective-C Is Not Java
Chris Adamson
 
The Why and How of Scala at Twitter
Alex Payne
 
The Cloud-natives are RESTless @ JavaOne
Konrad Malawski
 
Introduction to Akka - Atlanta Java Users Group
Roy Russo
 
Short intro to scala and the play framework
Felipe
 
Introduction to Spark SQL and Catalyst / Spark SQLおよびCalalystの紹介
scalaconfjp
 
Mastering the Sling Rewriter
Justin Edelson
 
Above the clouds: introducing Akka
nartamonov
 
Demystifying Oak Search
Justin Edelson
 
Play vs Rails
Daniel Cukier
 
Ad

Viewers also liked (6)

PPTX
Programmation 2011-2012
lespacerelatif
 
PDF
Mathematical formulation of inverse scattering and korteweg de vries equation
Alexander Decker
 
PPTX
Google
Pao Bonilla
 
DOCX
Emisión de co²
jromanbmo
 
PPTX
CIC CAO Inst. Nov09
Helen Barrett
 
Programmation 2011-2012
lespacerelatif
 
Mathematical formulation of inverse scattering and korteweg de vries equation
Alexander Decker
 
Google
Pao Bonilla
 
Emisión de co²
jromanbmo
 
CIC CAO Inst. Nov09
Helen Barrett
 
Ad

Similar to Building Concurrent WebObjects applications with Scala (20)

PDF
Scala and jvm_languages_praveen_technologist
pmanvi
 
PDF
Typesafe stack - Scala, Akka and Play
Luka Zakrajšek
 
PDF
Server Side JavaScript on the Java Platform - David Delabassee
JAXLondon2014
 
PDF
Scala Frustrations
takezoe
 
PDF
Avatar 2.0
David Delabassee
 
PDF
4 JVM Web Frameworks
Joe Kutner
 
PPTX
Multi-threading in the modern era: Vertx Akka and Quasar
Gal Marder
 
PDF
Solid and Sustainable Development in Scala
scalaconfjp
 
KEY
Scala Introduction
Adrian Spender
 
PPT
Devoxx
Martin Odersky
 
PPTX
Concurrency in Eclipse: Best Practices and Gotchas
amccullo
 
PDF
Rafael Bagmanov «Scala in a wild enterprise»
e-Legion
 
PDF
Advanced akka features
Grzegorz Duda
 
PDF
Persistent Session Storage
WO Community
 
PDF
Play framework
Andrew Skiba
 
PPT
Scala
Andreas Enbohm
 
PDF
Eclipse e4
Chris Aniszczyk
 
PDF
Java 8 selected updates
Vinay H G
 
PDF
Full Stack Scala
Ramnivas Laddad
 
PDF
Martin Odersky: What's next for Scala
Marakana Inc.
 
Scala and jvm_languages_praveen_technologist
pmanvi
 
Typesafe stack - Scala, Akka and Play
Luka Zakrajšek
 
Server Side JavaScript on the Java Platform - David Delabassee
JAXLondon2014
 
Scala Frustrations
takezoe
 
Avatar 2.0
David Delabassee
 
4 JVM Web Frameworks
Joe Kutner
 
Multi-threading in the modern era: Vertx Akka and Quasar
Gal Marder
 
Solid and Sustainable Development in Scala
scalaconfjp
 
Scala Introduction
Adrian Spender
 
Concurrency in Eclipse: Best Practices and Gotchas
amccullo
 
Rafael Bagmanov «Scala in a wild enterprise»
e-Legion
 
Advanced akka features
Grzegorz Duda
 
Persistent Session Storage
WO Community
 
Play framework
Andrew Skiba
 
Eclipse e4
Chris Aniszczyk
 
Java 8 selected updates
Vinay H G
 
Full Stack Scala
Ramnivas Laddad
 
Martin Odersky: What's next for Scala
Marakana Inc.
 

More from WO Community (20)

PDF
KAAccessControl
WO Community
 
PDF
In memory OLAP engine
WO Community
 
PDF
Using Nagios to monitor your WO systems
WO Community
 
PDF
Build and deployment
WO Community
 
PDF
High availability
WO Community
 
PDF
Reenabling SOAP using ERJaxWS
WO Community
 
PDF
Chaining the Beast - Testing Wonder Applications in the Real World
WO Community
 
PDF
D2W Stateful Controllers
WO Community
 
PDF
Deploying WO on Windows
WO Community
 
PDF
Unit Testing with WOUnit
WO Community
 
PDF
Life outside WO
WO Community
 
PDF
Apache Cayenne for WO Devs
WO Community
 
PDF
Advanced Apache Cayenne
WO Community
 
PDF
Migrating existing Projects to Wonder
WO Community
 
PDF
iOS for ERREST - alternative version
WO Community
 
PDF
iOS for ERREST
WO Community
 
PDF
"Framework Principal" pattern
WO Community
 
PDF
Filtering data with D2W
WO Community
 
PDF
WOver
WO Community
 
PDF
Localizing your apps for multibyte languages
WO Community
 
KAAccessControl
WO Community
 
In memory OLAP engine
WO Community
 
Using Nagios to monitor your WO systems
WO Community
 
Build and deployment
WO Community
 
High availability
WO Community
 
Reenabling SOAP using ERJaxWS
WO Community
 
Chaining the Beast - Testing Wonder Applications in the Real World
WO Community
 
D2W Stateful Controllers
WO Community
 
Deploying WO on Windows
WO Community
 
Unit Testing with WOUnit
WO Community
 
Life outside WO
WO Community
 
Apache Cayenne for WO Devs
WO Community
 
Advanced Apache Cayenne
WO Community
 
Migrating existing Projects to Wonder
WO Community
 
iOS for ERREST - alternative version
WO Community
 
iOS for ERREST
WO Community
 
"Framework Principal" pattern
WO Community
 
Filtering data with D2W
WO Community
 
Localizing your apps for multibyte languages
WO Community
 

Recently uploaded (20)

PDF
How-Cloud-Computing-Impacts-Businesses-in-2025-and-Beyond.pdf
Artjoker Software Development Company
 
PPTX
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
PDF
Why Your AI & Cybersecurity Hiring Still Misses the Mark in 2025
Virtual Employee Pvt. Ltd.
 
PDF
A Day in the Life of Location Data - Turning Where into How.pdf
Precisely
 
PDF
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
PDF
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
 
PDF
Software Development Company | KodekX
KodekX
 
PDF
Advances in Ultra High Voltage (UHV) Transmission and Distribution Systems.pdf
Nabajyoti Banik
 
PDF
DevOps & Developer Experience Summer BBQ
AUGNYC
 
PDF
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
PDF
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
PDF
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
PPTX
How to Build a Scalable Micro-Investing Platform in 2025 - A Founder’s Guide ...
Third Rock Techkno
 
PDF
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
PDF
REPORT: Heating appliances market in Poland 2024
SPIUG
 
PDF
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
PDF
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 
PDF
Cloud-Migration-Best-Practices-A-Practical-Guide-to-AWS-Azure-and-Google-Clou...
Artjoker Software Development Company
 
PDF
Building High-Performance Oracle Teams: Strategic Staffing for Database Manag...
SMACT Works
 
PDF
Chapter 2 Digital Image Fundamentals.pdf
Getnet Tigabie Askale -(GM)
 
How-Cloud-Computing-Impacts-Businesses-in-2025-and-Beyond.pdf
Artjoker Software Development Company
 
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
Why Your AI & Cybersecurity Hiring Still Misses the Mark in 2025
Virtual Employee Pvt. Ltd.
 
A Day in the Life of Location Data - Turning Where into How.pdf
Precisely
 
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
 
Software Development Company | KodekX
KodekX
 
Advances in Ultra High Voltage (UHV) Transmission and Distribution Systems.pdf
Nabajyoti Banik
 
DevOps & Developer Experience Summer BBQ
AUGNYC
 
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
How to Build a Scalable Micro-Investing Platform in 2025 - A Founder’s Guide ...
Third Rock Techkno
 
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
REPORT: Heating appliances market in Poland 2024
SPIUG
 
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 
Cloud-Migration-Best-Practices-A-Practical-Guide-to-AWS-Azure-and-Google-Clou...
Artjoker Software Development Company
 
Building High-Performance Oracle Teams: Strategic Staffing for Database Manag...
SMACT Works
 
Chapter 2 Digital Image Fundamentals.pdf
Getnet Tigabie Askale -(GM)
 

Building Concurrent WebObjects applications with Scala