アプリサーバー

コードを動かします。リクエストに応答し、データベースへクエリを投げます。

このページはまだ日本語に翻訳されていません。

The App Server stands for a virtual machine that runs your code.

When to place it#

  • Add a copy, or a size step, when its card shows CPU, workers, or memory near full and p99 climbs.

  • Put a Load Balancer in front before the second copy.

  • Fix the backends first when the limit is workers while CPU is low: the box is waiting on them. See Find the bottleneck.

How it works#

It answers page views and bots itself, and turns every other request kind into backend calls: read and write queries, auth calls, tasks, charges, and more. Its capacity depends on its instance type, its runtime, and its framework. The tightest of four limits sets it: CPU, worker slots, memory, and network.

A request holds its worker slot while it waits on each backend call. So a slow Database also lowers the capacity of runtimes that hold a worker while they wait. This is Little's law.

The Garage box runs Postgres on the same machine. When you link it to a Database, Connection Pooler, or Cache, Postgres moves off the box for good. A Burstable box earns CPU credits while idle and is throttled when they run out.

Options#

設定項目設定値表示条件
ランタイム28 種類のランタイム常時
フレームワーク30 種類のフレームワーク常時
プールサイズワーカー 1 つ以上プールありのランタイム
プロセスマネージャ静的 / 動的 / オンデマンドPHP-FPM
ワーカーの再起動オフ / 数時間ごと常駐するランタイム
圧縮オフ / Gzip圧縮の後
サービスすべてのサービスサービスが 2 つ以上
コレクタG1 / Parallel / ZGCJava
GOGC50 / 100 / 200Go GCチューニングの後
シェディング均等に落とす / 価値の低いものを落とす優先度付きロードシェディングの後
デグラデーション種別を保つ / 最も高いものを落とすグレースフルデグラデーションの後
自分の書き込みを読むどこでも読む / 自分の書き込みを読むread-your-writesルーティングの後
フィードプル / プッシュ開いたリージョンが 2 つ

Stack#

The Stack is the language, its runtime, and the framework. It sets how the box shares work, how fast each request runs, the memory each process holds, and whether the runtime can keep a connection open.

  • Runtime: the server that runs your code. Each one uses a model such as a process per request, a thread pool, or an event loop, and the model decides how a request waits on a backend. See Runtimes.

  • Framework: the library around the runtime. It adds CPU and memory to every request, and it buys velocity. The picker lists the frameworks for the runtime's language.

  • Pool size: how many worker processes serve requests. A request holds one slot while it waits on each backend call, so a slow Database fills the pool while CPU stays idle. The figure beside the control says how many workers the box's RAM fits. Go past it and the box swaps, then kills a process.

  • Process manager: PHP-FPM keeps a pool of worker processes, and the process manager decides which of them stay running. Static keeps the whole pool resident, so no request waits for a fork, and the box holds that memory even when idle. Dynamic keeps the busy workers plus two spares, so a burst makes a small share of requests wait a moment for a fork. On demand keeps only the busy workers, so idle RAM is lowest and more requests wait. Pick Static when RAM is spare, Dynamic for most Designs, and On demand when memory is the limit and the tail can wait.

  • Recycle workers: restarts each process now and then. It caps a memory leak before the process runs out, and every restart comes back cold. Turn it on for a runtime that keeps memory between requests.

  • Compression: Gzip on the responses that shrink well. It cuts their size, the egress they bill, and the time they take to reach a user, and it costs CPU on each one. Uploads and media do not shrink.

  • Service: which Service the Node belongs to. It appears once the app splits into more than one Service.

Garbage collection#

  • Collector: a Java runtime's garbage collector. G1 balances pause against throughput. Parallel is a little faster and pauses longer, with a little less memory. ZGC keeps pauses tiny at less throughput and more memory. Pick ZGC when a spike in p99 hurts more than CPU.

  • GOGC: a Go runtime's collection target. A lower value collects more often, so memory stays small and CPU goes to the collector. A higher value does the reverse. Go collects without a long pause either way.

Overload#

  • Shedding: Priority load shedding answers a full Node by dropping whole request kinds, lowest value first, until it is back under its line. The default, Drop evenly, refuses a share of every kind instead of whole kinds. The kinds it keeps stay fast, and the dropped ones count as errors.

  • Degradation: Graceful degradation drops the kinds that cost the most CPU first, so the cheap, high-volume kinds keep their latency. A Node with both settings on degrades first.

  • Read your writes: sends a read that follows a write to the primary, so a lagging replica cannot answer it with old data. See Read your writes.

Feeds#

  • Feeds: how the App Server serves a feed. Pull merges the accounts a user follows at read time. Push writes a copy into each follower's timeline. Push becomes the hybrid with Hybrid fan-out. See Fan-out on write and on read.

How it fails#

  • Overloaded, it queues requests, then drops them.

  • A box with too little RAM swaps, and a pool sized too big for its RAM is killed.

Instance failure#

  • Signs: The App Server's card goes grey, its Inspector reads "The host under this VM died. It still bills.", and the requests sent to it are stranded.

  • Do now: Press Replace in its Inspector and pay the price. It comes back cold.

  • Prevent: Run a second copy: Load balancing puts the copies behind a Load Balancer, and Health checks skip the dead host. A copy inside a Cluster is rescheduled by itself.

Zone outage#

  • Signs: Every Node in one zone goes grey at once.

  • Do now: Nothing brings the zone back sooner. Fail over promotes a Standby, and this Component keeps none, so it ends on its own after at most 120 s.

  • Prevent: Research Multiple zones, then put copies in different zones with the Zone setting.

