

# Best practices for Neptune Graph Sessions

 The following best practices help you get predictable behavior and cost from [Neptune Graph Sessions](gettingStarted-graph-types.md). 

## Keep queries short
<a name="best-practices-sessions-short-queries"></a>

 A session's underlying compute is stopped based on its activity and active requests. To avoid interruptions, run queries that finish within a few seconds to a few minutes. Break long-running work, such as large data loads or expensive algorithms over the whole graph, into smaller requests. 

## Retry manually after an idle period
<a name="best-practices-sessions-retries"></a>

 To avoid data corruption, Neptune Analytics rejects queries that an AWS SDK retries automatically after a connection timeout. This applies to all Neptune Analytics graphs, and matters most for sessions: the first query to a stopped session waits for the session to resume, which takes under 20 seconds, so it's more likely to time out. When you query a session after an idle period, handle a timeout by retrying the query in your application instead of relying on SDK retries. 

 For latency-sensitive requests, set your client timeout to allow at least 20 seconds for a resume, or send a lightweight query first so that the session is running before the requests that matter. 

## Rely on automatic stop and start
<a name="best-practices-sessions-auto-stop-start"></a>

 You don't need to stop or start a session explicitly. A session stops automatically after 15 minutes with no traffic, and starts automatically when the next query arrives. While `StopGraph` and `StartGraph` are supported for sessions, we recommend that you rely on automatic stop and start. See [Automatic stop and start for Neptune Graph Sessions](managing-sessions-auto-stop-start.md). 