Simplified Chinese

current version: v1.0.0

nfshmserver

NFShmServer is a lightweight, agile, elastic, distributed shared memory plug-in development framework developed in C++, allowing you to develop server-side applications faster and easier. Part of the ideas come from UE4 and Ogre. (currently mainly used In the field of games) The open source architecture I wrote was open sourced a few years ago, and then I started my own project, but I didn’t open source it anymore. I don’t have a project now, and I have modified it for 2 years, and I plan to open it up again.


License
GitHub stars
GitHub issues
GitHub code size in bytes
SonarCloud
codecov
QQ Group
Discord
996.icu

Copyright © [NFShmServer]
GitHub: https://github.com/yigao/NFShmServer

Code cloud: https://gitee.com/xiaoyi445_admin/NFShmServer

QQ group: Click to add group 762414765

CImaster branchdevelop branch
Github ActionsGithub ActionsGithub Actions

characteristic

  • It is possible to achieve a distributed architecture without modifying any source code, to achieve single-process operation, and to speed up the usual server development.Distributed operation only requires program startup and parameter modification
  • C++ hot update, the server restarts after a crash, the player has no perception, no impact, no price data is lost, even the intranet protocol data will not be lost, the game data is stored in the shared memory, and the shared memory architecture has passed through many MMOs. There is no problem with the project verification. If the intranet communication uses shared memory communication, the player protocol data will not be lost when the server is abnormal. If your level is sufficient, you can theoretically do hot updates without restarting the server. Of course, it is not recommended that you do so.
  • Server game configuration data, from excel to shared memory code, to sql statement, just define a protobuf structure, you can generate a lot of useful code, you can use this protobuf structure to read excel data, generate the corresponding shared memory structure class, To store data, you can also generate sql data, import the excel table into the database, without modifying the source code, you can read the excel data from the local file, and you can directly read the configuration from the database.
  • For the player’s personal data, you only need to define a protobuf structure, automatically generate shared memory data, sql data, and complete the access of mysql data through protobuf emission, without writing sql statements yourself.
  • Similar to Tencent’s internal server, each server process has an independent ID similar to the network IP to represent this server. You don’t need to know where any server process is deployed, as long as you know the independent ID of this server, you can communicate with each other
  • Friendly log control, you can control individually, a small module’s log, or even a player’s log
  • Cross-platform (Windows, Linux, MacOS)
  • High availability system architecture
  • High concurrency and high performance network module
  • The supporting U3D client, a fishing project, has not been uploaded yet
  • Rich plugins (DB, script, HTTP, WebSocket, etc.)

Dependencies

  • libevent
  • spdlog
  • google protobuf
  • hiredis
  • rapidjson
  • concurrent queue
  • RapidXML
  • LuaIntf
  • navigation
  • lua
  • mysql
  • mysqlpp
  • curl
  • evpp
  • openssl
  • theron
  • zookeeper

The environment that may be required for linux centos installation:

  • sudo apt-get install g++
  • sudo apt-get install cmake
  • sudo apt-get install automake
  • sudo apt-get install zip unzip

(Not necessary, unless you want to modify excel, or modify the proto file) To install Excel tools, you need to install the protobuf python module and xlrd python module

Supported Compilers

  • GCC >= 7 (Tested on CentOS 7)
  • MSVC >= VS2017 (Tested on Win10)

Build and Install

FOR WINDOWS, MSVC >= 2017

  1. Git pull all source
  2. Build the solution
  3. Run the binary file by Install/Bin/Debug/rund_allserver.bat
  4. The static compilation method used on win, instead of dynamically loading so/dll files, is only used for normal development. All programs will be packaged into NFPluginLoader, and then different programs can be selected to run through the configuration file, configured and installed on linux The above configuration is the same, no need to change.

