Microservices are often presented as the default for serious applications. In practice they solve specific problems, mostly about teams and independent scaling, and they add operational work of their own. This article walks through when to split a Node.js application, and how to run the resulting services on AWS so they stay reliable under load.

Start with a modular monolith

Most products should begin as one deployable application with clear internal modules: users, billing, orders, notifications. Each module owns its own data access and talks to others through defined functions, not by reaching into each other's tables.

This gives you most of the benefits of separation (clear ownership, easier testing) without network calls, distributed failures or multiple deployments.

When splitting makes sense

Consider extracting a service when one or more of these is true:

  • Different scaling needs. Image processing or report generation needs far more CPU than the rest of the app.
  • Different release cadence. One team ships several times a day, another monthly, and they keep blocking each other.
  • Fault isolation. A crash in a non-critical feature should not take down checkout.
  • Team size. Several teams working in one codebase spend more time coordinating than building.

Extract one service at a time, starting with the module that has the clearest boundary.

Containers on ECS with Fargate

Package each service as a Docker image and run it on Amazon ECS with the Fargate launch type, which runs containers without you managing servers.

  • An Application Load Balancer routes requests by path or host to the right service and checks each container's health endpoint.
  • Service auto scaling with target tracking adds or removes tasks to keep a metric, such as average CPU or requests per target, near a value you choose.
  • Spread tasks across at least two Availability Zones so one data centre problem does not take you offline.

Keep services stateless

A task can be stopped and replaced at any time, so nothing important should live only in its memory or disk:

  • Store sessions and short-lived data in Redis (Amazon ElastiCache).
  • Store uploaded files in Amazon S3, not on the container's file system.
  • Read configuration and secrets from environment variables, Parameter Store or Secrets Manager.

Choose how services talk

Synchronous calls (HTTP or gRPC) are simple when one service needs an answer right away. Add timeouts, limited retries with exponential backoff, and circuit breakers so one slow service does not make every caller slow.

Asynchronous messaging suits work that can happen in the background: sending email, updating search indexes, generating invoices. Use SQS queues for work items, SNS or EventBridge to broadcast events, and a dead-letter queue to catch messages that keep failing.

Make every handler idempotent: processing the same message twice must not charge a customer twice. Store a unique ID for each operation and skip ones you have already handled.

Give each service its own data

Shared databases quietly couple services back together. Each service should own its data store, whether that is RDS or Aurora for relational data or DynamoDB for high-throughput key-value access, and share data through APIs or events.

Node.js specifics that matter at scale

  • Never block the event loop. Heavy CPU work (image resizing, PDF generation, large JSON parsing) belongs in worker threads or a separate service.
  • Shut down gracefully. ECS sends SIGTERM before stopping a task and SIGKILL after a timeout (30 seconds by default). Stop accepting new requests, finish in-flight ones and close database connections in that window.
  • Pool connections. Reuse database connections and enable HTTP keep-alive for calls to other services.
  • Set memory limits deliberately. Match Node's heap size to the container's memory so the process is not killed unexpectedly.

Observability from day one

With several services, a single request crosses many logs. You need:

  • Structured JSON logs in CloudWatch, each with a correlation ID passed between services.
  • Metrics for request rate, error rate and latency per service.
  • Distributed tracing with OpenTelemetry or AWS X-Ray to see where time is spent.
  • Alerts on symptoms users feel, such as error rate and slow responses, rather than on every CPU spike.

Deploy safely

  • Define infrastructure as code with AWS CDK or Terraform, so environments are reproducible.
  • Run tests and build images in a CI/CD pipeline on every merge.
  • Use rolling or blue/green deployments with automatic rollback when health checks fail.
  • Put risky features behind feature flags so you can turn them off without a deploy.

Keep costs in check

  • Right-size task CPU and memory using real metrics.
  • Use Fargate Spot for background workers that can tolerate interruption.
  • Scale down non-production environments outside working hours.

Checklist

  • Is there a clear reason to split this module out?
  • Is the service stateless, with data in Redis, S3 or its own database?
  • Do calls between services have timeouts, retries and idempotency?
  • Does the service shut down cleanly on SIGTERM?
  • Can you trace one request across every service it touches?
  • Can you roll back a bad deploy in minutes?

Microservices pay off when they let teams and workloads scale independently. Built on these foundations, they can grow with your traffic instead of becoming the bottleneck.