Search code examples
javatcparchitecturevert.xvertx-verticle

Efficient way to use vertx Vertciles in a TCP server


I am working on a TCP server that needs to be able to manage up to 500 simultaneous connections. It's a simple server, that waits for the client to establish a connection. Then, it calculates resources asked by the client, and sends it to it.

Rather than using a thread per connection, I have decided to use Vertx.

A colleague adviced me to use one verticle per connection. Reading the documentation, I had the feeling that doing this would go against the principle of Vertx, and that it would amount to doing one thread per connection.

But the thing is, I don't really know how I could do it another way. I could have different Verticles to handle different operations, but these operations are executed a lot in a short time, so it would involve tons of Verticles creation. It would probably be expensive, in terms of performances.

So my question is : Should I do as my colleague said ? If not, Do you have any recommandation?

I understand that this might be hard to answer without knowing exactly what the server needs to do, but the point of this question is to understand the way Vertx should be used to make it as efficient as possible. I don't expect an anwser that will exactly fit my needs, but recommandations to put me in the right track.

Thanks a lot!


Solution

  • You do not need one verticle per connection. Start with one verticle instance and then increase the number of instances as needed (depends on your hardware).

    The vertx-examples repository has an Echo TCP server and client to get you started.