# Multi-tenancy performance

**URL:** https://discuss.elastic.co/t/multi-tenancy-performance/3732
**Category:** Elasticsearch
**Created:** [January 3, 2011, 6:43pm UTC](https://discuss.elastic.co/t/multi-tenancy-performance/3732 "2011-01-03T18:43:24Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![recht](https://avatars.discourse-cdn.com/v4/letter/r/13edae/32.png) [@recht](https://discuss.elastic.co/u/recht)
#### Post date: [January 3, 2011, 6:43pm UTC](https://discuss.elastic.co/t/multi-tenancy-performance/3732/1 "2011-01-03T18:43:24Z")

</div>

Hi

It seems that performance degrades pretty quickly when adding indexes,  
although the twitter example would suggest that it's possible to  
create a large number of indexes. Is there any way of speeding up  
multiple indexes, or is this not recommended for per-user indexes  
(we're talking millions of users)? After 400 indexes, it takes about 4  
seconds to create a new index.

Kind regards,  
Joakim

---

<div class="post-metadata">

### Author: ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)
#### Post date: [January 4, 2011, 4:40pm UTC](https://discuss.elastic.co/t/multi-tenancy-performance/3732/2 "2011-01-04T16:40:18Z")

</div>

An index comes with an overhead when you create it. Actually, the main  
overhead is a shard, and by default, an index is created with 5 shards with  
1 replicas. Each shard is a lucene index, which does come with its own  
overhead in terms of memory requirements and os resources (mainly file  
handles).

Talking about millions of users, I would suggest against creating an index  
per user.

-shay.banon

On Mon, Jan 3, 2011 at 8:43 PM, recht [jrecht@gmail.com](mailto:jrecht@gmail.com) wrote:

> Hi
> 
> It seems that performance degrades pretty quickly when adding indexes,  
> although the twitter example would suggest that it's possible to  
> create a large number of indexes. Is there any way of speeding up  
> multiple indexes, or is this not recommended for per-user indexes  
> (we're talking millions of users)? After 400 indexes, it takes about 4  
> seconds to create a new index.
> 
> Kind regards,  
> Joakim

---

<div class="post-metadata">

### Author: ![Rich\_Kroll](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rich_kroll/32/3229_2.png) [@Rich\_Kroll](https://discuss.elastic.co/u/Rich_Kroll)
#### Post date: [January 4, 2011, 4:44pm UTC](https://discuss.elastic.co/t/multi-tenancy-performance/3732/3 "2011-01-04T16:44:28Z")

</div>

Shay,  
Are there any guidelines you can give (recommended upper limit) to number of  
indexes per cluster?

- Rich Kroll

On Tue, Jan 4, 2011 at 11:40 AM, Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)wrote:

> An index comes with an overhead when you create it. Actually, the main  
> overhead is a shard, and by default, an index is created with 5 shards with  
> 1 replicas. Each shard is a lucene index, which does come with its own  
> overhead in terms of memory requirements and os resources (mainly file  
> handles).
> 
> Talking about millions of users, I would suggest against creating an index  
> per user.
> 
> -shay.banon
> 
> On Mon, Jan 3, 2011 at 8:43 PM, recht [jrecht@gmail.com](mailto:jrecht@gmail.com) wrote:
> 
> > Hi
> > 
> > It seems that performance degrades pretty quickly when adding indexes,  
> > although the twitter example would suggest that it's possible to  
> > create a large number of indexes. Is there any way of speeding up  
> > multiple indexes, or is this not recommended for per-user indexes  
> > (we're talking millions of users)? After 400 indexes, it takes about 4  
> > seconds to create a new index.
> > 
> > Kind regards,  
> > Joakim

--  
“We can't solve problems by using the same kind of thinking we used when we  
created them.” ~ Albert Einstein

---

<div class="post-metadata">

### Author: ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)
#### Post date: [January 4, 2011, 4:46pm UTC](https://discuss.elastic.co/t/multi-tenancy-performance/3732/4 "2011-01-04T16:46:19Z")

</div>

It really depends on the hardware you have, memory allocate to ES process.  
Maybe other people can give explicit examples with some numbers, but I  
suggest you do a quick capacity tests with what you have,  
and extrapolate based on that.

On Tue, Jan 4, 2011 at 6:44 PM, Rich Kroll [kroll.rich@gmail.com](mailto:kroll.rich@gmail.com) wrote:

> Shay,  
> Are there any guidelines you can give (recommended upper limit) to number  
> of indexes per cluster?
> 
> - Rich Kroll
> 
> On Tue, Jan 4, 2011 at 11:40 AM, Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)wrote:
> 
> > An index comes with an overhead when you create it. Actually, the main  
> > overhead is a shard, and by default, an index is created with 5 shards with  
> > 1 replicas. Each shard is a lucene index, which does come with its own  
> > overhead in terms of memory requirements and os resources (mainly file  
> > handles).
> > 
> > Talking about millions of users, I would suggest against creating an index  
> > per user.
> > 
> > -shay.banon
> > 
> > On Mon, Jan 3, 2011 at 8:43 PM, recht [jrecht@gmail.com](mailto:jrecht@gmail.com) wrote:
> > 
> > > Hi
> > > 
> > > It seems that performance degrades pretty quickly when adding indexes,  
> > > although the twitter example would suggest that it's possible to  
> > > create a large number of indexes. Is there any way of speeding up  
> > > multiple indexes, or is this not recommended for per-user indexes  
> > > (we're talking millions of users)? After 400 indexes, it takes about 4  
> > > seconds to create a new index.
> > > 
> > > Kind regards,  
> > > Joakim
> 
> --  
> “We can't solve problems by using the same kind of thinking we used when we  
> created them.” ~ Albert Einstein

---

<div class="post-metadata">

### Author: ![ppearcy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ppearcy/32/980_2.png) [@ppearcy](https://discuss.elastic.co/u/ppearcy)
#### Post date: [January 4, 2011, 9:33pm UTC](https://discuss.elastic.co/t/multi-tenancy-performance/3732/5 "2011-01-04T21:33:27Z")

</div>

I'd recommend using the shard routing behavior for per user data  
buckets. This keeps the shard count bounded and ends up only searching  
the necessary shard. In order to re-shard, you do need to rebuild  
content, though.

On Jan 4, 9:46 am, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:

> It really depends on the hardware you have, memory allocate to ES process.  
> Maybe other people can give explicit examples with some numbers, but I  
> suggest you do a quick capacity tests with what you have,  
> and extrapolate based on that.
> 
> On Tue, Jan 4, 2011 at 6:44 PM, Rich Kroll [kroll.r...@gmail.com](mailto:kroll.r...@gmail.com) wrote:
> 
> > Shay,  
> > Are there any guidelines you can give (recommended upper limit) to number  
> > of indexes per cluster?
> 
> > - Rich Kroll
> 
> > On Tue, Jan 4, 2011 at 11:40 AM, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com)wrote:
> 
> > > An index comes with an overhead when you create it. Actually, the main  
> > > overhead is a shard, and by default, an index is created with 5 shards with  
> > > 1 replicas. Each shard is a lucene index, which does come with its own  
> > > overhead in terms of memory requirements and os resources (mainly file  
> > > handles).
> 
> > > Talking about millions of users, I would suggest against creating an index  
> > > per user.
> 
> > > -shay.banon
> 
> > > On Mon, Jan 3, 2011 at 8:43 PM, recht [jre...@gmail.com](mailto:jre...@gmail.com) wrote:
> 
> > > > Hi
> 
> > > > It seems that performance degrades pretty quickly when adding indexes,  
> > > > although the twitter example would suggest that it's possible to  
> > > > create a large number of indexes. Is there any way of speeding up  
> > > > multiple indexes, or is this not recommended for per-user indexes  
> > > > (we're talking millions of users)? After 400 indexes, it takes about 4  
> > > > seconds to create a new index.
> 
> > > > Kind regards,  
> > > > Joakim
> 
> > --  
> > “We can't solve problems by using the same kind of thinking we used when we  
> > created them.” ~ Albert Einstein

---

<div class="post-metadata">

### Author: ![ppearcy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ppearcy/32/980_2.png) [@ppearcy](https://discuss.elastic.co/u/ppearcy)
#### Post date: [January 4, 2011, 9:36pm UTC](https://discuss.elastic.co/t/multi-tenancy-performance/3732/6 "2011-01-04T21:36:06Z")

</div>

And to answer your other question, you want to keep to keep the number  
of indexes reasonably bounded. This is just my rough back of the  
envelope number, but I'd try to keep the shard count below 100 for a  
beefy server. These shards can get quite large, though, as long as you  
have the RAM and disk available and I am sure you can push the count  
much much higher with proper tuning.

On Jan 4, 2:33 pm, Paul [ppea...@gmail.com](mailto:ppea...@gmail.com) wrote:

> I'd recommend using the shard routing behavior for per user data  
> buckets. This keeps the shard count bounded and ends up only searching  
> the necessary shard. In order to re-shard, you do need to rebuild  
> content, though.
> 
> On Jan 4, 9:46 am, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:
> 
> > It really depends on the hardware you have, memory allocate to ES process.  
> > Maybe other people can give explicit examples with some numbers, but I  
> > suggest you do a quick capacity tests with what you have,  
> > and extrapolate based on that.
> 
> > On Tue, Jan 4, 2011 at 6:44 PM, Rich Kroll [kroll.r...@gmail.com](mailto:kroll.r...@gmail.com) wrote:
> > 
> > > Shay,  
> > > Are there any guidelines you can give (recommended upper limit) to number  
> > > of indexes per cluster?
> 
> > > - Rich Kroll
> 
> > > On Tue, Jan 4, 2011 at 11:40 AM, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com)wrote:
> 
> > > > An index comes with an overhead when you create it. Actually, the main  
> > > > overhead is a shard, and by default, an index is created with 5 shards with  
> > > > 1 replicas. Each shard is a lucene index, which does come with its own  
> > > > overhead in terms of memory requirements and os resources (mainly file  
> > > > handles).
> 
> > > > Talking about millions of users, I would suggest against creating an index  
> > > > per user.
> 
> > > > -shay.banon
> 
> > > > On Mon, Jan 3, 2011 at 8:43 PM, recht [jre...@gmail.com](mailto:jre...@gmail.com) wrote:
> 
> > > > > Hi
> 
> > > > > It seems that performance degrades pretty quickly when adding indexes,  
> > > > > although the twitter example would suggest that it's possible to  
> > > > > create a large number of indexes. Is there any way of speeding up  
> > > > > multiple indexes, or is this not recommended for per-user indexes  
> > > > > (we're talking millions of users)? After 400 indexes, it takes about 4  
> > > > > seconds to create a new index.
> 
> > > > > Kind regards,  
> > > > > Joakim
> 
> > > --  
> > > “We can't solve problems by using the same kind of thinking we used when we  
> > > created them.” ~ Albert Einstein

---

<div class="post-metadata">

### Author: ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)
#### Post date: [January 4, 2011, 10:21pm UTC](https://discuss.elastic.co/t/multi-tenancy-performance/3732/7 "2011-01-04T22:21:31Z")

</div>

Yea, routing is a great use case for user base "index". Just make sure you  
provide the user id as the routing value when you index, and when you search  
(so only one shard will be queried), on top of the userid filtered query.

One thing regarding the need to reindex, with clever index placement, you  
can work around that. By aliasing indices with the username, you can  
dynamically allocate more indices on the fly and assign new users to them.  
Rollover to a new index when you have, for example, N numbers of users  
assigned to that index. On the "front end", all the code interacts with the  
aliases, so it feels as if each user has its own index, except for the fact  
that user id routing and wrapping of any query executed in the context of a  
user with a filtered query with user id. That can be easily done with a nice  
"search layer" in the app that will automatically wrap any query with a  
filtered query, and provide the routing value.

On Tue, Jan 4, 2011 at 11:33 PM, Paul [ppearcy@gmail.com](mailto:ppearcy@gmail.com) wrote:

> I'd recommend using the shard routing behavior for per user data  
> buckets. This keeps the shard count bounded and ends up only searching  
> the necessary shard. In order to re-shard, you do need to rebuild  
> content, though.
> 
> On Jan 4, 9:46 am, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:
> 
> > It really depends on the hardware you have, memory allocate to ES  
> > process.  
> > Maybe other people can give explicit examples with some numbers, but I  
> > suggest you do a quick capacity tests with what you have,  
> > and extrapolate based on that.
> > 
> > On Tue, Jan 4, 2011 at 6:44 PM, Rich Kroll [kroll.r...@gmail.com](mailto:kroll.r...@gmail.com) wrote:
> > 
> > > Shay,  
> > > Are there any guidelines you can give (recommended upper limit) to  
> > > number  
> > > of indexes per cluster?
> > 
> > > - Rich Kroll
> > 
> > > On Tue, Jan 4, 2011 at 11:40 AM, Shay Banon \<  
> > > [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com)\>wrote:
> > 
> > > > An index comes with an overhead when you create it. Actually, the main  
> > > > overhead is a shard, and by default, an index is created with 5 shards  
> > > > with  
> > > > 1 replicas. Each shard is a lucene index, which does come with its own  
> > > > overhead in terms of memory requirements and os resources (mainly file  
> > > > handles).
> > 
> > > > Talking about millions of users, I would suggest against creating an  
> > > > index  
> > > > per user.
> > 
> > > > -shay.banon
> > 
> > > > On Mon, Jan 3, 2011 at 8:43 PM, recht [jre...@gmail.com](mailto:jre...@gmail.com) wrote:
> > 
> > > > > Hi
> > 
> > > > > It seems that performance degrades pretty quickly when adding  
> > > > > indexes,  
> > > > > although the twitter example would suggest that it's possible to  
> > > > > create a large number of indexes. Is there any way of speeding up  
> > > > > multiple indexes, or is this not recommended for per-user indexes  
> > > > > (we're talking millions of users)? After 400 indexes, it takes about  
> > > > > 4  
> > > > > seconds to create a new index.
> > 
> > > > > Kind regards,  
> > > > > Joakim
> > 
> > > --  
> > > “We can't solve problems by using the same kind of thinking we used  
> > > when we  
> > > created them.” ~ Albert Einstein

---

<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, 4:14am UTC](https://discuss.elastic.co/t/multi-tenancy-performance/3732/8 "2017-07-06T04:14:22Z")

</div>


