> For the complete documentation index, see [llms.txt](/llms.txt)


# Server Types and How to Choose

The differences between relay, sync, and stateMachine, how to choose, and the development workflow



GS2-Realtime has three server types, depending on what the room's server does. This page explains which one to choose and what you build after choosing.

## Server Types {#execution}

| `serverType` | What the server does | What you build in the game | Suited for |
| --- | --- | --- | --- |
| `relay` | Relays messages to specified players or to everyone | The message format and the handling after receiving it | Games that want to design their own communication freely |
| `sync` | Delivers object state to everyone and manages who can modify it | Prefabs for display and the logic that operates them | Games that want to share positions and state |
| `stateMachine` | In addition to `sync`, creates and updates objects with the rules you register | Everything in `sync`, plus rules written in C# | Games that want the server to decide enemy behavior, HP, and battle progression |

With `stateMachine`, the server decides HP calculations and whether an attack is allowed, so a modified client cannot rewrite the results. Even when multiple players operate at the same time, the server processes their operations in order, so everyone sees the same result.

## How to Choose {#availability}

You choose with `serverType` in the Realtime namespace settings.

- If you only want to deliver your own messages to participants, choose `relay`.
- If you want to share the positions and state of objects, choose `sync`.
- If, in addition, you want the server to manage enemy behavior and game progression, choose `stateMachine`.

For how to use `relay`, see [Introduction to GS2-Realtime]().

## stateMachine Development Workflow {#workflow}

| Step | What you build | Page that explains it |
| --- | --- | --- |
| 1. Write the rules | C# that spawns enemies, validates operations, and handles the passage of time | [Room Definition Reference]() |
| 2. Generate | The rules (GSL) and the sync schema for Unity | [Generation and Registration](#deployment) |
| 3. Register | Registration with GS2-StateMachine and the Realtime namespace settings | [Generation and Registration](#deployment) |
| 4. Display in Unity | Prefabs, NetworkWorld, and the connection logic | [Unity Client]() |

Rules written in C# are converted to GSL and run inside the room. The C# code itself does not run on the server, so there are restrictions on the C# you can use.

## Page Guide {#guides}

| What you want to do | Page |
| --- | --- |
| Try everything end to end first | [Tutorial: Build an Enemy Whose HP Is Managed by the Server]() |
| Look up Unity settings and APIs | [Unity Client]() |
| Look up how to write rules and the limits | [Room Definition Reference]() |
| Look up the C# definition format (states, Step, supported syntax) | [C# Definition Reference]() |
| Migrate from Photon (PUN2) | [Migration Guide from Photon]() |



