Building decoupled polyglot applications with Vert.x

@tcrawley

Clojure/Conj 2013

What is Vert.x?

“Vert.x is a lightweight, high performance application platform for the JVM that's designed for modern mobile, web, and enterprise applications.”

What is a human?

“A Human is a bipedal mammal that procreates and turns food into waste."

What problems does Vert.x solve?

The JVM networking packages are byzantine

Efficiency requires concurrency, which is error-prone

Everything can't be asynchronous

Plumbing decoupled components can be painful

How does Vert.x solve these problems?

The JVM networking packages are byzantine

An abstraction over Netty

Efficiency requires concurrency, which is error-prone

Thread confinement

Everything can't be asynchronous

Sync/async hybrid

Plumbing decoupled components can be painful

Built-in event bus

Polyglot

  • Java
  • JRuby
  • Jython
  • JavaScript/CoffeeScript (Rhino, DynJS*)
  • Groovy
  • Scala*
  • PHP*
  • Clojure*

(* in-progress)

Why Async?

Why Async?

standing2.jpg http://www.flickr.com/photos/taestell/10366923794/

Reactor Loop(s)

Defaults to one/core

Verticle tied to one loop

Thread confinement

Distributed Event Bus

  • Simple (String, int, byte[], etc) & structured (JSON) messages
  • Publish/Subscribe
  • Point-to-point
  • Request/Response
  • Clusterable (Hazelcast, browser)
  • Transient

Sample App

cheese-crop.png http://www.flickr.com/photos/nh567/2774100797

This is where the demo happens

See https://github.com/tobias/vertx-clojure-conj-2013/tree/master/rivulet

Sample Application

vertx-rivulet-simple.png

Sample Application

vertx-rivulet.png

Features

  • HTTP(S), TCP, UDP, WebSocket servers
  • Ditto clients, plus DNS
  • Distributed Event Bus
  • Timers
  • Async FS
  • Embeddable

Gains

  • Hides Netty complexity
  • Efficient
  • Distributed Event Bus
  • Thread confinement
  • Polyglot
  • Clusterable

Losses

  • Hides Netty complexity
  • Language ecosystems
  • "Callback Hell"

Don't block…

reactor2.jpg http://www.flickr.com/photos/subindie/955633308

Worker Verticles

Runs on a thread pool, so can block.

Still thread-confined by default.

Ancillary Projects

Resources

http://vertx.io/

https://github.com/vert-x/mod-lang-clojure/

https://github.com/isaiah/lein-vertx/

https://github.com/tobias/vertx-clojure-conj-2013/

Simple, without being simplistic.

Questions?

hands.jpg http://www.flickr.com/photos/coldtaxi/426162862/