QtCore 是否太“重”了?用于服务器端?
我正在考虑使用 Qt 库编写一个自包含的 http 服务器,尽管很多人认为 QtCore 太臃肿并且开销太大。 QtCore http 服务器会使用线程池管理大约 50 个并发连接的负载吗?
QtCore 库在 arch Linux 上动态链接,编译为经过优化 o2 发布
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. Would a QtCore http server manage a load of about 50 concurrent connections, using a thread pool.
The QtCore library is dynamically linked on arch Linux compiled for release with optimization o2
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
没有理由不能用 Qt 编写服务器,但是,实际上没有办法事先判断性能是否是您想要的(取决于您的服务器做什么)。请注意,并发线程的最佳数量通常取决于硬件核心的数量以及程序中的并行级别。我的建议是在最短的时间内尽可能地实现,然后根据需要调整性能。即使服务器无法处理那么多并发连接,您也可以使用进程级并行性(运行多线程服务器的多个实例),直到提高性能为止。
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). 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.
您的问题非常广泛,答案取决于您想要如何设计 http 服务器。您可以将其设计为“单线程反应器”或“多线程前摄器”或“半同步半异步”服务器。
QT 主要使用原生或 posix API 上的小包装类,并且肯定会带来自己的超重,50 个连接听起来并不算太多,但答案又取决于这些连接将做什么?提供简单的页面或执行繁重的计算?
我认为该项目的难点在于实现一个安全、可靠、可扩展的完整http服务器。您必须编写大量代码才能提供简单 Java servlet 模型的生命周期。需要许多接口/抽象。
您可以找到已经测试过的开源 http 服务器。我什至懒得编写自己的生产软件。
Your question is very broad and the answer depends on how you want to design your http server. You could design it as a "single threaded reactor" or "multi-threaded proactor" or "half-synch half asynch" server.
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 ? 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. You will have to do a lot of coding just to provide the life cycle of a simple Java servlet model. Many interfaces/abstractions are required.
You can find open source http servers already tested. I would not even bother writing my own for production software.
50 个连接并不算多。
但我希望你添加 QtNetwork 模块:-)
50 connections isn't much.
But I hope you will add the QtNetwork module :-)