Region outage#

  • Signs: Every Node in one region goes grey at once, and that region's board goes grey with them.

  • Do now: Press Fail over on the banner. It needs Multiple zones and a second open region, and starts the Node again in the nearest other region, cold, for the price of a replacement. Otherwise it comes back when the incident ends: 180 sim seconds in the catalog, 60 once the error budget counts.

  • Prevent: Research Multiple regions and GeoDNS, then run a copy of it in a second region.

Memory leak#

  • Signs: The card's Inspector reads "Memory grows: N GB leaked." Left alone, the process runs out of memory and restarts cold.

  • Do now: Press Restart in the Inspector. It frees the leaked memory and comes back cold.

  • Prevent: Turn on Recycle workers (periodic restarts), do the Fix memory leak task, or run a runtime that does not persist, such as PHP-FPM. Research Metrics and Alerting to see it sooner.

Event loop block#

  • Signs: p99 rises on every kind that service answers, because a CPU-heavy kind such as login holds the event loop.

  • Do now: Press Move login on the banner. It needs an API Gateway in front of an App Server on an event loop, and a Link from the Gateway to another App Server on a runtime without one: the Gateway then sends login there only, and the incident ends once no login reaches a loop. Without that, it ends on its own after at most 35 s.

  • Prevent: Research libuv thread pool and Managed identity, which move the heavy work off the loop.

GC pause storm#

  • Signs: p99 spikes while p50 stays normal, on a runtime with a garbage collector whose heap is above 90% of RAM.

  • Do now: Press Restart in the Inspector. A restart clears the heap.

  • Prevent: Give the box more RAM, switch Java to ZGC in the Collector section, or tune Go with Go GC tuning and the GOGC setting.

JVM warmup under load#

  • Signs: Copies an Autoscaler adds during a spike answer at the runtime's cold speed, and p99 gets worse for 30 s.

  • Do now: Press Drain on the cold copy. It needs Health checks and ends the incident when the Node is empty. Otherwise wait for the warmup.

  • Prevent: Turn on Slow start on the Load Balancer, research GraalVM native image, or scale on a schedule with Scheduled scaling.

Stale OPcache#

  • Signs: A busy PHP App Server with OPcache fails 30% of its requests, running the old code against the new schema.

  • Do now: Press Restart on the banner or in the Inspector. It resets the cache and ends the incident.

  • Prevent: Research Continuous delivery. A CI/CD Pipeline resets the cache on every deploy.

Library incompatibility#

  • Signs: A busy gevent App Server fails 15% of its requests.

  • Do now: Press Restart on the banner or in the Inspector. It ends the incident.

  • Prevent: Research Automated tests.

Runtime compatibility#

  • Signs: A busy Bun App Server fails 20% of its requests.

  • Do now: Press Restart on the banner or in the Inspector. It ends the incident.

  • Prevent: Research Automated tests.

Spot reclaim#

  • Signs: Its Inspector reads "The provider reclaims this Spot Node in N s. Replace it with on-demand." After 10 s the Node goes grey.

  • Do now: Press Switch to on-demand before the warning runs out. Otherwise it comes back by itself once the incident ends.

  • Prevent: Keep Nodes on the request path on On-demand or Reserved pricing, and use Spot only on a fleet that can lose a Node.

Bad deploy#

  • Signs: The error rate jumps right after a deploy, and a "Bad deploy" banner appears with a Roll back button.

  • Do now: Press Roll back on the banner. It needs Continuous delivery; without it the incident ends on its own after at most 120 s.

  • Prevent: Research Continuous delivery and Automated tests. A Canary deploy strategy and Feature Flags cap how much a bad deploy breaks.

Bad config push#

  • Signs: App Servers and Workers crash together, and a "Bad config push" banner appears with a Roll back button.

  • Do now: Press Roll back on the banner. They restart on the old config.

  • Prevent: Research GitOps and stage the rollout, so a push reaches one region first.

Connection exhaustion#

  • Signs: The Database's card reads "Refusing N queries/s: too many connections."

  • Do now: Nothing on the App Servers ends it; it ends on its own after at most 40 s. A Connection Pooler between the App Servers and the Database caps the connections it holds.

  • Prevent: Research Connection pooling and place a Connection Pooler in front of the Database.

Supply-chain compromise#

  • Signs: Users fall 10% at once as the reputation goes, and a "Supply-chain compromise" banner appears with a Pin and redeploy button.

  • Do now: Press Pin and redeploy on the banner.

  • Prevent: Research Dependency scanning or Deno. A Security team lowers the odds again.

Leap second or clock skew#

  • Signs: Every Node in the App Server's region answers 1,000 ms late, and 10% of its answers time out. A banner appears with a Restart Nodes button.

  • Do now: Press Restart Nodes on the banner. One click resyncs the whole region.

  • Prevent: Research Leap smearing.

Tips#

  • Match the instance family to the runtime: Compute for CPU-bound runtimes, Memory for many workers.

  • Restart a leaking server to free its memory. It comes back cold.

ルール#

  • 追加のコピーは 1 つ前より 25% 高くなります。
  • 売却すると、最後のコピーの価格の 50% が戻ります。
  • インスタンス種別がサイズと支出を決めます。サイズを 1 段上げるとリソースと支出が倍になります。
  • 新しいコピーはコールドスタートで、温まるまで遅いままです。

一緒に使えるもの#

データベース、ロードバランサー、コネクションプーラー、キャッシュ、ワーカー、サーバーレス関数、APIゲートウェイ、リアルタイムハブ、エッジ関数

セキュリティ#

これらの脆弱性がこのコンポーネントを狙います。猶予期間が終わる前にパッチを当てます。

  • CVE-2026-0451, CVSS 7.5
  • CVE-2026-0042, CVSS 5.3
  • CVE-2026-3141, CVSS 7.5
  • CVE-2026-1024, CVSS 9.9

エンジニアリング用語#