Notes from… Scaling webapps with Akka [live blog]

Akka is a Scala based framework for creating robust and scalable distributed applications, and (along with the Lift web framework), has been one of the poster boys for the Scala dev community. Given the [relative] naivety of Scala programming language I was intrigued to see what was actually possible with these frameworks from the trenches. Tonight’s presentations from Maciej Matyjas (@matyjas) at skillsmatter offered to show exactly these possibilities using both Lift and Akka to build a scalable webapp with remote actors, and also using sbt as the build tool (sbt purporting to be the Scala good cop equivalent of Maven).

So how was it for me…. Well, let me [try] and write things up as they spill out at the event, before giving any comment…

  • little actual trialling of akka from attendees
  • trying to conquer the golden hammer of frameworks, (HA, speed, capacity)
  • lives in the same framework space as AMQP, NoSQL, Lift etc..
  • Akka named after a Swedish mountain range
  • Feature set: Actor mode, multi core, graceful failure like OTP, STM (like Clojure)…
  • Overview of Actors including features such as asynch message passing, lightweight processes, immutable messages (hence thread safe) etc.. So an easy way of doing concurrency
  • Other implementations of Actors incl: Erlang, Lift, Scala…
  • shows interesting pattern match which ends with a tail recursive call to keep the receive listener available (in Erlang) and compares this to a pattern match/receive example in Scala (with receive blocking a thread in the Scala example)…which led to…
  • event based Actors (which react) as a par thread based Actors
  • Lift Actors are even lighter weight than Scala actors, and not thread based (so can run on frameworks like GAE)
  • sample of Akka Actors are started via a Factory and started explicitly
  • millions of Akka Actors supported on ‘commodity’ hardware
  • Also remote Actor support (where the host and port are specified when starting the Actor)
  • Graceful failure via the OTP ‘Let it crash’ philosophy
  • A Supervisor manages Actors availability via linking Actors and various strategies around this
  • explicit linking of Actor to Supervisor required, and lifecycle management also needs to be provided
  • STM – transactional without locking, and all in memory (ACI but no D)
  • Map, Vector and Ref data types supported in STM
  • Transactors – Actors meet STM, where the transactions are handled in the Actor execution, (with the STM Actor extending Transactor)
  • Pluggable storage w/ Cassandra, Redis, Mongo in Akka
  • atomic { } blocks provided in Akka, where commits could be triggered in the storage system of record
  • Demo time !!
    • Looks like Maven dir structure.. but.. it’s sbt time !
    • ..used to execute  lift project…
    • looking under the covers of the sbt project file.. colour scheme needs rectifying so Maciej has to perform some multi-finger-Mac finger knots !
    • @d6y saves the day by calling the set-background-color command !
    • all dependencies contained in a class file ?!?!
    • live code.. (and in emacs ! double bravery award, surely) with continuous building via sbt running in the background
    • Simple Actor with a pattern match on some case classes, and then running this up (via sbt) in a console instance <phew/>…
    • extends sample to make a http call using the dispatch package in akka to call a delicious feed, and then parses results using Scala XML DSL
    • … after parsing a feed through to the console, creating a comet Actor for Lift…
    • .. being unfamiliar with Lift, it’s slightly unclear what incantation is being scribed…
    • ….though it definitely makes me want to understand Lift !!
    • then structural typing and binding of  of response to format back to web front end !!
  • <applause /> 😉
  • Q&A

Overall, a very robust and deep presentation from Maciej. Possibly one of the best presentations I’d seen at skillsmatter covering all the major bases (IMHO) in the Scala framework space. Not a presentation for the faint of heart, or complete noobs to Scala, (my own naivety of Lift let me down when stepping through the demos). Also, interesting to see the use of emacs as a editor of choice for demos. When I saw @odersky demo last he (extensively) used the REPL for demonstrating too. Might be a case of doing this to prove there are no smoke and mirrors in use, but does raise some questions about tooling (and developer acceptance of these tools) in the Scala space. Still great demo, and makes me want to pick up and run with both frameworks asap.

Nice one Maciej !

Leave a Reply