# Spark, analogy between shard and partition is wrong

**URL:** https://discuss.elastic.co/t/spark-analogy-between-shard-and-partition-is-wrong/81847
**Category:** Elasticsearch
**Tags:** es-hadoop
**Created:** [April 10, 2017, 4:16pm UTC](https://discuss.elastic.co/t/spark-analogy-between-shard-and-partition-is-wrong/81847 "2017-04-10T16:16:47Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![ebuildy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ebuildy/32/6070_2.png) [@ebuildy](https://discuss.elastic.co/u/ebuildy)
#### Post date: [April 10, 2017, 4:16pm UTC](https://discuss.elastic.co/t/spark-analogy-between-shard-and-partition-is-wrong/81847/1 "2017-04-10T16:16:47Z")

</div>

The plugin es4Hadoop make an analogy between ES shard and Spark partition, but it's not good.

Most of Spark users, advice to have "small" partitions, about 512M, for instance, Spark cannot cache in disk more than 2Gb (a know issue, not fix yet), whereas, elasticsearch advice to have big shard (10 Go), this is not compatible.

We should be able to control how many partitions when reading from elasticsearch. And by default, you should use the same value then HDFS use (64M/128M == 1 partition), I think it's a good idea to follow that.

(repartition can help, but it's very resources consuming and can give OOM).

---

<div class="post-metadata">

### Author: ![james.baiera](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/james.baiera/32/10209_2.png) [@james.baiera](https://discuss.elastic.co/u/james.baiera)
#### Post date: [April 13, 2017, 4:32pm UTC](https://discuss.elastic.co/t/spark-analogy-between-shard-and-partition-is-wrong/81847/2 "2017-04-13T16:32:08Z")

</div>

@ebuildy in 5.0 we introduced the parallel reader functionality to the connector. When reading from Elasticsearch on clusters running 5.0 and up, the connector will subdivide the shards into slices based on the number of documents in them. This is configurable using the `es.input.max.docs.per.partition` (default 100,000). This should let you split up the larger ES partitions into smaller Spark friendly partitions.

---

<div class="post-metadata">

### Author: ![ebuildy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ebuildy/32/6070_2.png) [@ebuildy](https://discuss.elastic.co/u/ebuildy)
#### Post date: [April 26, 2017, 7:10am UTC](https://discuss.elastic.co/t/spark-analogy-between-shard-and-partition-is-wrong/81847/3 "2017-04-26T07:10:41Z")

</div>

Ha fantastic!

(Cannot believe that Spark still has the max 2GB bug 😕 😕 )

---

<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: [May 24, 2017, 7:21am UTC](https://discuss.elastic.co/t/spark-analogy-between-shard-and-partition-is-wrong/81847/4 "2017-05-24T07:21:03Z")

</div>

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