8. The C10k Problem
It's time for web servers to handle ten
thousand clients simultaneously, don't you
think? After all, the web is a big place now.
(Dan Kegel, 2003)
"Real-time will become the default. It won't be
this newfangled tech that only Google and
Facebook and Twitter can afford to build.”
12. Addressing the Problem
• event-driven / asynchronous architecture
– Many long lived connections are a feature of modern
– OS threads are a precious resource
– Blocked OS threads are bad!
• => Service many connections with a small number of
• Reactor Pattern (Douglas C. Schmidt, 1995)
– Event Loop
• different programming model
=> on which abstraction?
(vert.x not blocking on 100
concurrent longrunning requests)
siege -c100 -b -r100 "http://localhost:8081/?longrunning"
22. What is vert.x?
• General purpose application platform on the JVM
• Provides primarily asynchronous APIs
• Simple but not Simplistic
• Popular for “modern” web applications
• Similarities with Node.js & Akka
• New approach to problems traditionally served
by classic application servers
23. The Vert.x Project
• Open-source (on Github, ASL 2.0)
• Age: ~1.5 years
• Sponsor: VMWare
• Based on: Netty, Hazelcast, SockJS
24. Core APIs
• TCP/SSL clients and servers
• HTTP/HTTPS clients and servers
– including WebSockets
• Event bus
• File system
• 100% asynchronous
• Scale by creating more Verticle instances
• Use message passing to communicate
• Fine-tune “pools” of verticles
• For TCP and HTTP servers Vert.x does
27. Event Loops are no Silver Bullet
• Don’t block the event loop!
• Long running calculations
• Blocking APIs (i.e. JDBC)
• Most traditional Java libraries have blocking
• => Hybrid Threading Model
– Worker Verticles can block
– Communication by message passing (Event Bus)
– Leverage ecosystem of Java libraries
28. Concurrency Model
• A verticle instance is always single-threaded
• Very different approach from “Java-Style”
– No more synchronized, volatile or locking
– Avoid many classic race conditions
29. Event Bus Demo
Event Loop Background Workers
30. Distributed Event Bus
• Connect multiple Vert.x JVM instances
• Applications are loosely coupled components
distributed across the network
• Use the same API on the client
• Distributed event space spans client and server
• Ideal for modern “real-time” web applications
31. Distributed Event Bus Demo
Vertx Instance Vertx Instance
Event Loop Event Loop Workers
32. Web Application Demo
Module Module Module
vertx. vertx. vertx.
web-server aut-mgr mongo- Mongo DB
(WebSocket) Event Bus
33. The Future
• Scala & Closure support
• Management, including GUI console
• Developer experience – IDE integration,
• Promises API?
• Direct-style API using continuations?
• Polyglot – use the language(s) you want
• Simple concurrency – wave goodbye to most race
• Leverage existing Java library ecosystem
• Powerful distributed event bus which spans client
• Powerful module system
Vert.x is the platform for a new generation of polyglot web
and enterprise applications.
35. Vert.x vs. Node.JS
JVM vs. V8
huge ecosystem of big ecosystem of
Java libraries node modules
small community vs. big community
First WWW page: August 1991XMLHTTP Request: 1996 (iframe, asynchronous content loading)AJAX as a term: 2005XMLHttpRequest spec by W3C in 2006
Google TalkVs. Real Time Computing- Receiver not known / ensuredpush vs. pullusers receive information when publishedno need for active requiring informationthick clients in the browserdata is exchanged, not finished web page
Herausforderung an unsere Internet-InfrastrukturVielmehrlanglebigeconnecctions connection / peristente connectionsMobile und grundsätzlicheVernetzungInternet of ThingsEs hat sichgezeigt, dass 10’000 connections so eine “magisce” Grenzeist, die eszuknackengibt.
This can involve a combination of operating system constraints and web server software limitations.While there are some specialized web servers that can handle more than ten thousand client connections, most web servers currently handle at most ten thousand clients simultaneously.http://stackoverflow.com/questions/763579/how-many-threads-can-a-java-vm-supportSo under 32-bit Windows, for example, where each process has a user address space of 2GB, giving each thread a 128K stack size, you'd expect an absolute maximum of 16384 threads (=2*1024*1024 / 128). In practice, I find I can start up about 13,000 under XP.
Long running requestsBlocking threads
In a lot of typical server applications threads are mostly waiting on IO.
Reactor Pattern: 1995threads are one of the bottlenecks for scaling
ÜberleitungzuNode.jsTwisted: Apple Calendar, NASA, Twilio …Node: LinkedIn, Walmart, Microsoft, Yammer, Browserling.MS: Azure Mobile Services uses Node in the Backend http://www.windowsazure.com/en-us/develop/mobile/
Event basierteprogrammier-model schlägvolldurch. KeineAbstraktion!Reading & Debugging (vs. sequential code)
Web-Server non blockingsiege -c100 -b -r100 "http://localhost:8081/?longrunning" Running_ From IDE, from commandline
Not really a framework, rather comparable with Tomcat or Jetty than with JSF or EJB
Verticles have their own classloaderMessages are passed by value
DEMO: Blocking WebServer
Most new functionality should be provided as modules
30’Event bus enables easy creation of real-time web applicationsMobile applications, gamesClint side library very small, can be used with any JS libraries
Distributed System very easy, same programming concepts
Building abstractionsAllowing long lived connections on a higher abstraction level than event-based APIs.
Loosely coupled Microservices
Vs. Real Time Computing- Receiver not known / ensured