| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
原始链接: https://news.ycombinator.com/item?id=43825336
Eieio创作了名为“百万棋盘”的独特在线游戏,玩家可以在超大规模的棋盘上互动。游戏采用Go语言开发,利用其并发能力实现实时、并发棋步操作,在众多棋盘上同时进行。游戏的架构优先考虑速度和可扩展性,使用单个进程和互斥锁保护的数据结构,每秒处理数千步棋。为确保系统能够承受负载,Eieio 使用模拟机器人进行测试,并咨询了性能工程师。 游戏采用乐观锁更新棋步,并使用依赖图来处理冲突的更新。棋子可以跨棋盘移动,但吃子仅限于单个棋盘,这是为了促进引人入胜的对局而做出的设计选择。作者计划在实施防止滥用措施(例如限速)后开源代码。早期的玩家策略包括建造坚不可摧的堡垒,突显了该项目规模所带来的涌现式游戏玩法。
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
My blog describing it is pretty sparse, sorry about that. Happy to answer any questions that folks have about the architecture.
Not that it was necessary, but I got really into building this out as a single process that could handle many (10k+/sec) moves for thousands of concurrent clients. I learned a whole lot! And I found golang to be a really good fit for this, since you mostly want to give tons and tons of threads concurrent access to a little bit of shared memory.
reply