---
name: codeengine-ts-app-notscaledown
title: Why aren't my app instances scaling down as expected?
description: When traffic to your application slows down such that your app begins to scale down, you observe that instances do not go away.
last-updated: 2023-08-22
---

> ## Documentation Index
> The table of contents for this documentation set is at https://cloud.ibm.com/docs/codeengine?format=markdown
> The index for all IBM Cloud docs is at: https://cloud.ibm.com/docs/llms.txt
> Use these files to discover more information as needed.

# Why aren't my app instances scaling down as expected?
{: #ts-app-domain-notscaledown}
{: troubleshoot}

When traffic to your application slows down such that your app begins to scale down, you observe that instances do not go away. 
{: tsSymptoms}

When the incoming workload is slows to your application, Code Engine starts to automatically scale down an application based on its configured scaling values. Code Engine sends a SIGTERM message to your application. Your code must react to this signal and shut down. If your code does not do handle the SIGTERM message, your application instances remain in `Terminating` status during the configured request time out value (default: 300 seconds). 
{: tsCauses}


Try one of these solutions. 
{: tsResolve}

* Review the documentation about how scaling works. See [Configuring application scaling](https://cloud.ibm.com/docs/codeengine?topic=codeengine-app-scale&format=markdown).

* Review the values configured for autoscaling for your application. 
    * From the console, go to the page for your application. The autoscaling settings are on the **Configuration > Runtime** tab.
    * With the CLI, run the [**`ibmcloud ce app get`**](https://cloud.ibm.com/docs/codeengine?topic=codeengine-cli&format=markdown#cli-application-get) command to display details of your app. 

* Ensure that your code handles SIGTERM messages. For applications to scale down cleanly, your application code must handle a SIGTERM signal. When Code Engine automatically scales down, a SIGTERM signal is sent to your application. 

    The following code example handles a SIGTERM message because it closes the connection to the HTTP server that was started by the app after the app receives a signal that the instance ends.

    ```javascript
    const server = // start the HTTP server

    process.on('SIGTERM', () => {
      console.info('SIGTERM signal received.');
      server.close(() => {
        console.log('Http server closed.');
      });
    });
    ```
    {: codeblock}


* Review the details of your app instances to help you troubleshoot your app. See [Getting details about app instances](https://cloud.ibm.com/docs/codeengine?topic=codeengine-troubleshoot-apps&format=markdown#ts-app-instancedetails).