简体   繁体   English

在TCP服务器中使用vertx Vertciles的有效方法

[英]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. 我正在开发一个TCP服务器,它需要能够管理多达500个同时连接。 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. 我没有使用每个连接的线程,而是决定使用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. 阅读文档 ,我觉得这样做会违反Vertx的原则,并且相当于每个连接做一个线程。

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. 我可以使用不同的Verticle来处理不同的操作,但是这些操作会在很短的时间内执行很多,所以它会涉及大量的Verticle创建。 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. 我知道如果不确切知道服务器需要做什么,这可能很难回答,但问题的关键在于理解Vertx的使用方式,以使其尽可能高效。 I don't expect an anwser that will exactly fit my needs, but recommandations to put me in the right track. 我不希望有一个完全符合我需求的anwser,但是建议让我走上正轨。

Thanks a lot! 非常感谢!

You do not need one verticle per connection. 每个连接不需要一个Verticle。 Start with one verticle instance and then increase the number of instances as needed (depends on your hardware). 从一个Verticle实例开始,然后根据需要增加实例数 (取决于您的硬件)。

The vertx-examples repository has an Echo TCP server and client to get you started. vertx-examples存储库有一个Echo TCP服务器和客户端 ,可以帮助您入门。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM