how to impove game-server performance with mutil-core cpu
how to impove game-server performance with mutil-core cpu My point:
- one busy process make one core busy, if only one busy process, very bad.
- multi-process process and listen on diffrent port imporved concurrency connections
- multi-process can't share the memory data directly. they need communicate.
- they can communicate in socket, fp socket开发者_如何学C, and redis
- seperate game-server into diffrent functions, each function a standalone process, some function can be parrallel processes.
if my point is correct, my question is:
what's the best way to communicate between processes, and keep the data synchronized, the best means fast and simple.
I am using nodejs, but I think it's the same with c for this topic.
Edit:
Sharding or seperate by functions , which is better
There are many discussions about that available on internet so I am just joining the links instead of repeating what they say:
- Use Threads Correctly = Isolation + Asynchronous Messages
- Use Thread Pools Correctly: Keep Tasks Short and Nonblocking
- Break Up and Interleave Work to Keep Threads Responsive
- Sharing Is the Root of All Contention
- Design for Manycore Systems
These links show the best practices to create a safe and well designed parallel solution.
I would advice to create a pool of threads to handle the connections. One thread per connection. That's the common "pattern" for servers.
One method for node.js is to use ØMQ, which allows you to communicate between threads, processes, and servers with the same simple BSD sockets compatible API.
Here's the node.js binding to try:
https://github.com/JustinTulloss/zeromq.node
精彩评论