Skip to content
ark

Server architecture

ark can assemble different server processes from the same plugin/module interfaces. The topology below is a reference for assigning responsibilities in a multi-process deployment. It is not a turnkey cluster, an implemented Registry service, or a measured capacity result.

Reference process roles and deployment boundaries

Separate roles before scaling

Reference role Responsibility Application decisions
Entry / directory Direct a client to an environment or entry endpoint Authentication, endpoint selection and discovery source
Cluster services Coordinate work shared across zones, such as a master or shared business service Ownership, state recovery and failover
Router Forward selected messages between zone and cluster processes Destination IDs, allowed routes, congestion handling
Zone services Run a zone’s world, game, proxy or login responsibilities Sharding, player placement and zone boundaries
Storage services Store application records independently from process routing Data model, replication, durability and backup

These roles need not be separate binaries for every application. Begin with the processes required by the workload; introduce a boundary when its ownership, scaling or failure behavior needs to differ. A plugin boundary alone is not a network or high-availability boundary.

What the repository supplies

src/server/ contains example process roles such as master, router, world, game, proxy, login and dir. Their corresponding config/*.app.toml manifests select plugins. A role’s source directory and configuration demonstrate composition; they do not certify that every service in the reference topology is complete.

The Bus plugin represents process addresses and routing destinations. Use the Bus reference to configure local process relationships, create a connection, and send a message with the required identifiers. The network plugin supplies transport integration. Module-to-module calls inside a process continue to use direct interfaces, as shown in application architecture.

Start from a verified pair

  1. Prepare one application’s runtime directory using the quick start.
  2. Give each process its own Bus identity, manifest and endpoints. A shared library filename is not a process identity.
  3. Verify a local client/server or Bus connection with a small workload and inspect both sides’ logs before adding routing layers.
  4. Add multiple zones or routers only with explicit ownership and recovery rules. Keep the target workload and failure tests with the deployment configuration.

Discovery is a separate integration decision. The framework does not require every deployment to start Consul. Configuration-driven endpoints, platform discovery and an optional integration have different operational requirements; none makes a custom multi-node Registry or automatic failover already available. See the routing design proposal for the historical cluster/router/zone concept, not a released HA contract.

Limits to verify in a deployment

Endpoint connectivity alone does not verify authentication, message delivery after reconnect, state transfer, split-brain behavior or storage consistency. The 100,000–200,000 concurrent-user target is a multi-process deployment goal, not a measured single-process limit. Benchmarks and acceptance distinguish local correctness/performance tools from cross-host capacity and endurance tests.

Verify server construction

The built-in server plugins use typed module factories and explicit dynamic-library entry points. Construction keeps the existing plugin version, configuration access, interface RTTI names, installation order and disabled frame updates. Network callbacks, lifecycle methods, protocols and resources retain their existing behavior.

With the application build dependencies installed, run:

cmake -S . -B out/server-construction -G Ninja \
  -DCMAKE_TOOLCHAIN_FILE="$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake" \
  '-DVCPKG_MANIFEST_FEATURES=application;boost;etcd-client' \
  -DCMAKE_BUILD_TYPE=Debug -DASIO_STANDALONE=OFF \
  -DARK_BUILD_APPLICATIONS=ON -DARK_BUILD_PROTO=ON \
  -DARK_BUILD_CORE_TESTS=ON -DARK_BUILD_EXAMPLES=OFF
cmake --build out/server-construction --target check-server-plugins --parallel 2

check-server-plugins exercises the real factory and assembly of each of the seven enabled server libraries, checks the retained source include paths, verifies disabled update admission, and loads each actual shared library to inspect both exported entry symbols. Each role runs a minimal core-only export host before its separate real-factory host. The two hosts separate export inspection from factory/lifecycle setup. On Windows, generated messages belong to one shared AFProto DLL linked through ark::proto; the real Kernel host also constructs Protobuf messages and exchanges them with the loaded Kernel library. Linux/macOS retain their existing static message-library configuration. A counted substitute through the real Login assembly checks destruction of rejected candidates, preservation of the original registration and a successful retry. check-core includes these focused checks in application builds. A separate test shared library runs the real Login entry and exit through the manager loader with a controlled module. The shared-library export hosts do not call business lifecycles. The real-factory hosts also exercise startup result propagation with controlled dependencies, as described below. The factory and export checks do not start network services or establish deployment readiness; the separate launcher checks below exercise local listeners.

node --test tests/ci/server-construction.test.mjs checks configure-only compatibility forwarding and construction policy without compiling native code. Simulate has source-policy coverage only; its unsupported PhysX 3/MessagePack integration is outside these native targets.

Role startup errors

Login, Proxy, Master, World, Dir and Router declare bus_module and net_service_manager_module as required providers through module_base<Role, bus_module, net_service_manager_module>. The manager rejects either missing interface in the dependencies phase, before any startup hook, and orders both providers before the role during startup. Their existing init() checks remain valid for direct lifecycle calls. Game also checks Kernel in init() before using it in later stages. Failed listener creation or a missing inter-server service returns false from post_init(). The manager retains the failing role and phase and stops startup; the launcher prints that diagnostic and exits with code 1. Successful listener setup returns true. These paths no longer terminate the process with code 0. These declarations do not add rollback or change the existing normal cleanup hooks.

The retained Master Timer/Msg pointers, Proxy Msg pointer and World Kernel/Msg pointers have no active dereference in these implementations and are not required providers. Declaring them solely because a pointer is retained would change supported compositions. The required edges refer to interface nodes; Net’s own Bus/Timer requirements do not create a reverse role dependency.

The public concrete Login, Proxy, Master, World, Dir and Router implementations now have a different module_base specialization. This is an incompatible source/ABI change for consumers that name the previous concrete base. Replace those base references with the new specialization or the role interface, and rebuild affected consumers and plugins together. The role interface RTTI keys, factory return types, message formats and listener lifecycle phases remain unchanged; no unchanged concrete layout is guaranteed.

The real-factory tests also run each public role assembly through the manager with controlled Bus/Net outcomes: missing dependencies, failed creation, missing service and successful setup for the six listener-only startup paths. For all six listener-only roles, these tests verify the exact two interface keys, remove each required provider before any provider hook, and block both providers behind a late-sorting prerequisite while an early-sorting role dependent checks all four startup phases and reverse cleanup order. Successful startup without the unused optional pointers remains covered. The Game construction host covers missing dependencies, including Kernel; its healthy listener lifecycle is checked through the real composition below. On macOS and Linux, check-server-startup additionally runs the actual Utility/Bus/Net/role libraries for all six listener-only paths, using a private minimal Bus test configuration. It checks healthy loopback startup and an occupied endpoint held by the test, including the failing role/phase and launcher exit code 1. These checks do not validate the shipped role presets or business handlers.

When the Kernel plugin target is available, the POSIX check-server-startup cases also include Game. check-server-startup-game selects just those two cases: the actual Utility, Bus, Net, Kernel and Game libraries run with private Bus identity 1.1.31.1 and a minimal Player JSON schema. Healthy startup must accept a loopback connection, cooperate with SIGTERM shutdown, close its peer and listener, and exit with code 0. An endpoint occupied by the test must instead produce the Game post_init failure diagnostic and exit code 1. The existing startup and shutdown observation bounds are unchanged. No entities or gameplay messages are created.

Game declares Kernel, Bus, Net, Map and class metadata as required providers through its concrete module_base specialization. The manager rejects any missing provider before running any startup hook, and initializes declared providers before Game in each startup phase. Map is required by scene/view operations; metadata is required by Player callback registration. Game still retains Guid and Msg lookups, but its current active implementation does not use them, so it declares no direct provider edge to either. Kernel’s existing Guid requirement remains transitive. The required runtime coupling between Map and Kernel remains undeclared; this slice does not resolve that cycle or establish a complete provider or teardown graph. The interface RTTI key, lifecycle bodies and wire format remain unchanged.

Upgrade: the retained concrete game_net_module_impl header changes its base from module_base<game_net_module> to module_base<game_net_module, kernel_module, bus_module, net_service_manager_module, map_module, class_meta_module>. Update source references to the former specialization and rebuild consumers of this concrete type, including consumers of the compatibility include game/include/game_net_module_impl.hpp. No unchanged-layout or general ABI compatibility guarantee is made. The interface type and registration key remain stable.

Game continues to resolve its module pointers during init() and register the existing Player callbacks during post_init(). The hook bodies still support either direct Game/Kernel post_init() order after all init() hooks complete; manager-driven startup now selects Kernel first through the declared edge. Before registration, Game requires Player metadata; it checks each registration result and starts the listener only after all four calls return success. Missing Player metadata or a rejected registration returns false without creating a listener. Partial registration is not rolled back.

check-game-initialization uses the production Game factory to omit each declared provider in turn and verifies dependency rejection before any provider or independent observer startup hook. A separate key-only scheduling control gives Game a deliberately early registry key and proves every declared provider’s init() runs before the real Game init() reaches its existing type checks. Those controls do not emulate provider interfaces. Existing manual phase tests separately use real Metadata, Map, Config and Guid implementations with the actual Game assembly, observe the real Player callback and control only the listener result. They retain both Game/Kernel post_init() orders and the missing-Player rejection. The separate DSO cases exercise the real network stack. These checks do not validate other class/scene callback behavior or gameplay.

The disabled Simulate source follows the same failure propagation and checks its simulation dependency before callback registration. Its PhysX 3/MessagePack integration remains unsupported by the build, so it has no native runtime acceptance in this suite. Dependency checks cover the modules dereferenced by existing startup code; they do not establish the readiness of unfinished role operations.

cmake --build out/server-construction --target check-server-startup --parallel 1
# Select Game alone when ARK_BUILD_PLUGIN_KERNEL=ON on a POSIX host.
cmake --build out/server-construction --target check-server-startup-game --parallel 1

Verify a local launcher composition

On macOS and Linux, check-server-launcher starts the real app executable with the actual Utility, Bus, Net and Login libraries. It creates a private runtime, supplies a loopback-only ephemeral endpoint for Bus identity 1.1.32.1, waits for the Login listener, connects one TCP peer, sends the owned process SIGTERM, and checks server EOF, a refused fresh connection and exit code 0. The peer replies to the server’s FIN by closing its own send side before waiting for process exit. A raw peer that stays open can make the transport wait for its existing graceful-disconnect timeout; that wait is distinct from the helper’s five-second cooperative shutdown bound. The helper has bounded startup/shutdown waits and reaps only its own child. Runtime configuration and logs remain under the build tree; a new directory is used for each run.

cmake --build out/server-construction --target check-server-launcher --parallel 1

Enable ARK_BUILD_PLUGIN_UTILITY, ARK_BUILD_PLUGIN_BUS and ARK_BUILD_PLUGIN_NET when configuring the application build. The test writes its own minimal manifest instead of modifying the shipped role presets. The Bus schema still requires a registry table; this local composition does not load Consul, register a service or perform discovery. Windows retains the construction tests above; this process/signal controller is enabled only on Unix.

This is launcher and transport acceptance. Login currently starts a listener without registering account-login handlers. Proxy’s server-selection and message-forwarding callbacks are incomplete. The shipped Router manifest does not select the Router role library, and the World preset leaves its plugin paths/configuration empty; use an application-owned, reviewed manifest before treating those presets as runnable deployments. No authentication, guest/session flow, cluster routing, reconnect recovery or persistence is established by a successful connection.

For a bounded existing business operation, enable examples and Kernel/Utility and run check-typed-examples. Its real EntityOperations library uses the checked-in manifest and metadata to create and inspect player data/tables/custom values, then destroys entities during shutdown. That in-process business demonstration and the separate Login transport composition verify different boundaries; they do not form an implemented network game-login flow.

The launcher controller reports the child exit code or signal and the last 16 KiB of its owned child log on failure. A permanent early-exit probe verifies that startup diagnostics are retained; the existing startup and shutdown deadlines are unchanged.

Verify a combined plugin flow

On POSIX, enable applications, Protobuf, core tests and the Bus, Net, Utility, Kernel and HTTP plugins, then run:

cmake --build <build-directory> --target check-system-composition --parallel 2
Check Observed behavior
Entity Checked-in JSON creates GuestPlayer; owner-thread HP changes from 100 to 85; an owning snapshot survives module destruction
Transport Protobuf service messages and binary HTTP /echo run together; a server restart uses the existing 30-second reconnect policy
Resource cleanup Route captures are released, HTTP/SS endpoints close, repeated stop() succeeds and all children exit 0
Bounds Three peer processes, at most two live together; 2-second network operations, 5-second local observations and a 55-second controller deadline

The target prints its private configuration/log directory. Record the tested revision with the result. Forced child termination is a failure. This local flow does not cover accounts, persistence, HTTP-driven Entity mutation, cross-host behavior or capacity. check-static-services separately covers eligibility and invalid-endpoint diagnostics.

Navigation

Type to search…

↑↓ navigate↵ selectEsc close