> For the complete documentation index, see [llms.txt](https://docs.release.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.release.com/reference-documentation/reference-examples/managing-service-resources.md).

# Managing service resources

Working with defaults and overrides for resources

Both the default configuration and the environment-specific configuration include a `resources` section, which contains resource defaults for:

* CPU limits and requests (required)
* Memory limits and requests (required)
* Replicas (required)
* Storage type and size

These resources are based on Kubernetes definitions of resources. You can read more about resources [here](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/).

Here is an example default resources stanza:

```yaml
resources:
  cpu:
    limits: 2000m
    requests: 100m
  memory:
    limits: 16Gi
    requests: 100Mi
  replicas: 1
  storage:
    size: 9Gi
    type: aws-efs
```

## Overriding resources

You can override the resource defaults in the [Application Template](/reference-documentation/application-settings/application-template.md), either in the `services` section or in the template for a particular environment.

Let's take a look at how to make the following changes to the defaults:

* Add extra memory for a `frontend` service in all environments.
* Deploy two `backend` replicas in all environments.
* Specify five `backend` replicas and ten `frontend` replicas in our production environment.

For the examples that follow, the resources defaults look like this:

```yaml
resources:
  cpu:
    limits: 1000m
    requests: 100m
  memory:
    limits: 2Gi
    requests: 100Mi
  replicas: 1
```

### Add extra memory for a `frontend` service in all environments

In the following snippet, we set memory `limits` to 4Gi and `requests` to 500Mi:

```yaml
services:
- name: frontend
  image: releaseapp/spacedust/frontend
  command:
  - "./start.sh"
  registry: local
  ports:
  - type: node_port
    target_port: '4000'
    port: '4000'
  memory:
    limits: 4Gi
    requests: 500Mi
  static: true
  build_command: GENERATE_SOURCEMAP=false yarn build
  build_base: frontend
  build_output_directory: build/
```

Now every environment will have a 4Gi memory limit and a 500Mi request value for each `frontend` instance. Every other service instance will have a 2Gi memory limit and 100Mi request value.

### Deploy two `backend` replicas in all environments

In the default environment configuration, override the default value for `replicas` in the `services` section for `backend`:

```yaml
services
- name: backend
  image: releaseapp/spacedust/backend
  command:
  - "./run-spacedust.sh"
  registry: local
  depends_on:
  - postgres
  - redis
  ports:
  - type: node_port
    target_port: '3000'
    port: '3000'
  replicas: 2
```

Now every environment we deploy based on our default environment configuration will deploy two instances of the `backend` service and one instance of each other service.

### Specify five `backend` replicas and ten `frontend` replicas in our production environment

In order to override resource defaults for our production environment, we need to create a production space and modify the [environment-specific configuration](/reference-documentation/environment-settings/environment-configuration.md).

Here's how we would set the number of replicas for `frontend` and `backend`:

```yaml
services:
- name: frontend
  image: releaseapp/spacedust/frontend
  command:
  - "./start.sh"
  registry: local
  ports:
  - type: node_port
    target_port: '4000'
    port: '4000'
  replicas: 10
  memory:
    limits: 4Gi
    requests: 500Mi
  static: true
  build_command: GENERATE_SOURCEMAP=false yarn build
  build_base: frontend
  build_output_directory: build/
- name: backend
  image: releaseapp/spacedust/backend
  command:
  - "./run-spacedust.sh"
  registry: local
  depends_on:
  - postgres
  - redis
  ports:
  - type: node_port
    target_port: '3000'
    port: '3000'
  replicas: 5
```

By overriding the defaults for replicas in the environment-specific configuration, your production environment will deploy with ten `frontend` and five `backend` instances running in the cluster. These changes are specific to your production environment, so other environments will not be affected.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.release.com/reference-documentation/reference-examples/managing-service-resources.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
