# Session disruption when downscaling ECS Fargate tasks

**URL:** <https://community.livekit.io/t/session-disruption-when-downscaling-ecs-fargate-tasks/147>\
**Category:** Agents\
**Tags:** agent-deployment\
**Created:** [January 21, 2026, 1:34pm UTC](https://community.livekit.io/t/session-disruption-when-downscaling-ecs-fargate-tasks/147 "2026-01-21T13:34:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![LiveKit-Community](https://sea1.discourse-cdn.com/flex001/user_avatar/community.livekit.io/livekit-community/32/67_2.png) [@LiveKit-Community](https://community.livekit.io/u/LiveKit-Community)\
**Post date:** [January 21, 2026, 1:34pm UTC](https://community.livekit.io/t/session-disruption-when-downscaling-ecs-fargate-tasks/147/1 "2026-01-21T13:34:37Z")

</div>

_This question originally came up in our Slack community and the thread has been consolidated here for long-term reference._

I’m self-hosting LiveKit agents on AWS ECS Fargate. Everything works except that when tasks are downscaling, some active sessions get disrupted.

What’s the recommended workaround for this? Should I switch to ECS with EC2 launch type?

---

<div class="post-metadata">

**Author:** ![LiveKit-Community](https://sea1.discourse-cdn.com/flex001/user_avatar/community.livekit.io/livekit-community/32/67_2.png) [@LiveKit-Community](https://community.livekit.io/u/LiveKit-Community)\
**Post date:** [January 21, 2026, 1:34pm UTC](https://community.livekit.io/t/session-disruption-when-downscaling-ecs-fargate-tasks/147/2 "2026-01-21T13:34:40Z")

</div>

**Fargate is not recommended** for LiveKit agents because ECS Fargate has a hard shutdown limit of 120 seconds. Sessions longer than 2 minutes can be terminated abruptly.

**Solution:** Use ECS with EC2 launch type instead.

For EC2 launch type, configure the drain timeout:

1. Set `drain_timeout` in your worker configuration: [Server options | LiveKit Documentation](https://docs.livekit.io/agents/server/options/#drain-timeout)
2. Set `stopTimeout` in your ECS task definition to be larger than the drain\_timeout

This allows active sessions to complete before the instance terminates.

See this KB article for additional tips on AWS deployments:

> **[Troubleshooting Latency and Timeout Errors with Turn Detection on AWS](https://kb.livekit.io/articles/6481005689-troubleshooting-latency-and-timeout-errors-with-turn-detection-on-aws)**
>
> If your agent is experiencing severe latency or timeout errors (e.g., TimeoutError in \_bounce\_eou\_task) even though CPU and memory usage appear
