# Storage on elastic search

**URL:** <https://discuss.elastic.co/t/storage-on-elastic-search/321996>\
**Category:** Elasticsearch\
**Created:** [December 26, 2022, 5:04pm UTC](https://discuss.elastic.co/t/storage-on-elastic-search/321996 "2022-12-26T17:04:28Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![mail2shanth](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mail2shanth/32/115463_2.png) [@mail2shanth](https://discuss.elastic.co/u/mail2shanth)\
**Post date:** [December 26, 2022, 5:04pm UTC](https://discuss.elastic.co/t/storage-on-elastic-search/321996/1 "2022-12-26T17:04:28Z")

</div>

Hi,

I am trying to build a benchmark on how much storage likely needed for Elasticsearch, below are some stats whenever I sent new records from logstash to Elasticsearch. I checked in Elasticsearch after every interval, (record or hits)

6 record - 11.4KB  
12 record - 22.4 KB  
18 - 33.4 KB  
24 records - 44 KB  
48 records - 66,9  
120 records - 92.9 KB

I don't see that it's exponentially increasing the storage for the records, how do I calculate if I need to send through 20B records?

Cheers,  
Shanth Kumar

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [December 26, 2022, 5:29pm UTC](https://discuss.elastic.co/t/storage-on-elastic-search/321996/2 "2022-12-26T17:29:14Z")

</div>

The storage required is not linear with the number of documents as the space efficiency of index data structures and compression improve with size for small data volumes, so you need to index a good amount of data before you can estimate the average size per document and extrapolate from there. I would recommend indexing a few million documents and use that to estimate average document size on disk.

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [December 26, 2022, 5:36pm UTC](https://discuss.elastic.co/t/storage-on-elastic-search/321996/3 "2022-12-26T17:36:59Z")

</div>

> [@Christian\_Dahlqvist](#):
>
> I would recommend indexing a few million documents and use that to estimate average document size on disk.

This ^^^ is the only way you will get a good estimate!

It can seem a bit weird at low volumes Elastic may not seem super efficient as it is setting up the base data structures etc..etc.... efficiencies are seen at scale.

You might also look at the How To section in the Docs... if [disk space is of most concern](https://www.elastic.co/guide/en/elasticsearch/reference/current/tune-for-disk-usage.html) or search speed there are ways to tune for each

---

<div class="post-metadata">

**Author:** ![mail2shanth](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mail2shanth/32/115463_2.png) [@mail2shanth](https://discuss.elastic.co/u/mail2shanth)\
**Post date:** [December 26, 2022, 6:02pm UTC](https://discuss.elastic.co/t/storage-on-elastic-search/321996/4 "2022-12-26T18:02:42Z")

</div>

Thank you @Christian_Dahlqvist and @stephenb!

I'll try to load a few millions before extrapolating it, considering I should load 20B records/documents per day.

Much appreciated!

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [December 26, 2022, 6:19pm UTC](https://discuss.elastic.co/t/storage-on-elastic-search/321996/5 "2022-12-26T18:19:27Z")

</div>

> [@mail2shanth](#):
>
> I should load 20B records/documents

That is a substantial volume!

Good luck! Come back and ask more questions...

---

<div class="post-metadata">

**Author:** ![mail2shanth](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mail2shanth/32/115463_2.png) [@mail2shanth](https://discuss.elastic.co/u/mail2shanth)\
**Post date:** [December 26, 2022, 7:14pm UTC](https://discuss.elastic.co/t/storage-on-elastic-search/321996/6 "2022-12-26T19:14:47Z")

</div>

Yes for sure it is!

It is 20B records/documents per day and approximately I need to store for a year. Not sure if elasticsearch would behave good with performance. I am doing a pre-study if it would work good.

I need to search on the timestamp to pick specific period data and on regex on the records.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [December 26, 2022, 7:20pm UTC](https://discuss.elastic.co/t/storage-on-elastic-search/321996/7 "2022-12-26T19:20:25Z")

</div>

> [@mail2shanth](#):
>
> I need to search on the timestamp to pick specific period data and on regex on the records.

If you need to search based on regexes, make sure you [consider the wildcard field type](https://www.elastic.co/guide/en/elasticsearch/reference/master/keyword.html#wildcard-field-type). It will likely take up more space but will likely speed up searches sigificantly as regex queries can be very, very expensive and slow. If you are going to use this, make sure you perform your storage test with this enabled for the required field(s).

> [@mail2shanth](#):
>
> It is 20B records/documents per day and approximately I need to store for a year.

Sounds like you will need a very large cluster, or possibly even a number of clusters.

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [December 26, 2022, 7:32pm UTC](https://discuss.elastic.co/t/storage-on-elastic-search/321996/8 "2022-12-26T19:32:56Z")

</div>

> [@mail2shanth](#):
>
> data and on regex on the records

Perhaps give some examples of what your searches look like..

Often folks use the term regex to mean different things...

There is also [match\_only\_text](https://www.elastic.co/guide/en/elasticsearch/reference/current/text.html#match-only-text-field-type) which is like full text search but optimized for logs / machine telemetry etc..

Elasticsearch can definitely handle that volume but the scale and speed is in the details at that scale.

We often see the scale you are talking to use several mid sized cluster with CCS cross cluster search, this architecture tends to provide a nice mix or manageability, scale , flexibility etc.

Also for that volume with long term retention... You would probably want to consider the searchable snapshot capabilities which could dramatically reduce your HW footprint and costs even though it requires a subscription which has costs.

The HW profiles and storage options and amount of storage all have considerations

Lots of things to consider... Let us know where we can help.

---

<div class="post-metadata">

**Author:** ![mail2shanth](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mail2shanth/32/115463_2.png) [@mail2shanth](https://discuss.elastic.co/u/mail2shanth)\
**Post date:** [December 26, 2022, 7:52pm UTC](https://discuss.elastic.co/t/storage-on-elastic-search/321996/9 "2022-12-26T19:52:56Z")

</div>

Sure, here is one of the document looks like, the output from logstash,

```auto

"hits": [
      {
        "_index": "test_index",
        "_id": "3Mb6ToUBRI9FrpjDjVXu",
        "_score": 1,
        "_source": {
          "host": "100.62.161.11",
          "nodeName": "AA-AMGU",
          "log": {
            "file": {
              "path": "/Users/.../Work/Projects/ELK/Logstash/Input/sample.txt"
            }
          },
          "event": {},
          "@timestamp": "2022-12-01T13:30:00.004Z",
          "type": "data",
          "record": "AA-AMGU AA SA 2022 Dec 1 14:29:59:87 CET 17 4001 10.XX.133.XX 56560 401 91.235.10.25 15179 2400160261XXXXX_467000XXXX1_35292011220XXXXX_string1 "
        }
      },
      {
        "_index": "test_index",
        "_id": "3cb6ToUBRI9

```

In the "record" there is an IP address (10.XX.133.XX) and a value (56560) that I want to query and based on timestamp. There could be multiple such records on an IP address and ports.  
I was planning to use the timestamp to query for records in specific period and use the regex to search for the IP Address and Port. Is there any better way to arrange fields and search for those?  
Is it better to split fields in the record and have them as separate fields?

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [December 26, 2022, 8:17pm UTC](https://discuss.elastic.co/t/storage-on-elastic-search/321996/10 "2022-12-26T20:17:11Z")

</div>

It is generally always better to parse out this data into specific fields that are indexed and can be searched much more efficiently than using regular expressions.

---

<div class="post-metadata">

**Author:** ![mail2shanth](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mail2shanth/32/115463_2.png) [@mail2shanth](https://discuss.elastic.co/u/mail2shanth)\
**Post date:** [December 26, 2022, 8:41pm UTC](https://discuss.elastic.co/t/storage-on-elastic-search/321996/11 "2022-12-26T20:41:30Z")

</div>

> [@stephenb](#):
>
> Also for that volume with long term retention... You would probably want to consider the searchable snapshot capabilities which could dramatically reduce your HW footprint and costs even though it requires a subscription.

Thanks! Ya subscription is fine of course.

Have another question, I read in other blogs that Elasticsearch shouldn’t be used as primary database instead should be a solution to bridge between logstash and other reliable databases. Is that a misconception? Is it ok to keep such huge data in Elasticsearch and rely on it?

---

<div class="post-metadata">

**Author:** ![mail2shanth](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mail2shanth/32/115463_2.png) [@mail2shanth](https://discuss.elastic.co/u/mail2shanth)\
**Post date:** [December 26, 2022, 8:44pm UTC](https://discuss.elastic.co/t/storage-on-elastic-search/321996/12 "2022-12-26T20:44:04Z")

</div>

> [@Christian\_Dahlqvist](#):
>
> is generally always better to parse out this data into specific fields that are indexed and can be searched much more efficiently than using regular expressions.

Thanks. Will explore more on logstash. So it’s well formatted for searches before sending to Elasticsearch.  
Much appreciated for such quick responses and support. I feel ELK is the solution for our current need!

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [December 26, 2022, 8:46pm UTC](https://discuss.elastic.co/t/storage-on-elastic-search/321996/13 "2022-12-26T20:46:40Z")

</div>

There has been a lot of improvements to resiliency and scalability over the last few years, so I know of a lot of use cases that use Elasticsearch as the primary data store, especially around logging and metrics. Naturally you should in this case treat it as a primary data store and ensure you have replica shards configured, the cluster set up properly and make sure you regularly take backups using the snapshot API, like you would with any other primary database.

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [December 26, 2022, 11:44pm UTC](https://discuss.elastic.co/t/storage-on-elastic-search/321996/14 "2022-12-26T23:44:30Z")

</div>

> [@mail2shanth](#):
>
> Have another question, I read in other blogs that Elasticsearch shouldn’t be used as primary database

That's a big question that will take some investigation and specific use case.

Very clear. One use case is to put elastic as a read-only search layer on top of your RDBMSs to isolate them from high volume, search loads and really quite honestly to protect them or protect you from having to scale many many RDBMSs that's one use case

We are seeing more and customers /use case where they are treating elastic as a primary data store. There are some misconceptions about that and there has been and continuing work on the resiliency and the atomicity of elasticsearch.

One thing for sure that elasticsearch does not support natively is multi-document transactions with rollback. I would even add though for some of those use cases. Some of the things that cause rollback don't exist in elastic....

So it really boil down to what your specific use case is.

Oh and I fixed a typo above. I meant to say the searchable snapshots which is commercial feature. Could actually save you overall. TCO even though the elasticsearch subscription has a cost....

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [January 23, 2023, 11:44pm UTC](https://discuss.elastic.co/t/storage-on-elastic-search/321996/15 "2023-01-23T23:44:59Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
