#community-help

Improving Search Response Time in Typesense

TLDR Ed expressed concerns about higher search response times. Jason identified the high max facet value and average record size factors contributing to the issue. They also discussed options to enhance performance, such as limiting facet values display and upgrading the CPU.

Powered by Struct AI

1

25
2mo
Solved
Join the chat
Aug 02, 2023 (2 months ago)
Ed
Photo of md5-120c789e9edae8b90bf59cf0e2612b66
Ed
08:18 PM
Hi, I am lookin at the <https://airbnb-geosearch.typesense.org/> and the search response time looks pretty good with millions of records. I have 1800 records and my search_ms is 223, I wonder if I am doing something wrong here
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
08:18 PM
Could you share all the search params you’re using?
Ed
Photo of md5-120c789e9edae8b90bf59cf0e2612b66
Ed
08:19 PM
curl '' \
  -H 'authority: ' \
  -H 'accept: application/json, text/plain, */*' \
  -H 'accept-language: en-US,en;q=0.9' \
  -H 'cache-control: no-cache' \
  -H 'content-type: text/plain' \
  -H 'dnt: 1' \
  -H 'origin: xxxx \
  -H 'pragma: no-cache' \
  -H 'referer:xxx/' \
  -H 'sec-ch-ua: "Chromium";v="115", "Not/A)Brand";v="99"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "macOS"' \
  -H 'sec-fetch-dest: empty' \
  -H 'sec-fetch-mode: cors' \
  -H 'sec-fetch-site: cross-site' \
  -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36' \
  --data-raw '{"searches":[{"collection":"tkag_en","q":"*","query_by":"data.title,content","drop_tokens_threshold":0,"filter_by":"data.jobField:=[`Engineering & Science`]","sort_by":"_text_match:desc,data.postingDate_timestamp:desc","page":1,"per_page":50,"facet_by":"data.businessUnit,data.category,data.company,data.contract,data.employmentType,data.entryLevel,data.jobField,data.language,data.remote,data.locations.cityState,data.locations.state,data.locations.country","max_facet_values":500,"include_fields":"data,_geoloc"},{"collection":"tkag_en","q":"*","query_by":"data.title,content","drop_tokens_threshold":0,"filter_by":"","sort_by":"_text_match:desc,data.postingDate_timestamp:desc","page":1,"per_page":0,"facet_by":"data.jobField","max_facet_values":500,"include_fields":""}]}' \
  --compressed
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
08:38 PM
A couple of things:

1. The geo search demo is running a non-burst CPU type, whereas your cluster has burst CPU type where performance can be a little unpredictable.

2. "max_facet_values":500 is what’s causing most of the slow-downs. If you’re able to remove that and leave it as the default, that will speed things up

3. Your average record size seems pretty high as well (at least a few KB), whereas the geosearch demo dataset record size is probably under 0.5kb
Ed
Photo of md5-120c789e9edae8b90bf59cf0e2612b66
Ed
08:39 PM
thank you for your prompt reply, shall I disable bursting?
08:40
Ed
08:40 PM
yeah I can probably change which fields to include
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
08:40 PM
You’d have to upgrade to a min of 4GB RAM to switch to a non-burst CPU type - worth experimenting
Ed
Photo of md5-120c789e9edae8b90bf59cf0e2612b66
Ed
08:40 PM
gotcha
09:32
Ed
09:32 PM
do we need this max_facet_values ?
09:32
Ed
09:32 PM
im trying to find out what it does
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
09:33 PM
It defaults to 10 facet values if not specified
Ed
Photo of md5-120c789e9edae8b90bf59cf0e2612b66
Ed
10:07 PM
hmm i need to wrap my head around it as i didn’t do this
10:08
Ed
10:08 PM
if i have jobs in 130 cities, only 10 city values would come?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
10:08 PM
For filtering options to show users - correct. And then you’d typically have a “load more” to show all cities
10:09
Jason
10:09 PM
Very similar to the “Show more” button in the AirBnb listings demo under “Property Type”
Ed
Photo of md5-120c789e9edae8b90bf59cf0e2612b66
Ed
10:09 PM
ah, the counts wouldn’t show correctly in all cities though
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
10:10 PM
For the cities that are displayed, the counts will be correct (leaving that other bug aside)
Ed
Photo of md5-120c789e9edae8b90bf59cf0e2612b66
Ed
10:10 PM
also here it cuts at 10
Image 1 for also here  it cuts at 10
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
10:10 PM
max_facet_values is 5 here
Image 1 for max_facet_values is 5 here
Ed
Photo of md5-120c789e9edae8b90bf59cf0e2612b66
Ed
10:11 PM
gotcha, yeah unfortunately customers wants all these fancy numbers
10:11
Ed
10:11 PM
but I understand the concept
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
10:11 PM
Ed
Photo of md5-120c789e9edae8b90bf59cf0e2612b66
Ed
10:12 PM
yeah customer wants all numbers when they go to filters

1

10:12
Ed
10:12 PM
we’re displaying 50
10:21
Ed
10:21 PM
facets problematic 😄