Vert.x - Tehran JUG meeting Aug-2014 - Saeed Zarinfam
-
Upload
saeed-zarinfam -
Category
Internet
-
view
206 -
download
1
description
Transcript of Vert.x - Tehran JUG meeting Aug-2014 - Saeed Zarinfam
Scalable & Polyglotapplication platform on JVM
Tehran JUG meeting Aug-2014By: Saeed Zarinfam
Intro
Scalable application platform Real-time system (web applications, game and ...) Similar to Node.js but not a clone! Some characteristics like Erlang Started by Tim Fox (RabbitMQ , HornetQ , Red Hat
Middlewares) in 2011 Sponsored by VMWare (SpringSource) and Red Hat! Manged by Eclipse Foundation
Requirements
JDK 7 or later (Oracle distribution or OpenJDK) server.js
$ vertx run server.js -instance 10
server.js in Java
Architecture
Slim and lightweight core Everything else as module Reusable modules
Features
Polyglot Asynchronous programming model (Non blocking
I/O and event-driven) Actor-like concurrency Distributed Event Bus (spans the client and server
side) Embedded as a library Module system
Big picture
Polyglot
Java JavaScript Python Ruby Groovy Clojure Scala
* PHP, Ceylon (under development)
Polyglot
New JDK 7 Feature (better support for Dynamically Typed Languages in the JVM)
e.g. invokedynamic bytecode instruction Support for a New Language as module!
Asynchronous programming model
Full Asynchronous core APIs Event-driven (event handlers) Java NIO libraries (non blocking) Netty 4
Sample TCP Server (Getting Notified of Incoming Connections)
Distributed Event Bus
Communication mechanism between applications components (Clustered)
Spans the client and server side Use same API in the browser Pub-Sub, Request/Response
Actor-like concurrency
No more synchronized, volatile or explicit locking
Write all your code as single threaded Components communicate with each other
over the event bus by exchanging messages. Number of threads to be equal to the number
of available cores on the machine.
Concurrency Model (Thread model)
Hybrid threading model Event Loops = number of threads to the available
cores on the server Multi-reactor pattern (more than one event loop) The Golden Rule - Don't block the event loop! Worker Verticles can block - never executed
concurrent (JDBC , …) Shared map (immutable, distributed)
Verticle
Verticle run insdide a vert.x instance verticle instance is never executed by more
than one thread concurrently (single threaded). verticle instances communicate with each
other over the event bus by exchanging messages.
verticle instances correspond to actors. (more coarse grained than actors)
Vert.x Instances
Vert.x instance runs inside its own JVM instance
The vert.x instances can be configured to cluster with each other
Module System
Public module registry Auto-redeploy of Modules JSON configuration New non-core features done as modules Runnable modules vs. includable modules Even new language support is done via
modules!
Vert.x APIContainer API
TCP/SSL servers and clients
UDP
HTTP/HTTPS servers and clients
WebSockets servers and clients
The distributed event bus
Periodic and one-off timers
Buffers
Flow control
File-system access
Shared map and sets
Accessing configuration
SockJS
Logging (JUL)
DNS Client
How Vert.x scale
Many instance of one verticle Clustering (auto-magic, configurable) Eventbus spans through all machine in cluster and browser Use all available core Hybrid thread model Automatic failover (-ha and "bare" Vert.x instances) HA groups (-hagroup) Quora (network partitions)(-quorum) Automatic load-balancing for TCP and HTTP ( available cores)
Sample web application
Other capabilities
Gradle template Maven archtype Testing Framework provided (Intergration-
Testing and Unit Testing) Logging (JUL logging)
Usage
Nodyn: Nodyn is a Node.js compatible framework, running on the JVM powered by the DynJS Javascript runtime with an embedded Vert.x
Yoke: Yoke is a minimal and flexible Vert.x web application framework
Edge
تشکر
. .zarinfam s@gmail com
:// .http javabyab com