• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Writing highly scalable WebSocket using the Atmosphere Framework and Scala
 

Writing highly scalable WebSocket using the Atmosphere Framework and Scala

on

  • 10,832 views

Devoxx 2011 Atmosphere Framework talk on WebSocket, Redis and Scala

Devoxx 2011 Atmosphere Framework talk on WebSocket, Redis and Scala

Statistics

Views

Total Views
10,832
Views on SlideShare
10,826
Embed Views
6

Actions

Likes
9
Downloads
161
Comments
0

4 Embeds 6

http://us-w1.rockmelt.com 2
http://paper.li 2
http://a0.twimg.com 1
http://www.docshut.com 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Writing highly scalable WebSocket using the Atmosphere Framework and Scala Writing highly scalable WebSocket using the Atmosphere Framework and Scala Presentation Transcript

    • Writing highly scalable WebSocket using the Atmosphere Framework
      • Jeanfrancois Arcand
      • Wordnik.com
      • Well Funded Silicon Valley based Startup
        • Creators of Meaning Discovery Engine
      • Wordnik extracts Meaning from Text
        • Lexicographic and Computational Linguistic algorithms
        • Data & Algorithms exposed via Swagger API
      • Self-updating English Language Dictionary
        • Based on in-context usage
        • Proprietary Text Corpus
          • Word Graph relates all words in English
      • Micro Service Architecture Infrastructure
        • Java/Scala/MongoDB
      Who is Wordnik
    • Who I am
      • Twitter: @jfarcand
      Creator of Grizzly Framework
    • Who I am Creator of Grizzly Framework Significant contributor of GlassFish
      • Twitter: @jfarcand
    • Who I am Creator of Grizzly Framework Significant contributor of GlassFish Creator of the AsyncHttpClient
      • Twitter: @jfarcand
    • Who I am Creator of Grizzly Framework Significant contributor of GlassFish Creator of Atmosphere Creator of the AsyncHttpClient
      • Twitter: @jfarcand
    • Who I am Creator of Grizzly Framework Significant contributor of GlassFish Creator of Atmosphere Creator of the AsyncHttpClient
      • Twitter: @jfarcand
      Tomcat, Apache Digester, Sitebricks, Jersey, Aether/Maven, etc.
    • The Atmosphere Framework A Portable Comet Framework
    • The Atmosphere Framework A Portable Comet Framework Support All native Comet API and Servlet 3.0
    • The Atmosphere Framework A Portable Comet Framework Support All native Comet API and Servlet 3.0 Atmosphere Client JQuery Plugin
    • The Atmosphere Framework A Portable Comet Framework Support All native Comet API and Servlet 3.0 Atmosphere Client JQuery Plugin Support available WebSocket Native API
    • The Atmosphere Framework A Portable Comet Framework Support All native Comet API and Servlet 3.0 Atmosphere Client JQuery Plugin Support available WebSocket Native API Plugs in for Redis, Active MQ (JMS), JGroups, XMPP, etc.
    • The Atmosphere Framework A Portable Comet Framework Support All native Comet API and Servlet 3.0 Atmosphere Client JQuery Plugin Support available WebSocket Native API Plugs in for Redis, Active MQ (JMS), JGroups, XMPP, etc. Supported/Integrated by almost all major frameworks and javascript library
    • The Atmosphere Framework WebSocket Spec is evolving fast on both Browser and Server Side
    • The Atmosphere Framework WebSocket Spec is evolving fast on both Browser and Server Side Chrome/Safari/Opera: WebSocket FF: MozWebSocket IE: (crikets … ~10)
    • The Atmosphere Framework WebSocket Spec is evolving fast on both Browser and Server Side Chrome/Safari/Opera: WebSocket FF: MozWebSocket IE: (crikets … ~10) Atmosphere JQuery Plug In hide that and propose a uniform API
    • The Atmosphere Framework WebSocket Spec is evolving fast on both Browser and Server Side Chrome/Safari/Opera: WebSocket FF: MozWebSocket IE: (crikets … ~10) Atmosphere JQuery Plug In hide that and propose a uniform API Decide the best transport, negociate it with the server
    • Java Landscape Jetty 7.0: First to Support WebSocket
    • Java Landscape Jetty 7.0: First to Support WebSocket Jetty 7.2.x -> API Changes, break compatibility
    • Java Landscape Jetty 7.0: First to Support WebSocket Jetty 7.2.x -> API Changes, break compatibility Jetty 7.4.5 and 8.0.2 and up: Spec change
    • Java Landscape Jetty 7.0: First to Support WebSocket Jetty 7.2.x -> API Changes, break compatibility Jetty 7.4.5 and 8.0.2 and up: Spec change GlassFish 3.0 -> some support
    • Java Landscape Jetty 7.0: First to Support WebSocket Jetty 7.2.x -> API Changes, break compatibility Jetty 7.4.5 and 8.0.2 and up: Spec change GlassFish 3.0 -> some support GlassFish 3.1.2 -> API Changes
    • Java Landscape Jetty 7.0: First to Support WebSocket Jetty 7.2.x -> API Changes, break compatibility Jetty 7.4.5 and 8.0.2 and up: Spec change GlassFish 3.0 -> some support GlassFish 3.1.2 -> API Changes Tomcat 7 zzzzzzzzzzzz
    • Java Landscape Jetty 7.0: First to Support WebSocket Jetty 7.2.x -> API Changes, break compatibility Jetty 7.4.5 and 8.0.2 and up: Spec change GlassFish 3.0 -> some support GlassFish 3.1.2 -> API Changes Tomcat 7 zzzzzzzzzzzz WOUAAAAAAAAAAAAAAA Atmosphere to the rescue!!
    • Java Landscape Jetty 7.0: First to Support WebSocket Jetty 7.2.x -> API Changes, break compatibility Jetty 7.4.5 and 8.0.2 and up: Spec change GlassFish 3.0 -> some support GlassFish 3.1.2 -> API Changes Tomcat 7 zzzzzzzzzzzz WOUAAAAAAAAAAAAAAA Atmosphere to the rescue!! Are you crazy enough to rewrite your entire app?
    • Java Landscape Jetty 7.0: First to Support WebSocket Jetty 7.2.x -> API Changes, break compatibility Jetty 7.4.5 and 8.0.2 and up: Spec change GlassFish 3.0 -> some support GlassFish 3.1.2 -> API Changes Tomcat 7 zzzzzzzzzzzz WOUAAAAAAAAAAAAAAA Atmosphere to the rescue!! Are you crazy enough to rewrite your entire app? Really want to use proprietary solution like ?
    • How? Integrate with all framework? Check!
    • How? Integrate with all framework? Check! Want Servlet API? Check!
    • How? Integrate with all framework? Check! Want Servlet API? Check! Want REST like API? Check!
    • How? Integrate with all framework? Check! Want Servlet API? Check! Want REST like API? Check! Fallback to Comet? Check!
    • How? Integrate with all framework? Check! Want Servlet API? Check! Want REST like API? Check! Fallback to Comet? Check! Pure WebSocket? Check!
    • How? Integrate with all framework? Check! Want Servlet API? Check! Want REST like API? Check! Fallback to Comet? Check! Pure WebSocket? Check! WebSocket Sub Protocol? Check
    • How? Integrate with all framework? Check! Want Servlet API? Check! Want REST like API? Check! Fallback to Comet? Check! Pure WebSocket? Check! WebSocket Sub Protocol? Check Atmosphere provides a uniform API and hides the underlying transport details (async I/O included)
    • Concepts Upgrade/Suspend
    • Concepts Upgrade/Suspend Broadcast
    • Concepts Upgrade/Suspend Broadcast Resume
    • Concepts Upgrade/Suspend Broadcast Resume Client choose the best technique (ws or comet) Async I/O (Input/Output Stream)
    • Concepts Upgrade/Suspend Broadcast Resume Cloud enabled (zzzzzz) Async I/O (Input/Output Stream) Survive Proxy Cloud Enabled
    • Zzzzzzzzz Enough Bla Bla Bla, let ’s do Scala!
    • API Atmosphere Handler
    • API Jersey to the rescue! (@ and Prog API) Atmosphere Handler
    • API Atmosphere Handler WebSocket Protocol Jersey to the rescue! (@ and Prog API)
    • API Atmosphere Handler WebSocket Protocol Servlet API Jersey to the rescue! (@ and Prog API)
    • The Demo Jetty 8 Tomcat 6 Redis Chrome Redis CLI Safari WebSocket WebSocket FAIL -> Streaming Broadcaster Broadcaster
      • def onRequest(r: AtmosphereResource[HttpServletRequest, HttpServletResponse]): Unit = {
      • var req: HttpServletRequest = r.getRequest
      • var res: HttpServletResponse = r.getResponse
      • var method: String = req.getMethod
      • if (" GET ".equalsIgnoreCase(method)) {
      • var b: Broadcaster = lookupBroadcaster(req.getPathInfo)
      • r.setBroadcaster(b)
      • if (req.getHeader(HeaderConfig.X_ATMOSPHERE_TRANSPORT).equalsIgnoreCase(HeaderConfig.LONG_POLLING_TRANSPORT)) {
      • req.setAttribute(ApplicationConfig.RESUME_ON_BROADCAST, true)
      • r.suspend(-1, false)
      • } else {
      • r.suspend(-1)
      • }
      • } else if (" POST ".equalsIgnoreCase(method)) {
      • var b: Broadcaster = lookupBroadcaster(req.getPathInfo)
      • var message: String = req.getReader.readLine
      • if (message != null && message.indexOf("message") != -1) {
      • b.broadcast(message.substring("message=".length))
      • }
      • }
      • }
      2005- AtmosphereHandler http://is.gd/hH3AaH
      • override def doGet (req: HttpServletRequest, res: HttpServletResponse): Unit = {
      • var m: org.atmosphere.cpr.Meteor = org.atmosphere.cpr.Meteor.build(req)
      • m.addListener(new Console)
      • res.setContentType("text/html;charset=ISO-8859-1")
      • var b: Broadcaster = lookupBroadcaster(req.getPathInfo)
      • m.setBroadcaster(b)
      • if (req.getHeader(HeaderConfig.X_ATMOSPHERE_TRANSPORT).equalsIgnoreCase(HeaderConfig.LONG_POLLING_TRANSPORT)) {
      • req.setAttribute(ApplicationConfig.RESUME_ON_BROADCAST, true)
      • m.suspend(-1, false)
      • }
      • else {
      • m.suspend(-1)
      • }
      • }
      • override def doPost (req: HttpServletRequest, res: HttpServletResponse): Unit = {
      • var b: Broadcaster = lookupBroadcaster(req.getPathInfo)
      • var message: String = req.getReader.readLine
      • if (message != null && message.indexOf("message") != -1) {
      • b.broadcast(message.substring("message=".length))
      • }
      • }
      1999 – Servlet API http://is.gd/GcnG0A
      • @Path("/resource/{topic}")
      • @Produces(Array("text/html;charset=ISO-8859-1"))
      • class Resource {
      • @ PathParam ("topic") private var topic: Broadcaster = null
      • @ GET
      • def subscribe: SuspendResponse[String] = {
      • return new SuspendResponse.SuspendResponseBuilder[String]()
      • .broadcaster(topic)
      • .outputComments(true)
      • .addListener(new Console)
      • .build
      • }
      • @ POST
      • @Broadcast
      • def publish(@FormParam("message") message: String): Broadcastable = {
      • return new Broadcastable(message, "", topic)
      • }
      2007 – REST API http://is.gd/Df9Uvm
    • 2011 – WebSocket API http://is.gd/SEa4AK
    • 2011 – Client API http://is.gd/9jumKt
    • SwaggerSocket Protocol HTTP/REST Over WebSocket
    • SwaggerSocket Protocol HTTP/REST Over WebSocket JSON based protocol
    • SwaggerSocket Protocol HTTP/REST Over WebSocket JSON based protocol Support Pipelined Requests
    • SwaggerSocket Protocol HTTP/REST Over WebSocket JSON based protocol Support Pipelined Requests Fully ASYNCHRONOUS
    • SwaggerSocket Protocol HTTP/REST Over WebSocket JSON based protocol Support Pipelined Request Fully ASYNCHRONOUS
      • Work with ANY existing technology, without any changes
      • No need to use Atmosphere API directly
      • Protocol easily extensible
    • SwaggerSocket Protocol WebServer Atmosphere WebSocket WebSocket Protocol Jersey REST Resource
      • Comparing HTTP/keep-alive vs WebSocket
      Benchmark
      • Writing WebSocket doesn ’t have to be complex
      • Use technology/API that you know, don’t re-invent the wheel again!
      • Twitter: @atmo_framework
      • Github: http://github.com/Atmosphere/atmosphere
      • Wordnik: http://wordnik.com
      Conclusion