Your SaaS keeps going down: the first five things to check

When your app keeps crashing or timing out, check these five things first: memory, database connections, disk, deploys and dependencies.

The short answer

Check five things in this order: whether the server is out of memory or disk, whether the database is out of connections or stuck on a slow query, whether a recent deploy caused it, whether a third-party service is failing, and whether you even know when it is down. Most repeated outages come from one of these, and the logs from the failing minute show which.

On this page
  1. 1. Is the server running out of memory or disk?
  2. 2. Is the database the bottleneck?
  3. 3. Did a deploy cause it?
  4. 4. Is a third party failing?
  5. 5. Do you know when it is down?
  6. How do you find the cause from the logs?
  7. When is it not one of these?
  8. What should the written post-mortem contain?
  9. Working with us

An app that goes down once is an incident. An app that goes down every week is a pattern, and patterns have causes. Before anyone proposes a rewrite or a bigger server, check these five things. Each takes an hour or less.

1. Is the server running out of memory or disk?

The most common cause of a recurring crash is simple resource exhaustion.

  • Memory: a process grows until the operating system kills it. Look for out-of-memory kills in the system log and a memory graph that climbs until the crash. A memory leak looks like a sawtooth: grow, crash, restart, grow again.
  • Disk: logs, uploads or temporary files fill the disk. A full disk breaks databases in confusing ways, and a backup that fills the disk can take the app down with it.
  • CPU: one runaway request or job pegs the processor.

Fix: find what grows, cap it, and add an alert at 80 percent so you hear before the crash. Rotate logs and delete temporary files.

2. Is the database the bottleneck?

If pages hang rather than error, suspect the database.

  • Connection exhaustion: every request opens a connection, the database has a limit, and when it is reached everything waits. Use a connection pool and set sensible limits.
  • A slow query: one query that scans a whole table can lock up everything behind it. Turn on slow-query logging and look at the worst five.
  • Locks: a long transaction or a migration that holds a lock stops other queries.
  • Missing indexes: things that worked with a thousand rows crawl at a million.

Fix the worst query first, usually with an index or a rewritten query, and measure again.

3. Did a deploy cause it?

Line up the outage times with your deploy history. If failures start right after releases, look at:

  • Does a plain restart drop requests? Many deploys stop the old version before the new one is ready. We start the new copy, wait for its health check, then switch; see zero-downtime deploys with Docker Compose.
  • Do migrations lock tables or break the version still running? Changes must be expand and contract: add, backfill, switch, drop later.
  • Is there a mismatch between parts of the build? We once shipped a server with the front-end files of a different build, and pages never became interactive; see two builds in one Docker image.
  • Can you roll back in minutes?

4. Is a third party failing?

Payment providers, email services, maps and AI APIs fail. If your app waits for them without a time limit, their outage becomes yours.

  • Set timeouts on every outbound call.
  • Do slow work in a background job, not in the request.
  • Retry with backoff, and make retries safe by using idempotency keys.
  • Decide what the app does when a provider is down: queue, degrade or show a clear message.

Check your error tracker for outbound errors that cluster at the outage times.

5. Do you know when it is down?

If customers tell you before your monitoring does, fix that now. A monitor that runs on the same server as the app goes quiet with it, so run checks from outside; see uptime checks outside the server.

Have three kinds of checks:

  1. a ready endpoint that also checks the database;
  2. a short real flow with a test account (sign in, write, read back);
  3. heartbeats from scheduled jobs, so a job that never ran raises an alert.

Alert on the second failure in a row, not the first, to avoid waking someone for a deploy.

How do you find the cause from the logs?

For the next outage, collect, before restarting anything:

  • the time it started and ended;
  • memory, CPU, disk and database connection numbers at that minute;
  • the last errors in the app and database logs;
  • the deploys and config changes in the previous hour.

Restarting fixes the symptom and destroys the evidence. If you must restart, copy the logs first.

When is it not one of these?

If all five are clean, look at traffic patterns (a bot, a scheduled import, a marketing email that sends thousands of users to one page) and at single points of failure such as one server or one database with no failover. A single machine can fail by itself; see is your SaaS ready for a second server.

What should the written post-mortem contain?

Keep it short. The time line, with the time of detection and the time of recovery; the cause, and the evidence for it; what made it worse or better; and the actions, each with an owner and a date. Add one question: how did we find out? If the answer is “a customer wrote to us”, the monitoring action goes to the top of the list. Review the actions at the next outage, because a pattern of repeated causes shows which fix was skipped.

Working with us

If your app keeps going down and your team has run out of guesses, send us what you have: the symptoms, the stack, and any graphs. We find the cause from evidence, fix it, and put monitoring in place so the next one is caught early. Use contact, or see our work on SaaS platforms.

Keep reading

Tell us what you want to build.

A product, a website, a search problem or a system that should work better. We reply with a plain answer and the first step.

A few sentences are enough (at least 20 characters).

We use your details only to answer your inquiry. See our privacy policy.