• Joined by Mathias Doenitz (aka @sirthias), lead developer of Spray, living in southwest Germany.
  • Loves the challenge and learning opportunities that Scala presents. No more daily grind!
  • Spray is a collection of libraries for working with TCP/IP and HTTP. It's pure Scala + Akka all the way down to the bare sockets. It is fully asynchronous.
  • Why not use servlets?
    • Spray can be used on servlets containers if you choose, but most people want to do away with the overhead of servlets and their XML configuration.
    • Servlets are server-side only, without a corresponding client library.
    • The servlet API's age really shows its age in that it
    • Uses mutability.
    • Lacks modern function Scala niceness like case classes and typeclasses.
    • Lacks streaming + chunked message support.
    • Conceals connection management.
    • Conceals thread pool management.
    • Makes it difficult to monitor/trace your application.
  • Why not use Netty? It's great software, but still not Scala all the way down. It's helpful to have the same stack (Scala, Akka, Typesafe Config, Typesafe Console, etc) all the way through, without adapter layers. The Spray primitives are the Akka, Config, etc. primitives.
  • Spray is nicely layered. If you need to go lower level, you can always go lower level. There are no black boxes until you reach Java NIO.
  • Other Scala web frameworks may be elephants all the way down, but they're not Scala elephants all the way down.
  • Core principles of Spray:
    • Non-blocking and asynchronous code whenever possible.
    • Actor and future-based design. (Also in some cases continuation-passing).
    • Highly optimized for high-load environments (think 100,000 open connections).
    • Lightweight, with very few dependencies.
  • Best practices for actors is still evolving.
    • To avoid throttling problems with actors, Spray uses push-back to the network via TCP flow control.
    • Spray has ocassionally had problems with untyped-ness of actors.
    • Derek Wyatt's forthcoming book will provide valuable information.
  • spray-io sits directly on top of Java NIO.
    • It is a more faithful representation of packet-based networking. It does not attempt to represent communication as a continuous (blocking) flow of bytes. Instead, spray-io is fully message-based.
    • Each actor message contains just they bytes that could be read from the network without blocking.
    • There are even cases where Java NIO is too high level, inefficient, or just not thread safe, and Spray is considering some native enhancements.
  • spray-can is built on spray-io. It provides a low-level HTTP server & client. In other words, spray-can brings spray-io up from TCP/IP to HTTP.
    • The client functionality was originally written just for internal tests.
    • The case class (model-only) spray-http module exists so the client and server components can use the same model.
    • When the client and server share the same model, certain tasks become really easy, like writing proxies.
  • spray-client provides high-level HTTP client functionality. For example, it lets you abstract over the different kinds of connections to a common request-based API.
  • Spray has two main levels of runtime monitoring
    • Logging directly onto Akka's event bus. Since Spray is Akka all the way down, you can do more with simple logging than is possible in black-box frameworks.
    • The Typesafe Console. Spray and Typesafe are working together to make sure Spray gets maximum benefit from the Console.

Part 2 of the interview will be released next week.

Direct download: 027-mathias-doenitz-part-1.mp3
Category:interview -- posted at: 7:28 PM

Syndication

Feedback

License

Archives