0

When we create an HTTP server inside a verticle, then does it mean that the event loop thread creates this server? If not what is the work of the event loop and who creates this HTTP server? When we create multiple instances of a vertice, then what happens to the event loop?

  • Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. – Community Nov 02 '21 at 14:18

2 Answers2

1

Q1. When we create an HTTP server inside a verticle, then does it mean that the event loop thread creates this server?

A: No

Q2. If not what is the work of the event loop ?

In a standard reactor implementation there is a single event loop thread which runs around in a loop delivering all events to all handlers as they arrive. Vert.x works differently here. Instead of a single event loop, each Vertx instance maintains several event loops. By default we choose the number based on the number of available cores on the machine, but this can be overridden.

The event loop thread is used to dispatch events to handlers.

enter image description here

Q3. Who creates this HTTP server?

A: Creating an HTTP server is done from the Vertx instance. The method used is createHttpServer()

HttpServer server = vertx.createHttpServer();

Q4. When we create multiple instances of a verticle, then what happens to the event loop?

The function of the event loop threads remain the same. With many vertical instances, there are just more event loop threads.

enter image description here

Images are gotten from this post, which I would also recommend to go through.

0

Event Loop is an implementation of Reactor design patter. It’s goal is to continuously check for new events, and each time a new event comes in, to quickly dispatch it to someone who knows how to handle it.

Check this article for more details: https://alexey-soshin.medium.com/understanding-vert-x-event-loop-46373115fb3e

Digsb
  • 320
  • 2
  • 8