狠狠撸

狠狠撸Share a Scribd company logo
Scalable & Polyglot
application platform on JVM
Tehran JUG meeting Aug-2014
By: 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
Vert.x - Tehran JUG meeting Aug-2014 - Saeed Zarinfam
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
Vert.x - Tehran JUG meeting Aug-2014 - Saeed Zarinfam
Vert.x - Tehran JUG meeting Aug-2014 - Saeed Zarinfam
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 API
Container 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

More Related Content

Vert.x - Tehran JUG meeting Aug-2014 - Saeed Zarinfam

  • 1. Scalable & Polyglot application platform on JVM Tehran JUG meeting Aug-2014 By: Saeed Zarinfam
  • 2. 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
  • 3. Requirements ? JDK 7 or later (Oracle distribution or OpenJDK) ? server.js $ vertx run server.js -instance 10
  • 5. Architecture ? Slim and lightweight core ? Everything else as module ? Reusable modules
  • 6. 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
  • 9. 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!
  • 10. Asynchronous programming model ? Full Asynchronous core APIs ? Event-driven (event handlers) ? Java NIO libraries (non blocking) ? Netty 4
  • 11. Sample TCP Server (Getting Notified of Incoming Connections)
  • 12. 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
  • 14. 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.
  • 15. 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)
  • 16. 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)
  • 17. Vert.x Instances ? Vert.x instance runs inside its own JVM instance ? The vert.x instances can be configured to cluster with each other
  • 20. 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!
  • 21. Vert.x API Container 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
  • 22. 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)
  • 24. Other capabilities ? Gradle template ? Maven archtype ? Testing Framework provided (Intergration- Testing and Unit Testing) ? Logging (JUL logging)
  • 25. 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
  • 26. ?????? . .zarinfam s@gmail com :// .http javabyab com