> ## Documentation Index
> Fetch the complete documentation index at: https://docs.purpify.host/llms.txt
> Use this file to discover all available pages before exploring further.

# Diagnose Java server lag

> Identify server-side, connection, or client lag and profile a Purpify Minecraft Java Edition server with spark.

First identify where the lag occurs. Server-side, connection, and client lag require different fixes.

| Lag type    | Common signs                                                                       |
| ----------- | ---------------------------------------------------------------------------------- |
| Server-side | The world slows for everyone, mobs freeze, or mined blocks reappear.               |
| Connection  | One or more players have delayed actions or rubber-band while moving.              |
| Client      | One player's display stutters or loses frames while the server continues normally. |

## Check server-side causes

1. Read the console for repeated errors, watchdog warnings, or overloaded messages.
2. Check whether the problem began after adding a plugin, mod, add-on, farm, redstone machine, or large group of entities.
3. Review `view-distance`, `simulation-distance`, and `entity-broadcast-range-percentage` in `server.properties`.
4. Test one change at a time and compare performance under similar player load.

## Profile the server with spark

Use spark on compatible plugin server software to find expensive plugins, tasks, entities, and server threads.

<Steps>
  <Step title="Install spark">
    Install a compatible spark `.jar` by following [Install Java plugins](/java/plugins), then restart the server.
  </Step>

  <Step title="Start a profiler">
    Run the profiler during the lag you want to investigate.

    ```text theme={"dark"}
    spark profiler start
    ```
  </Step>

  <Step title="Stop and open the report">
    Let it collect representative activity, then stop it.

    ```text theme={"dark"}
    spark profiler stop
    ```

    Open the generated report link.
  </Step>

  <Step title="Read the result">
    Check TPS, milliseconds per tick, memory and garbage collection, then inspect the plugin, mod, world, or thread consuming the most processing time.
  </Step>
</Steps>

<Warning>
  A spark report may contain server details. Review it before sharing the link publicly.
</Warning>

<Columns cols={2}>
  <Card title="Server properties" icon="gear" href="/java/server-properties">
    Adjust view, simulation, and entity broadcast distances.
  </Card>

  <Card title="Pregenerate the world" icon="globe" href="/java/pregenerate-world">
    Generate chunks before high-speed exploration.
  </Card>
</Columns>
