简体   繁体   English

Python中的文字游戏服务器,设计的优缺点?

[英]Word game server in Python, design pros and cons?

I'd like to get busy with a winter programming project and am contemplating writing an online word game (with a server load of up to, say, 500 users simultaneously). 我想忙于冬季编程项目,并正在考虑编写在线文字游戏(服务器负载最多可以同时容纳500个用户)。 I would prefer it to be platform independent. 我希望它是平台无关的。 I intend to use Python, which I have some experience with. 我打算使用我有经验的Python。 For user data storage, after previous experience with MySQL, a flat database design would be preferable but not essential. 对于用户数据存储,在拥有MySQL的先前经验之后,最好使用扁平数据库设计,但不是必需的。 Okay, now the questions: 好的,现在的问题是:

Is it worth starting with Python 3, or is it still too poorly supported with ports of modules from previous versions? 从Python 3开始值得吗?还是以前版本的模块端口仍然对它的支持太差?

Are there any great advantages in using Python 3 for my particular project? 在我的特定项目中使用Python 3有什么好处? Would I be better off looking at using other languages instead, such as Erlang? 我会选择使用其他语言(例如Erlang)更好吗?

Is there any great advantage in using a relational database within a game server? 在游戏服务器中使用关系数据库有什么很大的优势?

Are there any open source game servers' source code out there that are worthy of study before starting? 开始之前是否有值得研究的开源游戏服务器的源代码?

I would go for Python + Django . 我会选择Python + Django It makes web application developments pretty easy. 它使Web应用程序开发非常容易。

Is it worth starting with Python 3, or is it still too poorly supported with ports of modules from previous versions? 从Python 3开始值得吗?还是以前版本的模块端口仍然对它的支持太差?

depends on which modules do you want to use. 取决于您要使用的模块。 twisted is a "swiss knife" for the network programming and could be a choice for your project but unfortunately it does not support python3 yet. Twisted是网络编程的“利刃”,可能是您的项目的选择,但不幸的是,它尚不支持python3。

Are there any great advantages in using Python 3 for my particular project? 在我的特定项目中使用Python 3有什么好处? Would I be better off looking at using other languages instead, such as Erlang? 我会选择使用其他语言(例如Erlang)更好吗?

only you can answer your question because only you know your knowledge. 只有您可以回答您的问题,因为只有您知道您的知识。 Using python3 instead of python2 you get all the advantages of new features the python3 brings with him and the disadvantage that non all libraries support python3 at the moment. 使用python3而不是python2,您将获得python3带来的新功能的所有优点,以及目前并非所有库都支持python3的缺点。

note that python2.6 should implements most (if not all) of the features of python3 while it should be compatible with python2.5 but i did not investigated a lot in this way. 请注意,python2.6应该实现python3的大多数(如果不是全部)功能,而它应该与python2.5兼容,但是我并没有以这种方式进行大量研究。

both python and erlang are candidates for your needs, use what you know best and what you like most. python和erlang都是满足您需求的候选人,请使用您最了解和最喜欢的知识。

Is there any great advantage in using a relational database within a game server? 在游戏服务器中使用关系数据库有什么很大的优势?

you get all the advantages and disadvantage of having a ACID storage system. 您拥有使用ACID存储系统的所有优点和缺点。

Related to your database choice, I'd seriously look at using Postgres instead of MySQL. 与您的数据库选择有关,我将认真考虑使用Postgres而不是MySQL。 In my experiance with the two Postgres has shown to be faster on most write operations while MySQL is slightly faster on the reads. 以我对这两个Postgres的经验,在大多数写操作中已显示出更快的速度,而MySQL在读操作中则稍快。

However, MySQL also has many issues some of which are: 但是,MySQL还存在许多问题,其中包括:

  • Live backups are difficult at best, and impossible at worse, mostly you have to take the db offline or let it lock during the backups. 实时备份充其量是困难的,而最坏的情况是不可能的,大多数情况下,您必须使数据库脱机或在备份过程中将其锁定。
  • In the event of having to kill the server forcefully, either by kill -9, or due to power outage, postgres generally has better resilience to table corruption. 如果必须通过kill -9或由于断电而强行杀死服务器,则postgres通常具有更好的抵御表损坏的能力。
  • Full support for ACID compliance, and other relational db features that support for, again imho and experiance, are weak or lacking in MySQL. 对ACID合规性的完全支持以及其他支持imho和experience的关系数据库功能在MySQL中很弱或缺乏。

You can use a library such as SQLAlchemy to abstract away the db access though. 您可以使用SQLAlchemy之类的库来抽象化数据库访问。 This would let you test against both to see which you prefer dealing with. 这样一来,您就可以对两者进行测试,以查看您希望与之打交道。

As far as the language choice. 就语言选择而言。

If you go with Python: 如果您使用Python:

  • More librarys support Python 2.x rather than Python 3.x at this time, so I'd likely stick to 2.x. 目前,更多的库支持Python 2.x,而不是Python 3.x,因此我可能会坚持使用2.x。
  • Beware multi-threading gotchas with Python's GIL. 当心使用Python的GIL的多线程陷阱。 Utilizing Twisted can get around this. 利用Twisted可以解决这个问题。

If you go with Erlang: 如果您使用Erlang:

  • Erlang's syntax and idioms can be very foreign to someone who's never used it. 对于从未使用过的人,Erlang的语法和习惯用法可能非常陌生。
  • If well written it not only scales, it SCALES. 如果写得好,它不仅可以缩放,而且可以缩放。
  • Erlang has it's own highly concurrent web server named Yaws. Erlang有自己的高度并发的Web服务器,名为Yaws。
  • Erlang also has it's own highly scalable DBMS named Mnesia (Note it's not relational). Erlang还拥有自己的高度可扩展的DBMS,名为Mnesia(请注意,它不是关系型的)。

So I guess your choices could be really boiled down to how much you're willing to learn to do this project. 因此,我想您的选择可能会归结为您愿意学习多少钱来做这个项目。

A project of this kind could be a great way of investigating a new language. 此类项目可能是研究新语言的好方法。 I'd say that Erlang is one of the more interesting languages out there, (1) being functional, (2) offering a superb concurrency / (distributed) parallelism paradigm, (2) seeing use in the industry (most notably & traditionally telecommunications), (3) actually entering the desktop space (CouchDB). 我想说的是,Erlang是目前最有趣的语言之一,(1)具有功能性,(2)提供了出色的并发性/(分布式)并行性范例,(2)在业界得到了广泛使用(最著名的是传统电信) ),(3)实际进入桌面空间(CouchDB)。 If you don't know it yet, go for it! 如果您还不知道,那就去吧! :-) :-)

As for open source game servers... Well, there's plenty. 至于开源游戏服务器...好,有很多。 Google around for MUD engines etc. For starters, check out the Wikipedia entry on MOO s and look at LambdaMOO. 到处都是Google的MUD引擎等。对于初学者,请查看MOO上的Wikipedia条目,并查看LambdaMOO。

If you're already fairly familiar with Python, then I'd investigate the Twisted library if I were you. 如果您已经相当熟悉Python,那么如果您是我,就会研究Twisted库。 Twisted is an asynchronous comms library that was originally developed to support a large text-based game. Twisted是一个异步通信库,最初是为支持大型基于文本的游戏而开发的。

The current level of support for Python 3 by commonly used libraries is not high - so you probably want to stick with something like Python 2.6 at this point in time. 常用库对Python 3的当前支持水平不高-因此您可能需要在此时使用Python 2.6之类的东西。

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

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