-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Async IO: Do we want it? Libraries to use? #100
Comments
See my comments in: PistonDevelopers/hematite#203 talking about my server design. (I also updated last comment talking about the client) With an threaded/actor model, async I/O would be pretty much built in (Meta/ reasoning) The model could be more simplified to prevent tons of channels being generated by having one master thread, which manages slave threads This (possible) layout would allow for when a client is added, the only thing that needs to be handed to them is the receiver of the master (there could also be multiple masters). The masters would then hand off the clients request of map generation/data/editing to the appropriate slave, which is defined by the region they manage The master will allocate who is responsible for what region, and when to spawn another slave. The slaves could then do the computation e.g. is this move legal. So it Would look lineally like this
The client thread could also just be any thread that sends a map request (such as generating a tree) The master would be the owner of the map data, and hands out references to slaves. The Master would be responsible for
The Slave would be responsible for all requests, including
Slaves perform all general actions. Each slaves could manage 1/16 of one chunk (chunk column) up to the entire map. (minimum map transfer size is 1/16 of packet, technically we could get around this with multi block updates, but at that scale I don't think concurrency will help, unless you had dozens of cores) The only Logic the master would do is determine which slave to give the request to. If the server is not under stress, It could hand the total request off to just one slave, so the client would receive a better compressed packet. (such as loading cached map data) If it was a heavy request (such as generating new map data) the master could hand the request off to multiple slaves, which could be sent to the client in parts (when its better for the client to receive 1/3 total data at a x intervals than receive the whole "request" at 3x intervals) This slave model would take care of blocking I/O, and allow for concurrency at the same time. Benefits of this method
EDIT: If any part of this doesn't make sense please ask, even if that means the whole thing. I'm so absorbed into this that I probably can't properly view it from an outside perspective. |
Note that each world does need a global game loop which ticks synchronously, so game logic would need to run on the master. |
Also can we please use the term worker thread (or connection thread for those communicating with clients) instead of slave? |
Most of the Java based servers use http://netty.io/ (async io) should we aim for that right from the beginning via mio/mio+mioco/mio+rotor or just plain threads (with pools) and channels?
/cc @fenhl
The text was updated successfully, but these errors were encountered: