# High Latency with geo filtering(point in a polygon) at high throughput

**URL:** <https://discuss.aerospike.com/t/high-latency-with-geo-filtering-point-in-a-polygon-at-high-throughput/4457>\
**Category:** Query & Indexing\
**Tags:** query, secondary, geoindex, latency\
**Created:** [August 2, 2017, 4:35am UTC](https://discuss.aerospike.com/t/high-latency-with-geo-filtering-point-in-a-polygon-at-high-throughput/4457 "2017-08-02T04:35:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Swati\_Kunte](https://avatars.discourse-cdn.com/v4/letter/s/a3d4f5/32.png) [@Swati\_Kunte](https://discuss.aerospike.com/u/Swati_Kunte)\
**Post date:** [August 2, 2017, 4:35am UTC](https://discuss.aerospike.com/t/high-latency-with-geo-filtering-point-in-a-polygon-at-high-throughput/4457/1 "2017-08-02T04:35:25Z")

</div>

We are using Aerospike’s query feature with geo point in a polygon filter. WE have created GEO2DSPHERE secondary index on the bin, but we see that it is taking ~150ms for a single call. When run at throughput ~10k with concurrency ~80, the response time reached ~2 seconds and this keeps on increasing at higher load. The set that we are querying has no more than 50 records and geo bin contains upto 50 polygons each. Aerospike machine configuration- 3 boxes (2 core, 8Gb ram, 200Gb dp2 disk)

Please let us know if we are missing some configuration or if we can tune our Aerospike cluster better

---

<div class="post-metadata">

**Author:** ![Albot](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/albot/32/2076_2.png) [@Albot](https://discuss.aerospike.com/u/Albot)\
**Post date:** [August 2, 2017, 9:55pm UTC](https://discuss.aerospike.com/t/high-latency-with-geo-filtering-point-in-a-polygon-at-high-throughput/4457/2 "2017-08-02T21:55:02Z")

</div>

- Is the latency also appearing inside the Aerospike histograms? (asadm -e show latency or AMC latency tab)
- Do you have multiple clients making the same call? Are the latencies cumulative (does running 1x query from 2 boxes take 150ms, or does running 1x query from 2 boxes take 300ms?)

---

<div class="post-metadata">

**Author:** ![Swati\_Kunte](https://avatars.discourse-cdn.com/v4/letter/s/a3d4f5/32.png) [@Swati\_Kunte](https://discuss.aerospike.com/u/Swati_Kunte)\
**Post date:** [August 3, 2017, 12:37pm UTC](https://discuss.aerospike.com/t/high-latency-with-geo-filtering-point-in-a-polygon-at-high-throughput/4457/3 "2017-08-03T12:37:59Z")

</div>

1. Is the latency also appearing inside the Aerospike histograms? (asadm -e show latency or AMC latency tab) - The latency is going high as we increase concurrency.

2. Do you have multiple clients making the same call? Are the latencies cumulative - Yes, we have multiple clients making the same call. We are running a test with the same latitude longitude point which is searched in the same keyspace in same bin. Response time is increasing as concurrent requests increase

---

<div class="post-metadata">

**Author:** ![rbotzer](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/rbotzer/32/2114_2.png) [@rbotzer](https://discuss.aerospike.com/u/rbotzer)\
**Post date:** [August 3, 2017, 2:42pm UTC](https://discuss.aerospike.com/t/high-latency-with-geo-filtering-point-in-a-polygon-at-high-throughput/4457/4 "2017-08-03T14:42:04Z")

</div>

In general the GEO2DSPHERE index may return a lot of false positives, with the decision on whether the polygons contain a specific point narrowed down post-retrieval in a fairly CPU intensive way. Larger regions are more susceptible to this outcome. 50 regions is a tiny number, and they’re likely to be very big.

One thing you should do is chop those polygons into smaller cells. That will lead to less overlap and a shorter computation time, lowering your latency.

Beyond that there’s configuration tuning and using an appropriate version. Which release of Aerospike CE are you using? Can you post the configuration you’re using, especially `service` and the `namespace` configuration for this specific namespace? (the entire config would help, if you’re comfortable with that). Not sure what a dp2 disk is. Are you on bare-metal or in a virtualized environment like Amazon EC2?
