Vertx scaling the number of instances per thread

前端 未结 1 1849
一整个雨季
一整个雨季 2020-12-30 15:49

Vert.x is a tool-kit for building reactive applications on the JVM.

I want to use vertx for JVM-based auto-scalable RESTful backend API.

So far what I\'ve fo

相关标签:
1条回答
  • 2020-12-30 16:20

    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.

    0 讨论(0)
提交回复
热议问题