Capacity Planning for Elasticsearch Clusters: Sizing for Today, Growing for Tomorrow
A deep, plain-English guide to working out how many nodes, how much disk, memory and CPU, and how many shards your Elasticsearch cluster really needs, and how to keep that answer correct as your data and traffic grow.
Picture a busy restaurant kitchen. If the owner buys too few stoves, the Saturday night rush turns into burned dinners and angry customers. If the owner buys fifty stoves for a quiet neighborhood cafe, the money is wasted and the electricity bill is painful. Smart owners look at how many guests come, what they order, how fast the cooks work, and what happens when a stove breaks, and then they buy just enough with a little room to spare. Capacity planning for Elasticsearch is the same craft: deciding how much hardware and how much structure your search cluster needs so it stays fast on the busiest day, survives a failure, and does not burn money on idle machines.
1What Capacity Planning Is and Why It Matters
Before touching a calculator, we need a clear idea of what we are actually trying to predict.
A simple definition
Capacity planning is the practice of estimating the resources a system needs to meet its goals, and then arranging those resources so the system keeps meeting the goals as demand changes. For Elasticsearch, the resources are disk space, memory, processor time, disk speed and network bandwidth. The goals are usually expressed as promises: searches finish within a certain time, new data becomes searchable within a certain delay, and the cluster stays available even when a machine fails.
Notice that capacity planning is not a one-time purchase decision. It is a loop. You estimate, you build, you measure, you learn where the estimate was wrong, and you adjust. The best teams treat their first estimate as a hypothesis and their production metrics as the experiment.
Capacity planning is like planning a road. You study how many cars will come at rush hour, not the average hour, and how the traffic will grow over the next years. You add lanes before the jam appears, and you keep a spare lane open for accidents. Building for the average is the classic mistake, because users feel the peak, not the average.
Why Elasticsearch needs its own careful planning
Elasticsearch is not a simple storage box. It is a distributed engine that builds many small search structures, keeps copies for safety, merges data in the background, and caches heavily in memory. This creates several surprises for newcomers.
Data grows on the way in
The space a document takes on disk can be smaller or larger than its raw size, depending on how you index it, and replicas multiply it again.
Structure has a cost
Every shard, even an empty one, consumes memory and coordination effort, so the number of shards matters as much as their size.
Memory is two things
The Java heap and the operating system file cache both matter, and they compete for the same physical RAM.
Workloads differ wildly
A log analytics cluster and a product search cluster can hold the same data volume and need completely different hardware.
What goes wrong without a plan
Under-provisioned clusters show symptoms that look like software bugs: slow searches, rejected write requests, nodes leaving the cluster, and shards refusing to allocate because disks are nearly full. Over-provisioned clusters hide their problem in the invoice. Both are avoidable, and both are far more expensive to fix in an emergency than in a calm planning session.
flowchart LR
A["Understand workload and goals"] --> B["Estimate storage, memory, CPU, IO"]
B --> C["Design shards, nodes and tiers"]
C --> D["Benchmark with realistic data"]
D --> E["Deploy with headroom"]
E --> F["Monitor real usage"]
F --> G["Adjust and re-plan"]
G --> A
Many people believe there is a magic formula that outputs the perfect cluster. There is not. Formulas give a starting point within a range, and only testing with your real documents and real queries narrows it down. Any guide that promises exact numbers without knowing your data is guessing.
2Foundations You Need Before Sizing Anything
A short refresher on the words we will use in every later chapter.
Cluster
A group of nodes that work together and share one view of the data and its structure.
Node
One running Elasticsearch process on one machine or container. It may have one or several roles.
Index
A named collection of documents, like a labeled filing cabinet.
Primary shard
One slice of an index that owns a portion of the documents. The count is set when the index is created.
Replica shard
A full copy of a primary shard kept on a different node for safety and extra read capacity.
Segment
An immutable chunk of data inside a shard. Background merging combines many small segments into fewer large ones.
Heap
The memory the Elasticsearch Java process manages for itself, holding caches, buffers and structures.
Page cache
Free memory the operating system uses to keep recently read file data close to the processor.
Data tier
A group of nodes with a similar hardware profile for data of a similar age or importance: hot, warm, cold or frozen.
Watermark
A disk usage threshold at which Elasticsearch starts to protect a node by refusing new shards or blocking writes.
The write path in one picture
When a document is indexed, it does not go straight into a finished file. It is first sent to the primary shard, written to a transaction log for safety and buffered in memory, and after a short refresh interval it becomes visible to searches as a new small segment. The primary then forwards the operation to its replicas. Understanding this path explains why writes cost CPU, memory and disk speed all at once.
sequenceDiagram
participant C as Client
participant N as Coordinating node
participant P as Primary shard
participant R as Replica shard
C->>N: Bulk request
N->>P: Route documents to primary
P->>P: Buffer and write transaction log
P->>R: Forward operation
R->>R: Buffer and write transaction log
R-->>P: Acknowledge
P-->>N: Acknowledge
N-->>C: Response
Imagine a note-taker in a meeting who writes minutes on scrap paper first, then later copies them into a neat binder. The scrap paper is the transaction log and buffer, the neat binder is the segment. A backup note-taker in another room copies everything too, which is your replica. Twice the note-takers means twice the pens and twice the paper.
Whenever you hear “add a replica”, think “double the write work and double the storage, in exchange for safety and read capacity”. Capacity planning is full of these trades.
3The Four Resources That Run Out
Every capacity problem is ultimately one of these four wells running dry.
Storage: how much data must live here
Total disk space needed for primaries, replicas, and working room. It is the easiest resource to estimate and the one that most clearly determines your node count for large datasets.
Memory: how much can be kept close
Heap for Elasticsearch itself, and file cache for the operating system. Search speed depends heavily on how much of your frequently used data stays in the file cache.
CPU: how much thinking can be done
Processor capacity for parsing documents, building segments, merging, running queries and computing aggregations. Both indexing and searching consume it, and they compete.
Disk and network speed: how fast data can move
Disk throughput and latency, and network bandwidth between nodes and to clients. Replication, recovery and searches that touch many shards all lean on these.
Think of a warehouse. Storage is the floor space, memory is the workbench near the door where the most requested boxes are kept, CPU is the number of workers, and disk and network are the width of the doors and roads. A warehouse can have lots of floor space and still jam because the doors are too narrow.
The bottleneck rule
A cluster is only as capable as its scarcest resource. When you size by storage alone, you often discover that memory or CPU is the real limit. When you size by CPU alone, you discover a full disk. A good plan calculates each of the four separately, and then takes the largest resulting node count as the answer.
| Workload | Usual first bottleneck | Why |
|---|---|---|
| Log and event analytics | Storage and indexing throughput | Huge write volume, long retention, simple queries |
| Product or site search | Memory and CPU for queries | Moderate data, high query rates, strict latency |
| Metrics and time series | Storage and shard count | Many small data points and many series |
| Analytics dashboards with aggregations | Heap and CPU | Large aggregations consume memory and processing |
| Mixed platform workloads | Whichever tenant is heaviest | Competing demands on shared resources |
Write down which resource you expect to bind first for your workload before you calculate anything. If the calculation later disagrees with your expectation, that mismatch is valuable information rather than a nuisance.
4Know Your Workload First
Hardware answers come from workload questions. Ask the questions before you shop.
Three broad workload families
Time-based data
Logs, metrics, events and security data arrive continuously, are rarely updated, and age out. Capacity is driven by daily volume multiplied by retention.
Search-centric data
Catalogs, documents and content have a relatively stable size, are updated in place, and serve interactive search. Capacity is driven by query rate and latency goals.
Analytics-centric data
Dashboards and reports run heavy aggregations across large volumes. Capacity is driven by memory and processing for aggregations.
The workload questionnaire
Before sizing, gather the following facts, even if some are only rough estimates. For each one, note how sure you are, because uncertain inputs deserve wider safety margins.
How much data, and how fast does it grow?
Current raw size, daily or monthly new volume, and the growth trend over the coming one to three years. Include the busiest periods, not just averages.
How long must data be kept, and how quickly must it be searchable?
Retention periods by data type, and what search speed is acceptable for older data. This drives how much can sit on cheaper tiers.
What is the write pattern?
Documents per second, average and peak document size, whether writes come in bulk batches or singly, and how often existing documents are updated.
What is the query pattern?
Queries per second at peak, the mix of simple filters versus full text versus aggregations, the time ranges searched, and how many concurrent users there are.
What are the service level goals?
Target latency for percentiles, the maximum acceptable delay before new data is searchable, and the availability promise. Numbers here turn opinions into requirements.
What failures must you survive?
One node, one rack, one availability zone? Each answer changes how much spare capacity you must hold.
A tailor cannot cut cloth without measurements. Guessing a person’s size might work for a scarf, but not for a suit. Your workload questionnaire is the measuring tape.
Averages hide peaks. If a batch job floods the cluster with writes every night, or a report is run by hundreds of people at nine in the morning, the peak defines the capacity you need. Always ask when the busiest hour is and how much busier than average it gets.
5Storage Sizing Step by Step
Storage is the most concrete calculation, so it is the natural place to begin.
From raw data to disk space
The disk footprint of your data is built up in stages. Each stage changes the number, and forgetting any one of them is the most common reason clusters run out of space early.
flowchart LR
A["Raw data per day"] --> B["Indexed size: raw times expansion factor"]
B --> C["Add replicas: multiply by copies"]
C --> D["Multiply by retention days"]
D --> E["Add growth allowance"]
E --> F["Divide by target disk utilization"]
F --> G["Total disk to provision"]
Stage by stage
Measure the raw volume
Determine how much source data arrives per day or per month, in the format it is sent, before Elasticsearch touches it.
Apply the expansion factor
The indexed size is raw size multiplied by a factor that depends on your mappings. Storing the original source, building inverted indexes for text, keeping columnar doc values for sorting and aggregations, and indexing many fields can all enlarge data. Compression and lean mappings can shrink it. Real measurements are commonly anywhere from about half to somewhat above the raw size, so you must test with a sample of your own documents rather than assume.
Multiply by copies
With one replica, every primary has one copy, so total space is twice the primary size. Two replicas triple it.
Multiply by retention and growth
Multiply by the number of days you must hold hot data, then add an allowance for growth over the planning horizon, for example one year of expected increase.
Reserve working room
Never plan to fill disks. Elasticsearch has watermarks: by default it stops assigning new shards to a node at eighty-five percent used, tries to move shards away at ninety percent, and makes indices read-only at ninety-five percent. Merges, reindexing and shard relocation also need temporary extra space. Planning to run at roughly seventy to seventy-five percent leaves a healthy buffer.
Packing a suitcase for a trip works the same way. You count the clothes, add a spare set in case of spills, add souvenirs you will buy, and then choose a suitcase that closes without you sitting on it. A suitcase packed to the very edge is one souvenir away from failure.
Things that quietly consume extra space
Deleted and updated documents
Updates and deletes leave old versions in place until segments merge, temporarily using additional space.
Merge working space
Merging writes a new segment before removing the old ones, so a shard can briefly need extra room.
Transaction logs
Write-ahead logs occupy disk until data is safely flushed, growing under heavy indexing.
Snapshots
Backups live in a repository, often outside the cluster, but their size must still be planned for.
Reindexing headroom
Changing mappings or shard counts usually means writing a second copy of an index before deleting the first.
Index a representative sample, such as a day or a few gigabytes of your real data, using your real mappings. Then compare the on-disk size of the resulting index with the raw sample. This single experiment is more reliable than any rule of thumb you will read online.
6Shard Strategy: Size, Count and Growth
Shards are the unit of scale in Elasticsearch, so shard planning is capacity planning.
Why shard size matters
Every shard is a self-contained search engine, and the cluster moves, recovers and balances shards as whole units. Very small shards waste memory and coordination effort because each carries fixed overhead. Very large shards are slow to recover after a failure, slow to move between nodes, and can concentrate load on one machine. A commonly cited healthy range is roughly ten to fifty gigabytes per shard, with the exact sweet spot depending on your workload and version. Always compare against the current official guidance, since recommendations have evolved.
Shards are moving boxes. Thousands of tiny boxes take forever to load and label. A few enormous boxes are too heavy to carry and may not fit through the door. Medium boxes are just right, easy to carry, easy to stack, and easy to redistribute among movers.
Why shard count matters
The shard count multiplies costs across the cluster. Each shard uses heap for its metadata and file handles, adds entries to the cluster state that every node holds, and adds work for every search that touches it. Elasticsearch has a default guardrail limiting shards per data node to one thousand, and an older rule of thumb suggested keeping shards per gigabyte of heap low, such as around twenty. Treat these as warning signs rather than targets. A well-planned cluster sits far below them.
Choosing the number of primary shards
Start from the size of the data an index will hold and divide by the target shard size. For a time-based index that rolls over daily, use the expected daily indexed volume. For a fixed catalog index, use its total indexed size plus growth. Then check two more things. There should be enough primaries to spread indexing load across your data nodes, and not so many that each search fans out to a crowd of tiny shards.
| Situation | Shard approach | Reason |
|---|---|---|
| Small index, under a few gigabytes | One primary shard | Avoids overhead, still plenty of speed |
| Daily logs of hundreds of gigabytes | Several primaries per day, or rollover by size | Spreads write load and keeps shards in range |
| Large search index with heavy queries | Enough primaries to parallelize, plus replicas for throughput | Queries run in parallel across shards |
| Many small tenants | Shared indices or one shard per tenant index | Prevents shard count explosion |
Rollover and lifecycle: keeping shards healthy automatically
For growing data, rollover creates a new index when the current one reaches a size, age or document count. Combined with lifecycle policies, it keeps shards in the target range without manual work and makes retention a simple matter of deleting whole old indices. Data streams package this pattern for time-based data and are the modern default for logs and metrics.
Leaving default shard settings on every index without thinking. Daily indices for tiny data sets, each with several shards, is the fastest way to end up with thousands of nearly empty shards and a cluster that spends its energy on bookkeeping.
You cannot casually change the primary shard count of an existing index. Split and shrink operations exist, and reindexing always works, but each is a deliberate operation. Choose the initial count with future growth in mind.
7Memory: Heap, Page Cache and Ratios
Memory is where Elasticsearch performance is often won or lost.
Two memory pools, one machine
On each data node, physical memory is shared between the Java heap and the operating system file cache. The heap holds cluster metadata, shard structures, caches, aggregation buffers and request working space. The file cache holds recently read pieces of your index files, so repeated searches read from fast memory instead of slower disk.
The widely followed guidance is to give the heap no more than about half of the machine’s RAM and to keep it below the size at which the Java virtual machine loses an efficient pointer optimization, roughly thirty gigabytes. The remaining memory is deliberately left to the operating system, because that is what makes searches fast.
Imagine a chef with a small prep table and a large pantry down the hall. The prep table is the heap, where active work happens. The pantry shelf nearest the door is the file cache, holding the ingredients used most often. If you make the prep table enormous, you have no room left for the nearby pantry, and the chef walks to a distant warehouse for every ingredient.
What consumes heap
Shard overhead
Each open shard holds structures in memory, so shard count directly pushes heap use up.
Cluster state
Every node stores the indices, mappings and routing metadata for the whole cluster.
Aggregations and sorting
Large aggregations over many distinct values need substantial working memory.
Indexing buffers and caches
Bulk indexing, request caches and query caches all take a share.
Memory-to-data ratios
A useful planning aid is the ratio of memory to the data a node holds. Older Elastic guidance cited approximate ratios such as one gigabyte of RAM per thirty gigabytes of data for hot data, around one to one hundred sixty for warm data, and much lower still for cold data. Newer features such as searchable snapshots on the frozen tier change these numbers dramatically. Use ratios only as a first pass, then validate through benchmarking, because your query patterns decide how much of your data must stay in cache.
| Tier | Data temperature | Memory expectation | Typical storage |
|---|---|---|---|
| Hot | Newest, written and searched constantly | Generous RAM relative to data | Fast local SSD or NVMe |
| Warm | Older, searched occasionally, no new writes | Moderate RAM relative to data | Larger, cheaper SSD |
| Cold | Rarely searched | Low RAM relative to data | Dense storage, sometimes backed by snapshots |
| Frozen | Very rarely searched, kept for compliance or history | Very low, uses a cache over snapshot storage | Object storage plus a local cache |
For search-heavy workloads, the goal is often to fit the frequently accessed portion of the index into the file cache. If your hottest data is one hundred gigabytes, machines with far less spare RAM than that will keep reading from disk, and latency will show it.
Do not raise the heap to solve every problem. A bigger heap means longer garbage collection pauses and less file cache. If heap pressure is high, first look for too many shards, oversized aggregations or a wasteful mapping.
8CPU, Thread Pools and the Write Path
Processor capacity decides how much work the cluster can do at the same moment.
What uses CPU
Elasticsearch spends processor time on parsing and analyzing incoming documents, building and merging segments, executing queries, scoring results, and computing aggregations. Indexing is generally processor hungry because text must be broken into terms and structures must be built. Searching is processor hungry when queries are complex, touch many shards, or run heavy aggregations.
Thread pools: the cluster’s work queues
Each node handles work through named pools of threads, with separate pools for searching, writing, and other tasks. The number of threads is tied to the number of processor cores, and each pool has a bounded queue. When work arrives faster than the pool can process it, the queue fills, and once it is full new requests are rejected. Rejections are Elasticsearch’s way of saying “I am at capacity, slow down”, and a steady stream of them is a clear scaling signal.
Think of a bank with a fixed number of tellers and a waiting area with a fixed number of chairs. When customers arrive faster than tellers can serve them, the chairs fill up, and the door guard starts turning people away. Adding chairs does not help if the real problem is not enough tellers.
Estimating CPU for search
A useful mental model is to count shard-level requests. A query that touches ten shards creates ten small pieces of work. If your cluster serves a certain number of queries per second, and each touches a certain number of shards, the total shard-requests per second is the product. Benchmarking tells you how many shard-requests per second one core or one node can sustain at your latency target, and that number converts directly into a node count.
| Lever | Effect on search CPU | Trade-off |
|---|---|---|
| Fewer shards per query | Lowers fan-out work | Less parallelism per query |
| Routing to relevant shards | Skips unneeded shards | Requires a routing key in your design |
| Simpler queries and filters | Cheaper per request | May limit product features |
| Caching frequent filters | Reuses work | Uses memory |
| More replicas | Spreads queries across more copies | More storage and write work |
Estimating CPU for indexing
Indexing capacity depends on document size, number of fields, analysis complexity, ingest pipelines and the replica count. Because every replica repeats the indexing work, doubling the replicas roughly doubles the total processing for writes. The most reliable method is to load a realistic sample into a test cluster, measure documents per second per node, and scale from there.
Use bulk requests of sensible size
Sending documents in batches, commonly starting around a few megabytes per request and tuning from there, is far cheaper than one document per request.
Keep mappings lean
Index only the fields you search on. Disable indexing or doc values for fields you will never query or aggregate.
Relax the refresh interval when you can
By default, new data becomes searchable after about a second. If a delay of several seconds is acceptable, fewer refreshes mean fewer tiny segments and less merge work.
Do heavy initial loads with fewer replicas
For a one-time bulk load, you can load with zero replicas and add them afterward, avoiding duplicate indexing work during the load.
Move heavy transformation elsewhere if needed
Ingest pipelines run on ingest-capable nodes and consume CPU. Complex parsing may deserve dedicated ingest nodes or upstream processing.
Searching and indexing share the same processors. A cluster that is comfortable with only searches may struggle when a large import starts. Test the combined load, not each in isolation.
9Disk and Network Performance
Capacity is not just how much can be stored, but how quickly it can be moved.
Choosing disk types
Because searches read many small pieces of files at random, disk latency matters a great deal. Solid-state drives and NVMe drives are the standard choice for hot data because they handle random reads and heavy writes gracefully. Spinning disks can be acceptable for older, rarely searched data where slower reads are tolerable, but they make merges and recoveries much slower.
| Storage type | Strength | Weakness | Good fit |
|---|---|---|---|
| Local NVMe | Very fast, low latency | Tied to the machine, higher cost per terabyte | Hot tier, heavy indexing |
| Local SSD | Fast, dependable | Moderate cost | Hot and warm tiers |
| Network attached block storage | Flexible sizing, easy resizing | Variable latency, throughput limits per volume | Warm tier, cloud deployments |
| Spinning disks | Cheapest per terabyte | Slow random access | Cold data, low query rates |
| Object storage with cache | Very cheap, huge capacity | Slower first access | Frozen tier, searchable snapshots |
A fast sports car and a slow truck can carry the same amount of luggage in one trip, but the sports car finishes many more trips in a day. Disk speed is about how many trips per second, not how large the trunk is. Elasticsearch makes lots of small trips.
Disk redundancy and layout
Because Elasticsearch already keeps replicas of every shard on other nodes, you do not necessarily need expensive redundancy inside each machine. Many teams stripe multiple local drives together for speed, accepting that losing a drive means the node recovers from replicas. This is a design decision to make consciously, weighing recovery time against hardware cost.
Network: the quiet consumer
Network capacity is used by client traffic, replication, search fan-out and result merging, shard recovery and rebalancing, and snapshots. For most moderate clusters, a fast local network is plentiful. But large clusters with heavy indexing, or clusters that must recover several terabytes after a failure, can be limited by network speed. When replicas live in different availability zones, traffic crosses zone boundaries, which can be both slower and, in cloud environments, chargeable.
Replication
Every indexed byte is sent to each replica, so heavy ingest multiplies network load.
Recovery
When a node fails, its shards are rebuilt on other nodes by copying data over the network, which can take hours for large nodes.
Search fan-out
Queries reach many shards, and their partial results are sent back and merged, especially costly for large result sets.
Snapshots
Backups transfer data to a repository and can compete with production traffic if unthrottled.
A node with twenty terabytes of data sounds economical, but if it fails, rebuilding that much data may take a long time and leave the cluster running without safety copies. Plan node size with recovery time in mind, and remember recovery speed is deliberately throttled to protect normal traffic.
10Node Roles and Cluster Topology
Not every node needs to do every job, and separating roles is a capacity tool.
Master-eligible
Manages the cluster state: creating indices, tracking shards, deciding allocation. Needs stability more than size.
Data nodes
Hold shards and do the heavy work of indexing and searching. Can be split by tier: hot, warm, cold, frozen.
Coordinating nodes
Receive client requests, fan them out, and merge results, with no data of their own. Useful for heavy aggregations.
Ingest nodes
Run pipelines that parse and enrich documents before indexing, taking that work off the data nodes.
Machine learning and transform nodes
Handle specialized jobs that can be resource intensive and are best isolated from core search.
The master node rule
For production, use three dedicated master-eligible nodes, an odd number so the cluster can always form a majority to elect a leader and avoid a split brain, where two halves both believe they are in charge. Dedicated masters do not need much disk or a large heap for most clusters, but they need reliability and reasonably fast processors. Very large clusters with huge cluster states may need stronger masters.
Masters are the air traffic controllers, data nodes are the planes and pilots doing the flying, and coordinating nodes are the check-in desks. You would not ask a controller to also fly a plane, because a busy plane could distract them at the exact moment the whole airport needs them.
flowchart TD
CL["Clients and applications"] --> CO["Coordinating nodes"]
CL --> IN["Ingest nodes"]
CO --> H["Hot data nodes"]
IN --> H
H --> W["Warm data nodes"]
W --> C["Cold and frozen nodes"]
M["Three dedicated master nodes"] -. "manage cluster state" .-> H
M -. "manage cluster state" .-> W
M -. "manage cluster state" .-> C
When to keep it simple
Very small clusters often combine roles on the same nodes to save cost. That is acceptable, but as soon as the cluster carries important or heavy workloads, dedicated masters are one of the cheapest and most effective reliability upgrades. Coordinating nodes are worth adding when dashboards run large aggregations or when the number of shards per query is high, because merging results consumes heap that you would rather not take from data nodes.
Advantages of dedicated roles
- Stability: heavy queries cannot starve cluster management
- Right-sized hardware for each job
- Easier to scale one bottleneck without buying everything
- Clearer troubleshooting when something is slow
Costs and trade-offs
- More machines to run and monitor
- Extra network hops for requests
- Overkill for tiny development clusters
11Data Tiers and Lifecycle as Capacity Tools
The cheapest terabyte is the one you store on the right kind of machine.
Most time-based data is very valuable when it is fresh and much less valuable as it ages. Index lifecycle management lets you encode this fact as a policy that moves data automatically from expensive fast hardware to cheap slower hardware, and eventually deletes it. Done well, this can cut hardware costs dramatically without hurting the searches people actually run.
flowchart LR
A["Hot: new data, fast disks"] -->|"After rollover or a few days"| B["Warm: older data, cheaper disks"]
B -->|"After weeks"| C["Cold: rarely searched"]
C -->|"After months"| D["Frozen: object storage plus cache"]
D -->|"At retention limit"| E["Delete"]
What each phase can do for capacity
Hot phase: absorb writes and serve fresh searches
Uses rollover to keep shard sizes in range. Sized for peak write and query load.
Warm phase: shrink and compact
Once writes stop, indices can be made read-only, shrunk to fewer shards, and force merged into fewer segments, reducing overhead and often improving query speed. Replica counts can also be reduced if safety allows.
Cold phase: lower cost per terabyte
Data moves to denser, cheaper nodes. With searchable snapshots, a single copy can be kept locally while the snapshot provides durability, cutting replica storage.
Frozen phase: store cheaply, search slowly
Data lives in object storage and is cached on demand. Searches are slower but storage cost drops sharply. Searchable snapshots are a paid-tier feature.
Delete phase: remove what is no longer needed
Deleting whole indices is fast and reclaims space immediately, unlike deleting individual documents.
Consider a library. New bestsellers stay on the front tables where everyone can grab them. Older books move to the regular shelves, then to the basement archive, and finally to an off-site warehouse you must request. Nobody pays front-table rent for books that are read once a year.
Capacity effects to remember
Designing tiers around storage cost alone. If users regularly run wide time-range dashboards that reach into cold or frozen data, those searches become slow and frustrating. Tier by how data is actually searched, and confirm with real query logs.
12Worked Example: Sizing a Logging Cluster
Let us walk through a complete, illustrative calculation from start to finish.
Every number in this chapter is a made-up example to teach the method. Your expansion factor, hardware and query load will differ. Use the steps, not the answers.
The scenario
A company collects application and infrastructure logs. About three hundred gigabytes of raw logs arrive per day. Logs must be searchable for thirty days: the newest seven days on fast hot nodes and the following twenty-three days on cheaper warm nodes. They want one replica for safety, expect twenty percent growth over the coming year, and want to survive the loss of any single node.
Step 1: storage
| Step | Calculation | Result |
|---|---|---|
| Expansion factor from a sample test | Measured on-disk size divided by raw size | About 1.1 |
| Indexed primary data per day | 300 GB times 1.1 | 330 GB |
| With one replica | 330 GB times 2 | 660 GB per day |
| Hot tier, 7 days | 660 GB times 7 | 4.62 TB |
| Warm tier, 23 days | 660 GB times 23 | 15.18 TB |
| Add 20 percent growth | Hot 4.62 times 1.2, warm 15.18 times 1.2 | Hot 5.5 TB, warm 18.2 TB |
| Plan for 70 percent disk use | Divide by 0.7 | Hot about 7.9 TB, warm about 26 TB |
Step 2: turn storage into nodes
Suppose each hot node offers two terabytes of usable fast storage. Seven point nine terabytes divided by two is about four nodes. Suppose each warm node offers eight terabytes. Twenty-six divided by eight is about three and a quarter, so four nodes. Now add one spare node in each tier so the loss of a machine does not push the survivors past their watermarks, giving five hot nodes and five warm nodes.
Step 3: check throughput
Three hundred gigabytes per day is about three and a half megabytes per second on average, or, if each log line is around one kilobyte, roughly thirty-five hundred events per second. Assuming the peak is about three times the average, plan for roughly ten thousand events per second. Spread across five hot nodes with one replica, that workload is modest for modern hardware, but you must confirm it in a benchmark, because parsing, mappings and pipelines can change the answer.
Step 4: check shards
Indexed primary data is 330 gigabytes per day. Aiming for a shard size around forty gigabytes suggests about eight primary shards per day. With one replica that is sixteen shard copies per day, and over thirty days about four hundred eighty shards across ten data nodes, or about forty-eight per node. That is comfortably far below the default guardrail, leaving room to grow.
Step 5: check memory
If each hot node has sixty-four gigabytes of RAM with a heap around thirty gigabytes, the remaining memory serves the file cache. Two terabytes of data on a sixty-four gigabyte node is roughly one gigabyte of memory per thirty-one gigabytes of data, consistent with older hot-tier guidance. A warm node with the same memory and eight terabytes is about one to one hundred twenty-five, which is acceptable for less frequently queried data but should be tested against real dashboards.
Step 6: add the supporting cast
Add three dedicated master nodes with modest resources. Add two coordinating nodes to absorb dashboard fan-out and result merging. If ingest pipelines are heavy, add ingest nodes or move the parsing upstream.
| Component | Count | Notes |
|---|---|---|
| Hot data nodes | 5 | Fast local storage, about 64 GB RAM each in this example |
| Warm data nodes | 5 | Larger, cheaper storage |
| Dedicated master nodes | 3 | Small but reliable |
| Coordinating nodes | 2 | For aggregation-heavy dashboards |
| Approximate total | 15 | Before any benchmark-driven adjustments |
This is like planning a school bus service. You count children, decide seats per bus, add spare buses for breakdowns, and confirm that the roads can handle the traffic. The count is a starting point, and the first week of real driving tells you which routes need adjusting.
This plan is only a hypothesis. Before buying hardware, run a benchmark with real logs and real dashboard queries, and adjust node counts, shard counts and heap settings according to what you observe.
13Sizing Search-Heavy Workloads
When users type into a search box and expect instant answers, the sizing questions change.
What is different
Search-centric workloads such as product catalogs, document search or site search typically hold a stable, moderate amount of data but face demanding latency goals and bursts of traffic. Storage is rarely the constraint. Instead, the questions become: can the important data stay in memory, can we handle peak queries per second, and how do we keep response times steady under load?
Working set in cache
The fraction of the index that is read frequently should fit in the operating system file cache for the best latency.
Peak queries per second
Seasonal spikes such as sales events define capacity, not the quiet Tuesday average.
Latency percentiles
The slowest few percent of requests are what users complain about, so size for tail latency and not just the average.
Query complexity
Faceted navigation, suggestions, fuzzy matching and scripts can multiply cost per request.
Scaling reads with replicas
For search workloads, replicas are not only for safety, they add read capacity. Each complete set of shards can answer queries independently, so adding a replica gives the cluster another full copy to spread load across. This scales throughput almost linearly at first, then gives diminishing returns as other limits, such as the coordinating node or the network, appear.
A popular shop can add checkout counters, and each extra counter serves more customers at once. But if there is only one door, adding more counters eventually does nothing, because customers cannot enter fast enough.
An illustrative sizing method
Measure one full copy
Build the index on a small test cluster with one complete copy of all primary shards, replay realistic queries, and find the highest query rate that still meets your latency goal. Suppose it is four hundred queries per second.
Apply peak and headroom
If the expected peak is fifteen hundred queries per second and you want fifty percent headroom, the target is twenty-two hundred fifty.
Compute copies
Twenty-two hundred fifty divided by four hundred is about five and a half, so six full copies: one primary set plus five replica sets.
Check the memory and storage consequences
Six copies of a two hundred gigabyte index is one point two terabytes of total storage and, more importantly, enough memory across the nodes to keep each copy’s hot data cached.
Validate under real conditions
Test again with the full cluster, including background indexing, to confirm that the measured capacity matches the plan.
If your traffic is highly seasonal, consider a plan that can add temporary replicas or nodes ahead of known peaks and remove them afterward, rather than paying for peak capacity all year.
14Benchmarking and Load Testing
A benchmark turns your estimate into evidence.
Why benchmarking is non-negotiable
Two clusters with identical hardware can behave very differently depending on the documents, mappings and queries they handle. Generic published numbers do not know your data. Benchmarking with your own documents and queries is the only way to learn your real expansion factor, indexing throughput, and query capacity.
flowchart TD
A["Define goals: throughput, latency, retention"] --> B["Prepare realistic data and queries"]
B --> C["Test one node and one shard"]
C --> D["Scale up load until latency goal breaks"]
D --> E["Record the knee point and resource use"]
E --> F["Extrapolate to full cluster size"]
F --> G["Test the full cluster including failures"]
G --> H{"Meets goals?"}
H -->|"No"| I["Adjust design and repeat"]
I --> C
H -->|"Yes"| J["Approve capacity plan"]
The single-shard method
A classic technique is to test the smallest meaningful unit first. Create an index with a single primary shard and no replicas on a single node, load realistic data, and measure how much it can index and how fast it can search. Push the load until latency starts to rise sharply, and note where that happens. That point, sometimes called the knee of the curve, is the shard’s practical capacity. Scaling to the full cluster then becomes a matter of multiplying by the number of shards and nodes, with adjustments for coordination and replicas.
Before ordering a fleet of delivery vans, you test one van on a real route to learn how many parcels it can deliver per hour. Then you multiply. You would not guess from the van’s brochure.
What a good benchmark includes
Representative data
Real or realistically generated documents with the same size, fields and distribution as production.
Realistic queries
Query mixes taken from production logs, including the expensive ones, not only easy examples.
Production-like settings
Same mappings, replica counts, refresh interval, hardware class and version as the intended system.
Mixed load
Searches and indexing at the same time, because that is how production behaves.
Failure scenarios
Take down a node during the test to see how recovery affects latency.
Long enough duration
Run long enough to include merges, cache warm-up and garbage collection cycles.
Tools and metrics
Elastic provides a benchmarking tool called Rally, designed for exactly this purpose, and many teams also use general load testing tools to replay their own query traffic. Whichever tool you use, capture throughput, latency percentiles such as the median, ninety-fifth and ninety-ninth, error and rejection counts, CPU use, heap use and garbage collection behavior, disk read and write rates, and network traffic.
Testing with a tiny dataset that fits entirely in cache, using overly simple queries, running for only a few minutes, or testing on a cluster with no background activity all produce flattering numbers that production will not match. Make the test uncomfortable on purpose.
15Resilience Headroom: Planning for Failure
A cluster that only works when nothing breaks is not really sized, it is merely lucky.
Failure is a capacity event
When a node disappears, its shards must be served from other copies and, over time, rebuilt elsewhere. The surviving nodes suddenly carry more data and more traffic than before. If they were already near their limits, the failure of one machine can trigger a chain reaction: survivors hit their disk watermarks, shards cannot be reallocated, and the cluster stays in a degraded state. Capacity planning must therefore include the extra load that comes after a failure.
Think of a lifeboat. It is not enough that it holds everyone in calm weather. It must still float when a few passengers shift to one side. The spare room in a lifeboat is not wasted space, it is the reason the boat is trusted.
The simple arithmetic of survivors
If a tier has a number of equal nodes and one fails, the survivors share its data, so each carries the original amount multiplied by the total node count divided by the survivors. With four nodes at seventy percent full, losing one leaves three nodes at about ninety-three percent, beyond the default high watermark. With five nodes at about fifty-five percent full, as in the worked example of Chapter 12, losing one leaves four nodes at about sixty-nine percent, which is healthy. This is exactly why the spare node in that plan matters.
| Nodes in tier | Normal disk use | Use after one node fails | Verdict |
|---|---|---|---|
| 4 | 70 percent | About 93 percent | Dangerous, above watermarks |
| 5 | 55 percent | About 69 percent | Healthy |
| 10 | 70 percent | About 78 percent | Acceptable |
Surviving a whole zone
Many production clusters spread nodes across availability zones, using shard allocation awareness so that a primary and its replica never share a zone. Losing an entire zone is a much larger event than losing one node. With three zones, the two survivors must absorb the third’s data, raising their load by half. To stay under the default low disk watermark after such a loss, the normal utilization should be under roughly fifty-six percent. With two zones the survivor must hold everything, so normal utilization must be under about forty-two percent if you want full redundancy to be restored in a single zone.
flowchart LR
subgraph Z1["Zone A"]
A1["Primary shards set 1"]
A2["Replica shards set 3"]
end
subgraph Z2["Zone B"]
B1["Primary shards set 2"]
B2["Replica shards set 1"]
end
subgraph Z3["Zone C"]
C1["Primary shards set 3"]
C2["Replica shards set 2"]
end
Z3 -. "Zone C lost: replicas promoted, shards rebuilt in A and B" .-> Z1
Z3 -. "Survivors take about 50 percent more data each" .-> Z2
You do not always need to restore full redundancy during an outage. Some teams accept running with fewer copies for a few hours and size for that. Others insist on full copies. Decide deliberately, write it down, and size to it.
Recovery speed and its limits
Elasticsearch throttles shard recovery so that it does not overwhelm normal traffic. That protects users but lengthens the time you spend without full redundancy. Recovery time is roughly the amount of data to rebuild divided by the effective recovery rate, so smaller nodes and faster networks recover sooner. Include this in your risk assessment: the larger each node, the longer the exposure window after a failure.
Decide the failure you must survive
One node, one rack, or one zone. This sets the size of your spare capacity.
Calculate post-failure utilization
Disk, heap, CPU and network for the surviving nodes, not just normal operation.
Configure allocation awareness
Make sure copies of the same shard are placed in different zones or racks.
Rehearse
Deliberately stop a node in a test environment and watch how long recovery takes and how latency behaves.
16Monitoring Signals and Scaling Triggers
Capacity planning does not end at launch. Production tells you how right you were.
The vital signs
| Signal | What it means | Typical warning sign |
|---|---|---|
| Disk usage per node | Distance to watermarks | Sustained use approaching your planning target |
| Heap used after garbage collection | Real memory pressure | Steadily climbing baseline, frequent long collections |
| CPU utilization | Processing headroom | Sustained high use, especially during peaks |
| Thread pool rejections | Work being turned away | Any sustained rejections in write or search pools |
| Search latency percentiles | User experience | Tail latency drifting up while averages look fine |
| Indexing latency and lag | Delay before data is searchable | Growing gap between arrival and visibility |
| Merge activity and throttling | Disk and CPU pressure from writes | Merges falling behind |
| Shard count and cluster state size | Structural load | Rising shard count per node, slow cluster state updates |
| Circuit breaker trips | Requests too heavy for memory | Any repeated trips |
| Recovery duration | Failure exposure window | Longer recoveries as data grows |
A car dashboard shows speed, fuel, engine temperature and warning lights. You do not wait for the engine to fail. You notice the temperature creeping up and act. These metrics are your cluster’s dashboard.
Watch trends, not just thresholds
A disk that is at sixty percent is fine today, but if it was at fifty percent last month and forty percent the month before, you will hit trouble in a predictable number of weeks. Track growth rates and project them forward. Set alerts that fire early, with enough lead time for procurement, approvals and change windows, not alerts that fire when the fire has started.
Turning signals into decisions
Disk trending toward the target
Add data nodes, move data to a colder tier sooner, reduce retention, cut replicas on old data, or improve compression.
Heap baseline rising
Reduce shard count, fix heavy aggregations, remove unused fields, or add nodes to spread shards. Avoid simply enlarging the heap.
Write rejections during peaks
Add indexing capacity, smooth ingestion with a queue upstream, tune bulk sizes and refresh intervals, or lighten pipelines.
Search latency tails growing
Add replicas, improve caching by adding memory, simplify expensive queries, or reduce shards touched per query.
Hold a short capacity review on a regular schedule, such as monthly or quarterly. Compare actual growth with the plan, update the forecast, and decide whether to order capacity now or later. Small regular reviews prevent large emergency purchases.
17Scaling Strategies and Cost Optimization
When the plan says you need more, there are several ways to get it, and some cost far less than buying hardware.
Vertical or horizontal
Scaling out: more nodes
- Adds capacity and resilience together
- Spreads shards and load across more machines
- Works well with small, uniform nodes
- Elasticsearch rebalances shards automatically
Scaling up: bigger nodes
- Fewer machines to manage
- Heap has practical limits, so extra RAM mainly helps file cache
- Larger nodes mean longer recovery after a failure
- Bigger failure blast radius when one machine dies
Most teams favor scaling out with moderately sized nodes, because it improves resilience and recovery. Scaling up still makes sense to reach the right memory-to-data ratio or to add faster disks.
Before buying, try these levers
Trim the data
Remove fields nobody uses, disable indexing on fields that are only stored, and avoid indexing large blobs. Lean documents shrink storage, memory and CPU together.
Use stronger compression on older data
Elasticsearch offers a higher-compression storage codec that trades a little indexing and read speed for noticeably smaller indices, well suited to warm and cold data.
Compact old indices
Shrink them to fewer shards and force merge them into fewer segments once writes have stopped.
Tune replicas by data age
Very old data may not need the same number of copies as fresh data, especially if a snapshot provides durability.
Downsample metrics
Recent versions can reduce the resolution of old time series data, keeping trends while shrinking storage significantly.
Use colder, cheaper tiers
Move data through warm, cold and frozen tiers according to how often it is really searched.
Automation and elasticity
Managed offerings and Kubernetes operators can scale certain tiers automatically based on storage and load signals, using Elasticsearch’s autoscaling capabilities. This helps with unpredictable growth but still relies on your having sensible limits and a sound shard design. Automation scales your mistakes as happily as your successes, so confirm the design first.
flowchart TD
A["Monitoring shows pressure"] --> B{"Which resource?"}
B -->|"Disk"| C["Tier data sooner, compress, trim retention, add data nodes"]
B -->|"Heap"| D["Cut shard count, fix heavy queries, add nodes"]
B -->|"CPU or rejections"| E["Tune bulk and pipelines, add nodes or replicas"]
B -->|"Search latency"| F["Add memory for cache, add replicas, simplify queries"]
C --> G["Re-benchmark and update the plan"]
D --> G
E --> G
F --> G
When you add nodes, Elasticsearch moves shards onto them, which uses network and disk. Adding capacity during a crisis can make the crisis worse for a while. Add capacity early, and throttle relocation when the cluster is under stress.
18Anti-Patterns and Best Practices
A short catalogue of the mistakes that show up again and again.
Problem
Sizing the cluster for the average day and ignoring peaks and growth.
Why It’s Harmful
Users experience the busiest hour. A cluster sized for the average will slow down or reject work exactly when it matters most.
Correct Approach
Measure peak rates, add a growth allowance, and keep meaningful headroom on every resource.
Problem
Creating thousands of tiny shards through default settings and daily indices for small data.
Why It’s Harmful
Each shard consumes heap, file handles and coordination effort. The cluster becomes slow and fragile without holding much data.
Correct Approach
Size shards into the healthy range, use rollover by size, and give small indices a single primary shard.
Problem
Giving the heap most or all of the machine’s memory, hoping it will make things faster.
Why It’s Harmful
It starves the file cache, lengthens garbage collection pauses, and can push the heap beyond the size where the Java virtual machine works efficiently.
Correct Approach
Keep the heap to about half of RAM and below roughly thirty gigabytes, and leave the rest for the operating system.
Problem
Running disks close to full to save money.
Why It’s Harmful
Watermarks trigger shard movement and then write blocks. Merges and recoveries need spare room. A single node failure can push survivors over the edge.
Correct Approach
Plan for roughly seventy percent utilization or lower, and lower still if you must survive a zone loss.
Problem
Copying a cluster design from a blog post or another company without testing it against your own data.
Why It’s Harmful
Data shape, mappings and queries differ enormously, so borrowed numbers may be wildly wrong in either direction.
Correct Approach
Use published guidance as a starting hypothesis and validate it through benchmarks with your own workload.
Problem
Ignoring the cost of a failure and sizing only for the healthy state.
Why It’s Harmful
The first hardware failure pushes the cluster into a degraded or unavailable state, turning a routine event into an incident.
Correct Approach
Size for the post-failure state, and rehearse failures before production depends on them.
Best practices at a glance
Do
- Gather workload facts and service goals before sizing
- Measure the expansion factor with your real data
- Target healthy shard sizes and modest shard counts
- Use dedicated masters and tiered data nodes
- Benchmark, then benchmark the failure case
- Review capacity on a regular cadence
Do Not
- Trust averages or generic numbers
- Fill disks or oversize the heap
- Create shards without a plan
- Wait for an incident to add capacity
- Change many things at once without measuring
19Real-World Scenarios
Five common situations, and how the ideas in this guide apply to each.
Centralized logging for a growing engineering organization
Data volume rises with every new service. The team uses data streams with rollover, hot and warm tiers, one replica, and a monthly capacity review that projects disk growth. A downsizing of retention for verbose debug logs buys months of runway before new nodes are needed.
E-commerce site search with holiday peaks
The catalog is modest in size, but traffic can rise many times during sales events. The team sizes for the seasonal peak using single-copy benchmarks, adds replicas ahead of the season, and removes them afterward. Latency percentiles, not averages, drive decisions.
Security analytics with long compliance retention
Regulations require a year or more of searchable history, but most searches touch only the last few days. Hot and warm tiers serve recent data, while cold and frozen tiers using searchable snapshots hold older data cheaply. Capacity planning focuses on how much data lives on each tier and how wide the typical time range is.
Multi-tenant software platform
Thousands of small customers and a few very large ones share the platform. The team plans capacity around shard count and cluster state size for the long tail, and around dedicated indices or nodes for the giants, watching per-tenant usage to decide when to move a tenant.
Metrics and observability with many time series
Millions of small data points arrive every minute. Shard count and cardinality drive memory, so the team uses purpose-built time series storage, downsampling for older data, and careful limits on the number of distinct series.
A repeatable planning routine
Collect goals and workload facts
Volume, growth, retention, write and query patterns, latency targets and failure tolerance.
Estimate each resource separately
Storage, memory, processing and input and output. Take the largest resulting node count.
Design shards, tiers and roles
Choose shard sizes and counts, tier boundaries, dedicated masters and coordinating nodes.
Add headroom for peaks, growth and failure
Apply utilization targets and size for the post-failure state.
Benchmark and adjust
Validate with real data, real queries, mixed load and failure tests.
Monitor and re-plan
Compare reality with the plan regularly and update the forecast.
20Frequently Asked Questions
There are formulas for each resource, such as storage from volume, expansion, replicas, retention and utilization. But the inputs, especially the expansion factor and query capacity, must come from testing your own data, so treat formulas as a first estimate.
A commonly cited range is roughly ten to fifty gigabytes, but the best value depends on your workload and version. Aim for shards large enough to avoid overhead and small enough to move and recover quickly, and check current official guidance.
There is a default limit of one thousand per data node, but healthy clusters usually run far below it. Heap use, cluster state size and recovery time are better guides than the limit itself.
About half of the machine’s memory, and no more than roughly thirty gigabytes. The rest should remain available to the operating system for the file cache.
At least one for most production data, so a node failure does not lose data. Add more when you need extra read capacity or greater fault tolerance, remembering each replica multiplies storage and write work.
Indexing builds search structures and stores extra representations of fields, which can enlarge data, while compression can shrink it. The result depends on your mappings, so measure with a real sample.
For production clusters, yes, three of them is the standard recommendation. They protect cluster management from being starved by heavy data node workloads. Very small development clusters can combine roles.
Before you reach your limits. Set alerts on trends in disk, heap, rejections and latency so that you have lead time, and remember that rebalancing itself takes time and resources.
Many moderately sized nodes usually improve resilience and shorten recovery, while very large nodes concentrate risk and slow recovery. The right balance depends on your memory-to-data needs and operational overhead.
Size to the measured peak with headroom, use replicas to add read capacity, buffer writes upstream, and consider temporary scaling ahead of known events.
No. Autoscaling reacts to signals, but it depends on a sound shard design, sensible limits and a budget. Planning tells you what the system should look like, and automation helps it get there.
Yes. Managed services handle machines and upgrades, but you still choose data volumes, tiers, shard design and retention, which determine performance and cost. The concepts in this guide carry over directly.
21Summary and Key Takeaways
Capacity planning for Elasticsearch is the art of matching hardware and structure to a real workload, with enough room for peaks, growth and failure. It starts by understanding your data volume, retention, write and query patterns, and service goals. It continues by estimating storage, memory, processing and input and output separately, and taking the largest node count as the answer. It shapes shards into healthy sizes, separates node roles, and uses data tiers so that cheap hardware holds cold data. It is confirmed through benchmarks with real data and real queries, including failure tests. And it never really ends, because monitoring and regular reviews keep the plan honest as your system changes. Build the plan, test it, and keep correcting it.
Key Takeaways
- Start with the workload — data volume, growth, retention, write and query patterns and service goals determine everything else.
- Size each resource separately — storage, memory, CPU and input and output each give a node count, and the largest one wins.
- Measure, do not assume — index a real sample to learn your expansion factor, and benchmark real queries to learn your true capacity.
- Shape shards deliberately — aim for healthy shard sizes and modest shard counts, using rollover and lifecycle policies to maintain them.
- Balance heap and file cache — keep the heap to about half of RAM and under roughly thirty gigabytes, leaving the rest for the operating system.
- Plan for failure and headroom — size for the post-failure state, keep disks well below watermarks, and rehearse node and zone losses.
- Keep planning after launch — monitor trends, alert early, use tiers and compression to stretch capacity, and review the plan regularly.