Vertx scaling the number of instances per thread

我是研究僧i 提交于 2019-12-03 08:43:37

You misunderstood the docs.

First, there is a single Event Bus (and it is shared between Vert.x instances when Vert.x is started in cluster mode). Its role is to allow a message passing style of communication between your verticles.

See The Event Bus section.

Then there are different types of threads in Vert.x: event loop threads and worker threads. By default, Vert.x creates as many event loop threads as cores on the machine, and a pool of 20 worker threads. Event loop threads are used to handle asynchronous events (file buffer was read, message has been received,... etc). Worker threads are used to execute the blocking parts of your application.

See Multi-Reactor pattern, The Golden Rule and Running Blocking Code

A verticle is the Vert.x unit of deployment. There are three types of verticles but the two you should know are "standard" verticles and "worker" verticles. Standard verticles are assigned a single event loop thread when they are deployed. Whichever type event you handle in your verticle will be handled by this single event loop thread. Worker verticles are guaranteed to be executed by a single worker thread at a time. It may not be the same worker thread each time, but never two worker threads will handle worker verticle events in parallel.

See Verticles

Eventually, to scale a Vert.x application, you deploy multiple instances of your verticles. For standard verticles, each instance will get a different event loop assigned so you will scale across your cores.

See Number of Verticles Instances

Vert.x doesn't automatically adjust the number of Verticles for you. This is something you could build with Vert.x monitoring tools though.

I belive this answers your three questions.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!