Answer the question
In order to leave comments, you need to log in
How to set up a python server for online games?
I want to make a game. The game is a shooter. The server will be written in Python.
The maximum number of players in one session is 60.
How to organize the server?
30 requests are sent per second from each client.
My version is this: each session == one thread.
In the flow, the server is already receiving packets from users.
It's just possible in another way: for each user there is a thread, but I don't understand how to transfer data from one thread to another without ruining performance.
I don't know if I'm right, correct me.
Answer the question
In order to leave comments, you need to log in
Most importantly, don't multithread in Python unless it's about io. Because there is a GIL and he will not forgive.
You can do one process per match, but then there will be a memory overrun, since you will have to duplicate static data in each process.
Take any modern asynchronous framework and write a service that can hold multiple matches. Global variables do not cause brakes.
PS Judging by the wording of the question, it may be too early for you to do such a project, try to reduce the complexity of the task by an order of magnitude.
PPS It was already correctly advised here: do as it turns out and call it a prototype. When a prototype appears, good and bad decisions will become visible, it will be possible to understand the topic in more detail.
To implement what you want, you need deep knowledge, and if you reason, you won’t go far :)
And making a server on python is not the best idea for game performance :)
+++++++++++++++++ ++++++++++++++=
Heard something about asynchronous programming, no?
+++++++++++++++++++++++++++++++++=
You can transfer information between threads using global variables :)
+++++++++ ++++++++++++++++++++++++=
In your question, I would say there are many different things that you did not specify, and this is called think what you want :)
First, do as you know = faster, because the faster the technical prototype is ready, the faster the spherical horses will disappear.
On it, you can estimate the maximum load, and how much time you can allocate for each player. In general, the direction of thought is correct, of course, but for each user its own flow is already too much.
No one always knows what game will eventually come out, it may turn out that the instance will be able to hold only 60 players if it is done well, and then there will be no talk of 60 threads.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question