简体   繁体   English

QtCore是否太“繁重”,无法在服务器端使用?

[英]Is QtCore too 'heavy' for server-side use?

I am looking into writing a self contained http server using Qt libraries, although many people have the view that QtCore is too bloated and that the overhead would be too large. 我正在考虑使用Qt库编写一个自包含的http服务器,尽管许多人认为QtCore太肿,并且开销会太大。 Would a QtCore http server manage a load of about 50 concurrent connections, using a thread pool. QtCore http服务器将使用线程池来管理约50个并发连接的负载。

The QtCore library is dynamically linked on arch Linux compiled for release with optimization o2 QtCore库是在Arch Linux上动态链接的,该Linux编译为使用优化O2发布

There is no reason that one could not write a server with Qt, however, there is really no way to tell beforehand whether the performance will be what you want (depends on what your server does). 没有理由无法使用Qt编写服务器,但是,实际上没有办法预先告知性能是否达到您想要的水平(取决于服务器的性能)。 Note that the optimal number of concurrent threads is typically dependent on the number of hardware cores, as well as the level of parallelism in your program. 请注意,并发线程的最佳数量通常取决于硬件核心的数量以及程序中的并行度。 My suggestion would be to implement whatever you can in the least amount of time, and then tune the performance as needed afterwards. 我的建议是在最短的时间内执行所有可能的操作,然后再根据需要调整性能。 Even if the server cannot handle that many concurrent connections, you can use process-level parallelism (running multiple instances of your multithreaded server), until you have improved the performance. 即使服务器不能处理那么多并发连接,您也可以使用进程级并行性(运行多线程服务器的多个实例),直到提高性能为止。

Your question is very broad and the answer depends on how you want to design your http server. 您的问题非常广泛,答案取决于您要如何设计http服务器。 You could design it as a "single threaded reactor" or "multi-threaded proactor" or "half-synch half asynch" server. 您可以将其设计为“单线程反应堆”或“多线程proactor”或“半同步半异步”服务器。

QT mostly uses little wrapper classes over native or posix APIs and brings its own overweight for sure and 50 connections does not sound too many but again the answer depends on what will these connections do ? QT大多在本机或posix API上使用很少的包装器类,并确定会带来自己的超重,并且50个连接听起来并不多,但答案又取决于这些连接将做什么? Serve simple pages or perform heavy calculations ? 服务简单的页面还是执行繁重的计算?

I think the difficulty of the project lies in implementing a full http server that is secure ,reliable and scalable. 我认为该项目的难点在于实现安全,可靠和可扩展的完整http服务器。 You will have to do a lot of coding just to provide the life cycle of a simple Java servlet model. 为了提供一个简单的Java servlet模型的生命周期,您将不得不做很多编码。 Many interfaces/abstractions are required. 需要许多接口/抽象。

You can find open source http servers already tested. 您可以找到已经测试过的开源http服务器。 I would not even bother writing my own for production software. 我什至不用为生产软件编写自己的软件。

50 connections isn't much. 50个连接并不多。

But I hope you will add the QtNetwork module :-) 但我希望您会添加QtNetwork模块:-)

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

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