# Running in production

These are general recommendations on running Metarank in a production environment.

![Production environment overview](/files/9tT7PYR41Tj2lH5Ku7jV)

## Persistence

Metarank provides several [Persistence](/reference/overview/persistence.md) options, however for production setup we recommend using only [Redis persistance](/reference/overview/persistence.md#redis-persistence) as it operates separately from running Metarank instances.

Redis does not depend on Metarank instances being re-deployed and should be configured with [disc backup](https://redis.io/docs/manual/persistence/).

At the moment, Metarank stores only processed events in Redis, so we recommend storing all events separately.

## API Serving

[Metarank CLI](/reference/cli.md) exposes several modes with which you can run Metarank: `standalone` and `serve`.

Although `standalone` mode is great for development purposes, it can't be used for production deployment:

* standalone mode cannot be scaled as it's not possible to run several instances that point to the same database
* you cannot re-train the model without restarting Metarank

For production deployment, you should only use the `serve` mode. You can have as many `serve` instances as you need, depending on the load you have and you can perform graceful restarts of Metarank with 0 downtime.

Resource consumption of the `serve` mode is relatively low as it performs minimal computations, so you can use cheaper nodes than when training the model.

At the moment, Metarank does not provide clustering capabilities out of the box, so you will need to use an external load balancer when deploying multiple API instances.

## Re-training

Metarank exposes a `train` mode that re-trains your model based on the calculated features. Training is a long-running process with high memory consumption, which depends on the amount of data that is stored, so we recommend running this process on-demand. You can re-train your model once a week or once a month, so there's no need to keep a large instance online all the time.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.metarank.ai/how-to/production-recommendations.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
