我想实现一个高性能的rtsp服务器来处理点播请求——它只处理信令请求,不需要流媒体文件。我已经完成了一个基于Mina网络框架的Java编写的版本,性能似乎不是很高。
据我所知,高性能SIP服务器(例如VoIP服务器)是用C编写的(例如OpenSIPS、Kamailo),我应该在我的项目中使用C还是C++以获得显着的性能改进?
顺便提一句。我找到了 OpenSER 作者用 C 语言编写的原因的一些解释:
“另一方面,在用 Java 开发 SIP 应用程序时,垃圾收集器会带来很多麻烦。当垃圾收集器清理内存时,用 Java 编写的负载较重的服务器会停止工作。垃圾收集器造成的延迟甚至可能会增加。”超过 10 秒的延迟是不可接受的。”
现在的事实是否意味着我也应该使用 C?
I want to implement a high performance rtsp server which is to handle vod request --- it only handles signaling request, it does not need to streaming the media file. I have accomplish a version that is written in Java basing on the Mina networking framework, and the performance seems to be not very high.
As far as I know, high performance SIP server(e.g. VoIP server) is written in C (e.g. OpenSIPS, Kamailo), should I use C or C++ for my project to get a significant performance improvement?
BTW. I found some explanation of the reason why OpenSER is written in C by its author:
"On the other hand, it is the garbage collector that can cause lots of troubles when developing SIP applications in Java. Aheavily loaded server written in Java stopsworking when the garbage collector is cleaning the memory. The delay caused by the garbage collector can be even more than 10 seconds. Such delays are unacceptable"
Is that a fact nowadays which mean that I should use C too?
发布评论
评论(3)
这里有大量的变量,语言可能不是决定因素。 MINA 的作者 Trustin Lee 后来创建了 Netty,它确实提供了非常高的性能。 Lee 本人表示 MINA 的“性能相对较差”,因为它提供的一些功能过于复杂。与核心紧密结合。因此,在完全重写所有内容之前,您可能会先看看 Netty。
如果您使用 Oracle 的 JVM,那么您正在使用一个极度优化的运行时系统,该系统可以识别代码中的热点(因此称为“HotSpot”)并在运行时积极优化它们。很长一段时间以来,您都可以说 Java 代码比 C 代码运行得更慢。 编写良好、经过优化的 C 代码在某些选择的任务中可能优于等效的 Java 代码,但是从那里进行概括可能不再合适,当然,您的代码必须承担一些负担JVM 为您提供 Java 的帮助。另请注意,您可以采取多种措施调整 JVM垃圾收集器,例如更喜欢一致性和短暂停而不是占用空间和长暂停。
显然,C 有几个优点(靠近机器有时正是你想要的),对于某些任务的显式内存管理也是如此。
There are a huge number of variables here, language may not be the determining factor. Trustin Lee, the author of MINA, later created Netty, which offers very high performance indeed. Lee himself says that MINA has "relatively poor performance" as a result of the complexity of some of the features it offers being too tightly bound to the core. So you might look at Netty before completely rewriting everything.
If you're using Oracle's JVM, you're using an extremely optimized runtime system that identifies hotspots in the code (hence the name "HotSpot") and aggressively optimizes them at runtime. It's been a long time since you could say, ipso facto, that Java code would run more slowly than C code. Well-written, optimized C code probably out-performs equivalent Java code in certain select tasks, but a generalization from there is probably no longer appropriate, and of course your code has to take on several of the burdens that the JVM shoulders for you with Java. Also note that there are several things you can do to tune the JVM's garbage collector, for instance to prefer consistency and short pauses over footprint and long pauses.
Obviously C has several strengths (being close to the machine is sometimes exactly what you want), as does explicit memory management for certain tasks.
您是否将您的 rtsp 服务器与 Wowza 进行了比较?
Wowza也是用Java编写的,如果你的rtsp服务器性能比Wowza低,我相信你可以在不改变语言的情况下提高它的性能,否则,如果Wowza与你的服务器性能相似,则表明Java无法满足性能要求,也许你应该考虑使用 c/c++ 代替。
Have you compared your rtsp server with Wowza?
Wowza is also written in Java, if your rtsp server has lower performance than Wowza, I believe you could improve its performance without changing language, otherwise, if Wowza has similar performance with your server, it indicates that Java cannot satisfy the performance requirements, maybe you should consider to use c/c++ instead.
我用 C# 构建了自己的 RtspServer,并且可以毫无问题地传输到数百个客户端。
http://net7mma.codeplex.com/
代码项目文章 @ http://www.codeproject.com/Articles/507218/Managed-Media-Aggregation-using-Rtsp-and-Rtp
非常欢迎您采用/参考该设计! (阿帕奇 2 许可证)
I built my own RtspServer in C# and have no problem streaming to hundreds of clients.
http://net7mma.codeplex.com/
Code Project article @ http://www.codeproject.com/Articles/507218/Managed-Media-Aggregation-using-Rtsp-and-Rtp
You are more then welcome to adopt / reference the design! (Apache 2 License)