AWS Fargate is slow when calling system commands. How do I debug it and what can be wrong?

co flag

I've been running my PoC on Fargate without many problems. It's a Micronaut Java app with not much happening on its own. I'm using the smallest 256mb/0.25CPU Fargate deployment.

I'm running a simple command from java code, prettier --version. Locally it takes less than a second, even when I'm running a container with 256mb/0.25CPU limits. On Fargate, though, it takes ridiculous 9-10 seconds. My container insights don't show anything that might explain this (screenshot).

The problem is in this specific command; If I run, for example, node --version, it's blazing fast. Prettier is a code formatter run by node.

What could cause this? It's hard to debug - since it's Fargate, I have no way to execute anything in a container without redeploying it. Logs are also not helpful. Is it somehow related to a thread spawned by Java?

My biggest question is why such a drastic difference between running locally and on ECS?

Tim avatar
gp flag
I would increase CPU to something like 4.0 temporarily and run the command again to see if that helps. Then try similar with RAM, and then together. If that helps then the problem is Fargate resources. If not I would wonder if there's some latency issue somewhere with a resource it needs.
cn flag
There's a lot of difference between running locally vs Fargate, and potentially even Fargate vs ECS on EC2. Fargate is basically a serverless service, so lots of allocation and magic is happening behind the scenes. Add a ton of logging, see if running the `prettier` command directly in a contianer is different to calling it from Java?

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.