Developers · Best Practices
Back-End Performance
Last updated 1 November 2026
Find what makes a page slow: log from your code, read the log, and time each part with time_diff.
Back-end performance is how long your instance takes to build a page before it sends it. Most of that time is spent in Liquid and in GraphQL queries. This section shows you what your code is doing and how long each part takes. Then you can fix the slow part instead of guessing.
The tools
| Tool | What it gives you |
|---|---|
The log tag | Writes any value to the instance log, with a type you choose, from pages, layouts, partials and background jobs |
insites-cli logs <environment> | Follows the instance log in your terminal while you load the page |
The admin_logs query | Reads the same log entries from GraphQL, 1 to 500 at a time |
The to_time and time_diff filters | Measure the time between two points in your code |
Example: time one query
Take the time before the code you want to measure, then the difference after it. time_diff returns milliseconds unless you give a unit:
{%- assign started = 'now' | to_time -%}
{%- graphql result -%}
query { records(per_page: 50, filter: { table: { value: "modules/website/developers_guide" } }) { total_entries } }
{%- endgraphql -%}
{%- assign ms = started | time_diff: 'now' -%}
pages={{ result.records.total_entries }} ms={{ ms }}insites-cli exec liquid docs57 -f timing.liquid
pages=213 ms=18.085This ran on the docs.insites.io instance on 1 November 2026. In a real page, write the result to the log with the log tag instead of printing it, then read it with insites-cli logs.
Where to look first
- GraphQL calls inside a loop. Each one is a round trip; fetch the related data in one query instead.
- Large
per_pagevalues when you only show a few rows. - Reports and exports that read a lot of data. On
recordsandusers,options: { read_replica: true }runs the read on a replica when the environment has one. Do not use it straight after a write, because a replica can lag.
Common mistakes
- Dividing a bare
time_diffby 3600 to get hours. The result is in milliseconds; pass'h'instead. - Logging a constant's value while you debug. The log is readable by anyone with access to it.
- Measuring once. Load the page several times and compare.