GitHub Danie1LinDistributedGolangGameServer A Distributed Game Server Made With Golang

From Trade Britannica
Jump to: navigation, search

I was just starting to learn Golang. Then I started to think about the best way to learn it. Because the concurrency mechanisms of Golang is very powerful, I choose online game to verify if I can use Golang to make a efficient game server.For me, this is the first time I make this such hard project. Unity, Golang, and C# are the three things I need to master at a time. I am grateful that I still have passion for this work and I never stop trying.



Tech/framework



- golang - gRPC - Kubernetes - Protobuf



CrossPlatform - Messages packet use protobuf. It is lightweight, fast and crossplatform. - Autoscaling- The controller is written in go-client. You can wire the strategy to autoscale dedicated server. - Lightweight: The image of dedicated server is less that 40MB.



Architecture



Agent server :



Match players to create or join a room. You can also control the load balancing and gameplay server. Agent will create a new pod to run the gameplay server if it has more connections than it should.



Gameplay Server



- Once players have been successfully matched, these players will be given the gameplay server's token and ip, and they can begin to play.



Packet Validating



In the branch master, I use ODE to simulate the physics on server.It is the most safe way to keep game fair.However, I found the memory server use is too much for me, Because I don't have money to maintance the server. I devised a way to let clients validate packets and run simulations of physics independently to reduce the server's load. I have completed the entities that can attack each other so far. I will begin to design forewards.



- The validation portion that prevents players from cheating. - An interface connecting a Physics Simulator.



Server : Two Ways to Run a Server:



- Run distributed server using Kubernete cluster - Use Kops to install kubernete on AWS - Create cluster - Install Mongodb - edit setupEnv.sh with your setting and bash setupEnv.sh go run main.go --type=agent on your local machine (Must on Where you install Kops)



- Run Standalone Server from Local Machine - Setup Mongodb with your setting.



Client:



This project can be downloaded. game servers You can also try build Andorid APK if you are interested in testing with Mutliplayer. It is very likely to be built correctly.



How to use?



If you are interested in making your own game, I would be honored to assist. You can throught these step to make it work.