游戏开发中的CPU还是RAM?
我开始研究用 Java 编写的游戏服务器。诚然,Java 不是服务器开发的最佳解决方案,但它是我最熟悉的语言。
我正在尝试设计这个游戏服务器来处理大量连接,但我不确定应该更关注什么:将数据存储在内存中还是降低内存使用率并使用更多原始 CPU 功率?
I'm beginning to work on a game server written in Java. Granted, Java is not the best solution to server development, but it is the language that I am most comfortable with.
I'm trying to design this game server to handle a lot of connections, and I'm not sure what to focus more on: storing data in memory or keeping memory usage down and using more raw CPU power?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当然取决于你的游戏是什么样的。我最近对 5,000 个客户端、大约 20MB 内存的服务器进行了基准测试。您可能保存比我更多的状态数据,这可能是一个问题。
许多连接的严重问题是设置套接字以正确处理它,使用某种方式的套接字处理变得非常陷入困境或破坏@1024连接等。我不确定你可以在java中做多少优化。
查看此链接了解我正在谈论的内容。
而且,祝你好运!另外,尽快将语言切换到提供与 java 相当的功能但没有可怕缺点的语言(即 Objective-C 或 C#)。我不仅仅是“抨击java”,而是当你谈论做高性能的事情时你会遇到的问题是java会将你抽象得离操作系统太远,你将无法利用优化当你需要它的时候。
Certainly depends on what your game is like. I recently benchmarked my server with 5,000 clients at like 20MB of ram. You may keep much more state data than me, and it could be a concern.
Your serious issue with many connections is setting up the sockets to handle it properly, using certain manner of socket handling becomes very bogged down or breaks @1024 connections etc. I'm not sure how much optimization you can do in java.
Look at this link for what I'm talking about.
And, good luck! And also, switch languages as soon as possible to a language offering comparable features to java but without the awful drawbacks (meaning Objective-C or C#). I'm not just "slamming java" but the problem you're going to reach when you talk about doing things that are performant is that java will abstract you too far from the Operating System and you will not be able to take advantage of optimizations when you need it.
我不建议您设计服务器的用途远远超过您真正需要的用途。如果你突然发现你有上万个客户,你可以重新设计系统。
我会从基本的服务器开始,例如 8 GB 内存的 i5,价格不到 500 英镑,或者 24 GB 的 i7,价格不到 1000 英镑。
随着连接数量的增加,除非您使用云解决方案,否则您可能会在耗尽资源之前耗尽带宽。
顺便说一句:您可以用 Java 实现延迟低于 100 微秒的高频交易系统。我还没有听说过任何 Objective-C 高频交易系统。 C# 在 Windows 上可能表现得一样好甚至更好,但我更喜欢 Linux 作为服务器系统。
I wouldn't suggest you design the server for far more than you really need to. If you suddenly find you have 10,000s of clients, you can re-design the system.
I would start with a basic server e.g. i5 with 8 GB of memory for less than £500, or an i7 with 24 GB for less than £1000.
As your number of connections grows you are likely to run out of bandwidth before you run out of resources unless you use a cloud solution.
BTW: You can implement a high frequency trading system with less than 100 micro-second latency in Java. I haven't heard of any Objective-C high frequency trading systems. C# might be able to perform as well or better on Windows, but I prefer Linux for server system.