This article is to provide some mobile gaming server optimization measures, some of which ideas are used in different occasions, not with a framework. You need to choose the appropriate scene mode according to the application!
Mobile game server considerations, optimization measures
1: IO operation is the largest consumption point performance, great attention to optimize the room.
2: Algorithm data structure. Sort optimization path searching algorithm. list, vector, hashmap choice. Big data addressing, do not consider traversal, pay attention to consider hash.
3: memory management. Overloading new / processing delete, memory pool object pool.
4: data prepared in advance and instant calculations.
5: Statistical aspects of monitoring the CPU. Logical frame count (it should be less than 50ms).
6: Pre-distribution tank to reduce switching and scheduling, thread pool and pretreated connection pools.
7: monitoring the frame group and information statistics and message queue.
8: CPU consumption Ranking: a first synchronous AOI, contracting the second network I / O operations, the third skill / BUFF determination calculation process, the frequency of the fourth timer.
9: memory leak detection, memory access violation alert, recovered memory fragmentation.
10: Ranking memory consumption: a first player object comprises its articles, the second network data buffer.
11: Note that 32-bit and 64-bit memory fault tolerance.
12: reduce unnecessary subcontracting sent.
13: reducing the cost of duplicate packets and re-package the copy.
14: Emergency recommended sub packet (sent immediately) and non-emergency packet (timing of transmission in rotation).
15: Ranking bandwidth consumption: a first synchronous movement position, loading the second object, the third landing burst, the state machine of the fourth timer message.
16: The client can do a pre-determined part of the mechanism, the operation part sub-transmission possible.
17: When a large number of players gathered, some non-urgent packets discarded.
18: Note that the number of key tables within a single database.
19: active users and inactive users access division process.
20: Players control the operating frequency of the operation of the database.
21: Note the use of shared memory and other ways to secure data backup storage.
22: Note that the security policy, internal network for IP checks, the log records, within any two points are ring using an encryption algorithm will be better.
23: Real-time attention to the gateway, database interfaces to monitor control.
24: timer should be stored in a queue, rather than one-way positioning.
25: When squared data synchronization, no direct synchronization direction pad, plus a role for AOI, based on the round side collision principle, abandon unnecessary information grid, you can save.
26: Clients do part of the prediction mechanism, pay attention to the time stamp problem when the server is detected.
27: regular heartbeat packet, it is necessary to check the dead links.
28: In order to achieve a more responsible and more types of AI, AI pathfinding stand-alone server design is already a must. Next to consider is chat, sync.
29: within the gateway server can consider using UDP.
30: Note that all memory pool, the pool and other objects of the dynamic expansion of distribution.
①: CPU to memory exchange of ideas.
②: NPC immortal idea. (Only disable)
③: the dynamic expansion of the concept, the concept of load balancing.
④: The client can not be trusted idea.
⑤: pointer data, messages are not credible idea.
⑥: Try to be the most rigorous check on the client side, blocking unnecessary request
⑦: can function on the client, on the client implementation, the server can be verified