# Rolling indexes or \_ttl

**URL:** <https://discuss.elastic.co/t/rolling-indexes-or--ttl/9259>\
**Category:** Elasticsearch\
**Created:** [October 6, 2012, 9:17pm UTC](https://discuss.elastic.co/t/rolling-indexes-or--ttl/9259 "2012-10-06T21:17:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ashish\_Nigam\_3](https://avatars.discourse-cdn.com/v4/letter/a/f19dbf/32.png) [@Ashish\_Nigam\_3](https://discuss.elastic.co/u/Ashish_Nigam_3)\
**Post date:** [October 6, 2012, 9:17pm UTC](https://discuss.elastic.co/t/rolling-indexes-or--ttl/9259/1 "2012-10-06T21:17:09Z")

</div>

Hi,  
I am working on a multi-tenant application. I have to create separate  
indexes for each tenant. And I need to maintain data for 3 months in index.

I think there are two ways to implement this requirement.

1. Use \_ttl to auto delete data from index. This would mean creating just  
one index for a tenant with 4 shards and 4 replicas.
2. Create index for each month. This would mean that I will have to create  
at least 4 indexes per tenant so that I cover 3 months index requirement.  
Then I will maintain one index alias that would allow me to search across  
all 4 indexes. In this strategy, I would only insert data only in present  
month index. At the end of the month, I will create new index for next  
month and delete oldest index. If I implement rolling indexes, I am  
thinking to create indexes with just one shard and one replica.

Which strategy is better in this case, \_ttl or rolling indexes?  
If rolling index is preferable, it would be good to know disadvantages of  
using \_ttl strategy.

Thanks  
Ashish

--

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [October 6, 2012, 9:45pm UTC](https://discuss.elastic.co/t/rolling-indexes-or--ttl/9259/2 "2012-10-06T21:45:48Z")

</div>

I prefer 2/

Drop an index is "removing" index dir which is quick and you release space.  
Using TTL is like deleting docs one by one. That means, creating a new version of the document which is empty. But it takes some space.

When ES optimize the index, deleted documents will be removed. Space will be released. You can call optimize API yourself.

So, IMHO, 2/ is the more efficient way to do it.

HTH

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 6 oct. 2012 à 23:17, Ashish Nigam [ashnigamtech@gmail.com](mailto:ashnigamtech@gmail.com) a écrit :

> Hi,  
> I am working on a multi-tenant application. I have to create separate indexes for each tenant. And I need to maintain data for 3 months in index.
> 
> I think there are two ways to implement this requirement.
> 
> 1. Use \_ttl to auto delete data from index. This would mean creating just one index for a tenant with 4 shards and 4 replicas.
> 2. Create index for each month. This would mean that I will have to create at least 4 indexes per tenant so that I cover 3 months index requirement. Then I will maintain one index alias that would allow me to search across all 4 indexes. In this strategy, I would only insert data only in present month index. At the end of the month, I will create new index for next month and delete oldest index. If I implement rolling indexes, I am thinking to create indexes with just one shard and one replica.
> 
> Which strategy is better in this case, \_ttl or rolling indexes?  
> If rolling index is preferable, it would be good to know disadvantages of using \_ttl strategy.
> 
> ## Thanks Ashish

--

---

<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:** [July 6, 2017, 3:09am UTC](https://discuss.elastic.co/t/rolling-indexes-or--ttl/9259/3 "2017-07-06T03:09:52Z")

</div>


