The next-gen polyglot asynchronous platform

http://vertx.io

https://github.com/eclipse/vert.x

@vertx_project

Norman Maurer

  • Red Hat (JBoss) - EAP Core Team
  • Former contractor for Apple Inc
  • Author - Netty in Action
  • Apache Software Foundation Member
  • Netty  / Vert.x Core-Developer and all things NIO
  • Java and Scala
  • Twitter: @normanmaurer
  • Github: https://github.com/normanmaurer
  • Blog: http://normanmaurer.me
  • 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...

    General

    • Asynchronous by nature
    • General purpose
    • High-Performing
    • Polyglot
    • Flexible

    ... and many more

    Asynchronous, what does this mean ?

    Asynchronous...

    • I/O Operations don't block at all!
    • Get notified once the operation completes
    • Be able to share one Thread across many connections

    © http://www.flickr.com/photos/56223083@N06/5514161603/

    As waiting is b0ring....
    But synchronous / blocking IO  served me well! Again, why should I care ?

    Blocking-IO may not SCALE!


    Usually a Thread takes memory from 256kb to 1mb for the stack space!

    Good luck with serving 1 million concurrent connections

    Ouch....

    © http://www.flickr.com/photos/djjasoncook/8608405432/

    Vert.x to the rescue

    © http://www.flickr.com/photos/brizzlebornandbred/6136653327/

    Philosophy

    • Slim and leightweight core
    • Everything else as module
    • Reusable modules

    Supported Core Protocols

    • TCP / UDP
    • HTTP(s) and compression*
    • WebSockets / Secure-WebSockets
    • SockJS
    • DNS Client*

    * Will be avaible in 2.1.0

    Other Core Features

    • FileSystem API
    • EventBus
    • Timer (Periodic, one-shot)
    • Scaling
    • Run compiled and source files
    • Shared-data
    • Standalone (container like) and Embedded mode
    • Auto-redeploy of Modules
    • Pumps

    Supported languages

    Event-Loop

    Someone needs to do the heavy work!

    © http://www.flickr.com/photos/stavos52093/9645884201/

    • Powered by n EventLoops (Usually one per Core)
    • Each Verticle bound to one EventLoop and so single-Threaded
    • No concurrency issues , YAY
    • WorkerVerticle can be bound to an non EventLoop Thread
    • WorkerVerticles are useful for blocking calls (like legancy frameworks)
    • Run tasks on the EventLoop of the Verticle
    Don't block the Event-Loop

    © http://www.flickr.com/photos/1000photosofnewyorkcity/5550289939/

    This includes:

    • Thread.sleep(...)
    • wait(...)
    • Lock.lock(...)
    • InputStream.read(...)
    • OutputStream.write(...)

    .... And many more

    Internals

    © http://www.flickr.com/photos/kevincollins123/5353373997/

    • Build on top of Netty 4
    • Uses Hazelcast for node discovery
    • Jackson for JSON
    • Java7+

    Build-tool agnostic / IDE support

    • Gradle template
    • Maven archtype
    • Works in any IDE without special configuration

    Modules

    © http://www.flickr.com/photos/s3a/4686060603/

    Modules - all over the place

    • New non-core features done as modules
    • => No changes to core needed
    • Get involved more easily
    • Runnable modules vs. includable modules
    • Even new language support is done via modules!
    • Modules are more less just a zip file (with meta-data)
    • Modules can include / depend on other modules
    • Applications are often bundled in modules

    Modules - Where to put them

    • Upload your modules to maven repository or bintray
    • Register the modules to the Module Registry
    • No license restriction but ASL2 / BSD / MIT is welcome ;)

    Modules - Ready to use

    • JDBC
    • MongoDB
    • Redis
    • Mailer
    • Yoke
    • async-postgres / mysql*

    ... and many more

    Testing

    • Testing Framework provided
    • Intergration-Testing
    • Unit Testing
    EventBus... Receive and Sent messages

    © http://www.flickr.com/photos/94585506@N05/8614340534/

    EventBus

    • Pass messages around, prefered JSON
    • Interact with other modules
    • Pub-Sub, Request/Response
    • May be distributed
    • Can even be used on the Browser vi JavaScript

    EventBus in action - Receive messages

    public class Receiver extends Verticle {
        @Override
        public void start() {
            vertx.eventBus().registerHandler("news-feed", new Handler>() {
                @Override
                public void handle(Message message) {
                    System.out.println("Received news: " + message.body());
                }
            });
        }
    }

    EventBus in action - Send messages

    public class Sender extends Verticle {
        @Override
        public void start() {
            // Publish some news on the feed every second
            vertx.setPeriodic(1000, new Handler() {
                @Override
                public void handle(Long timerID) {
                    vertx.eventBus().publish("news-feed", "more news!");
                }
            });
        }
    }
    Hmmm... so polyglot? Time to see it in action

    © http://www.flickr.com/photos/virar-/4644450720/

    public class ServerExample extends Verticle {
        @Override
        public void start() {
        	vertx.createHttpServer().requestHandler(new Handler() {
                public void handle(HttpServerRequest req) {
                    req.response().headers().set(
                         "Content-Type", "text/html; charset=UTF-8");
                    req.response().end(
                         "<html><body><h1>Hello from Vert.x!</h1></body></html>");
                }
            }).listen(8080);
        }
    }
    var vertx = require('vertx')
    vertx.createHttpServer().requestHandler(function(req) {
        req.response.end(
    		"<html><body><h1>Hello from Vert.x!</h1></body></html>");
    }).listen(8080);
    vertx.createHttpServer().requestHandler { req ->
        req.response.end 
            "<html><body><h1>Hello from Vert.x!</h1></body></html>"
    }.listen(8080, "localhost")

    It's OpenSource - Contribute now!

    © http://www.flickr.com/photos/legofenris/4499417549/

    Get Involved

    Mailinglist
    https://groups.google.com/forum/#!forum/vertx

    IRC
    #vertx irc.freenode.org

    Website
    http://vertx.io

    GitHub
    https://github.com/eclipse/vert.x/

    Other Project info

    • Eclipse Foundation
    • ASL2 License
    • Community Driven
    • Small Team but growing
    • Current stable version 2.0.2.Final

    Things to come...

    • HA/Clustering*
    • Fat-Jars*
    • StartTLS support
    • More Performance tuning ;)
    • Metrics ?
    • Cluster-wide Shared-Data

    ... and many more

    Want to know more about internals...


    You may want to buy my book...



    http://www.manning.com/maurer/


    Enough said... Demo time!

    © http://www.flickr.com/photos/64260010@N07/5853626947/

    Questions please!

    © http://www.flickr.com/photos/photomequickbooth/3531951972/

    Thanks!