FOR LINUX(UBUNTU, CENTOS) —- please use administrator(or sudo) to do these:

  1. Git pull all source
  2. run build_dynamic_debug.sh to build Debug of NFShmServer
  3. run build_dynamic_release.sh to build Release of NFShmServer
  4. Run the server, execute in several situations:
    • Depending on whether to use the master server for distributed or zoopeer, you need to configure zookpeer first, and there are several execution methods:
    • If you want to execute all distributed processes in one process and one thread, as long as it is convenient for debugging:
    • The intranet uses TCP communication, and the master server is used for distribution: ./NFPluginLoader –Server=AllServer –ID=1.1.1.1 –Config=../../Config –Plugin=../../TcpPlugin –restart
    • The intranet uses Bus communication, and the master server is used for distribution: ./NFPluginLoader –Server=AllServer –ID=1.1.1.1 –Config=../../Config –Plugin=../../BusPlugin –restart
    • The intranet uses TCP communication, and the zoopeer server is used for distribution: ./NFPluginLoader –Server=AllServer –ID=1.1.1.1 –Config=../../Config –Plugin=../../TcpPlugin_Zookpeer –restart
    • The intranet uses Bus communication, and the zoopeer server is used for distribution: ./NFPluginLoader –Server=AllServer –ID=1.1.1.1 –Config=../../Config –Plugin=../../BusPlugin_Zookpeer –restart
    • If you want distributed execution:
    • The intranet uses TCP communication, and the master server is used for distribution: execute the script CreateScript.sh or CreateScript_TcpPlugin.sh to generate Start.sh, Stop.sh, ReStart.sh, Alllog.sh and other scripts, execute Start.sh, and a One starts the server and executes Alllog.sh to view the logs of all servers.
    • The intranet uses Bus communication, and the master server is used for distribution: Execute the script CreateScript_BusPlugin.sh to generate scripts such as Start.sh, Stop.sh, ReStart.sh, Alllog.sh, and execute Start.sh to start the servers one by one. Execute Alllog.sh to view logs of all servers.
    • The intranet uses TCP communication, and the zoopeer server is used for distribution: execute the script CreateScript_TcpPlugin_Zookpeer.sh to generate scripts such as Start.sh, Stop.sh, ReStart.sh, and Alllog.sh, and execute Start.sh to start the servers one by one. Execute Alllog.sh to view logs of all servers.
    • The intranet uses Bus communication, and the zoopeer server is used for distribution: Execute the script CreateScript_BusPlugin_Zookpeer.sh to generate scripts such as Start.sh, Stop.sh, ReStart.sh, Alllog.sh, and execute Start.sh to start the servers one by one. Execute Alllog.sh to view logs of all servers.

Tutorial && Documents

Tutorial Chapters:

–>

Concept Chapters:

Client download, the client code is still being sorted out, it will be open source later, now there is a fishing apk, you can play

game.apk

server architecture

Process architecture:

App Architecture

Single physical machine server architecture:

Single physical machine server architecture

Multi-physical machine server architecture:

Multi-Physical Machine Server Architecture

Server architecture description:

  • All servers must be connected to the master server. You can choose to use the master server as the naming server, or you can choose zookeeper as the naming server, just modify the configuration.
  • Each server has an ID similar to an IP address as a unique ID. For example, the master server ID is 1.1.1.1, and the worldserver server ID is 15.100.3.1. The servers communicate with each other without knowing which physical machine the other party is deployed on. , you only need to know the unique ID of the other party to communicate with each other
  • Each individual physical machine has a NFRouteAgentServer routing proxy server, which is used to realize intranet communication and communicate with other physical machines on this physical machine, and a NFProxyAgentServer gateway proxy server, which is used to link the gateway to achieve external (client) communication
  • physical machine
  • Logical servers such as LoginServer, LogicServer, GameServer, WorldServer, SnsServer, and StoreServer are not connected to each other. All of them on the same physical machine are connected to the same NFRouteAgentServer routing proxy server, and register their unique IDs to this NFRouteAgentServer to achieve mutual communication. , For example, LoginServer sends a message to WorldServer, LoginServer and WorldServer are not connected to each other, LoginServer needs to send the message to NFRouteAgentServer first, and NFRouteAgentServer forwards the message to WorldServer.
  • The NFRouteAgentServer routing proxy server is connected to the NFRouteServer server to achieve mutual linking. The NFRouteAgentServer routing proxy server will send the logical server information under itself to the NFRouteServer server to realize distributed cross-physical machine communication. Server communication between different physical machines requires NFRouteServer. For example, LoginServer sends messages to WorldServer that is not on the same physical machine. LoginServer needs to send the message to NFRouteAgentServer on the same physical machine, and NFRouteAgentServer forwards the message to NFRouteServer. Let’s forward the message to NFRouteAgentServer on the same physical machine as WorldServer, and NFRouteAgentServer forwards the message to WorldServer
  • The client only connects to NFProxyServer and sends a message to the logical server. NFProxyServer will forward the message to the NFProxyAgentServer proxy server connected to the logical server. The NFProxyAgentServer proxy server forwards the message to the logical server. Similarly, when the logical server sends a message to the client, it needs to pass the NFProxyAgentServer proxy server, NFProxyAgentServer proxy server is sending messages to NFProxyServer, NFProxyServer is sending messages to clients

some awesome projects

PSS

  • Author: freeeyes
  • Description: Plugin-based cross-platform web server framework

ARK

  • Author: NickYang1988
  • Description: Plugin-based cross-platform web server framework

NoahGameFrame

  • Author: ketoo
  • Description: Plugin-based cross-platform web server framework

#NFShmServer2 #NFShmServer2 #lightweight #agile #flexible #distributed #shared #memory #plugin #development #framework #developed

Leave a Comment

Your email address will not be published. Required fields are marked *