Search code examples
elasticsearchsharding

How many shards should I use with Elasticsearch on a dev & CI environment?


By default Elasticsearch is configured to start with 5 shards.

Is there a reason to use 5 shards locally (on my development machine) and on the continuous integration server (for integration tests)? Is it better to use 1?

Obviously I don't care about scalability in those cases, I just want the simplest setup.


Solution

  • The simplest setup is 1 primary shard, 0 replicas.

    If you only have one node and replica count is >0 it will always be yellow. Not a problem per se, but those will not be needed.

    If you want to test search response time with that one shard, for example, it depends on some factors if 1 is enough or you need more. The simplest rule of thumb is to have shards no larger than 30-50GB, for example. But this number also depends on factors.

    So, I'd say if you have one node, start with 1 primary, 0 replicas. If that primary is too "large", think about having more primaries (each shard will do part of the work and each will use one core CPU for searching).