This message was deleted.
# community-help
s
This message was deleted.
j
It says “Network error”… Are you able to share the exact request URL and query parameters to Typesense that throws this error?
e
dm’d
j
Looks like your cluster is spiking to 100% CPU every now and then
I would recommend upgrading to 4vCPUs for the volume of traffic you have
r
Are there lower RAM configurations for 4vCPUs? 8 GB seems overkill given dataset size 😅
j
Unfortunately no…
r
Any plans to add this in the future? It seems that things have stabilized now though
j
We would love to! But most cloud platforms (including AWS which is what we run Typesense Cloud on at the moment) only offer a fixed set of RAM / CPU configs, so we’re kinda restricted by that. When we do colo servers in the future, we’d want to add more configs for sure.
Btw, looking at last 3 days max CPU usage, your nodes are still exhausting CPU every now and then…
r
Yes, you are right. Out of curiosity, shouldn’t we fall back to the other nodes in case of CPU exhaustion?
j
The failover only happens if the health endpoint is unhealthy for over 30s. In this case, the spikes seem much shorter than that
r
Gotcha. Hmm, the next upgrade tier bumps our yearly spend to more than Algolia actually. We might need to look into self-hosting on GCP. In the meantime, we’ll bump the resource limits
j
Out of curiosity, may I know how many searches per month you had in Algolia?
r
~375k searches/m
j
Hmmm! That looks way less than the traffic your Typesense cluster is getting… Almost 8x more if I extrapolate your avg requests per second to requests per month
r
Perhaps @Ethan Horoschak can explain more into that. I think it’s because we need to make many more typesense requests to get to feature parity with Algolia
e
I noticed in the network console when integrating the typesense instant search adapter that every change in query sends about 10 requests
👀 1
Even if we only change one filter or letter in the query
j
Hmm, is the UI public somewhere that I can take a look?
r
e
Perhaps we can set the cache period to longer than 2 minutes
r
I am seeing about 8 requests for each search, which lines up with what you were saying earlier @Jason Bosco
j
Yup, I see that too… And all of them are identical. The typesense-instantsearch-adapter shouldn’t do this, unless it’s being somehow re-instantiated multiple times, may be due to some reactivity?
For eg, have a look at the network requests in this demo which uses typesense-instantsearch-adapter: https://songs-search.typesense.org
The adapter also has a client-side cache… so if it’s the same instance of the adapter, duplicate requests should just be served from the JS-based cache. Since it’s making separate duplicate network requests, my guess is that it’s being instantiated multiple times
e
here’s a snippet of our implementation on the jobs page: https://gist.github.com/ethanhoroschak/42273d93f0c8069f5c0609945dfaafbf
we instantiate the adapter outside of the component so it would be strange if it was getting instantiated that many times
j
I’m not too familiar with react, so I can’t tell if there’s any particular issue with this implementation… Could any of the widgets be re-rendered repeatedly somehow, that’s triggering a search?
I see the same issue on page load as well btw, without typing in any query
e
I console logged right below the adapter instantiation and made a bunch of requests and it doesnt look like the adapter was reinstantiated
j
Are any of the params passed to any of the instantsearch widgets reactive, and might be changing values repeatedly as different parts of the UI load?
e
we have query params set up which prefill the filters
j
I meant to say “props” btw
Hmm, so I tried changing the network throttling to Slow 3G in Chrome, and reloaded the page, I now see 16 duplicate requests… Could the loader component be causing repaints somehow?
e
yeah we have a query param hook that updates the url parameters and the states of the query and filters which uses useEffect with the params as a dependency
j
e
I believe it is an issue with out query param implementation causing rerenders
although the prop doesnt change - do rerenders cause typesense requests even if the props dont change?
j
I’ve seen search requests generated by Instantsearch anytime any of the widgets are re-rendered
e
im testing with our algolia implementation we didnt have the duplicate request issue
it only sends 1 request with our same setup so switch to the typesense adapter was the only change
j
Are you using SSR?
e
not for this page
first tab is algolia
j
I now remember one user running into a similar issue a while ago… But I’m not sure if they managed to fix it or not.
Here’s a Next.js app that uses the adapter and doesn’t do multiple requests if that helps narrow it down: https://showcase-nextjs-typesense-ecommerce-store.vercel.app This is the source-code: https://github.com/typesense/showcase-nextjs-typesense-ecommerce-store
e
hmm yeah this implementation doesnt use query params so likely wont have the rerender issues
I believe it may be the typesense adapter - since that was the only change
we have multiple rerenders but the prop values for the widgets dont change
j
The adapter is a simple stateless (except for the cache) data transformation library that is called by instantsearch… So it doesn’t initiate any search requests by itself, unless it has a set of search requests given to it by Instantsearch… So I’m not sure if there’s any fixes in the adapter that can be done to solve for this.
Scratch that - I just found this issue which seems related: https://github.com/algolia/react-instantsearch/issues/2847
r
Was just on that exact issue 😅
😄 1
j
Looks like Instantsearch does trigger multiple searches, but it expects some different form of cache in aany custom search client used… Let me implement this and we’ll see if that fixes the issue
👍 2
Could you upgrade to
2.7.1-5
of the adapter on your local machine and check if you see the issue now?
e
Looks like it works!
only sending 1 request per query change now
j
Awesome! 🙌
Once you deploy this to production your requests per second should go down significantly
e
deploying now - will keep an eye out on requests
👍 1
seem to still be getting the network errors even though our cpu hasnt gone above 40% in the last hour
j
Do you have a timestamp in UTC when you saw the last couple of errors? And also the exact search request with all the search params?
e
last happened: Aug 2, 2023 90500 PM UTC
sent the request in dms
j
Hmm, I can’t seem to find any evidence of timeouts from metrics on our side
e
hmm we got 181 errors in the last 24 hours - any other reason they could be happening?
j
I guess client network connectivity (internet issues) could also cause this…
e
Ah interesting - that makes it hard to know which errors to ignore and which are due to the cluster
r
@Jason Bosco I don’t think this could be client side since the error response code is indicating a network error with a specific Node (in our case, Node 0). It seems like this call is being made directly in the typesense library, so we don’t have any access to it at the moment. Would it be possible to add some additional logging? I am sure that can help us narrow down what might be causing it
j
The error is indeed being generated because the client can’t connect to the Typesense node. But you can still get a “Network Error” if the browser’s internet connectivity is flaky and the browser can’t send an outbound request
r
Ah, yeah you are correct. Looking at the networking trace though, it seems that the other requests to other APIs are working fine, what could be causing a client to be blocked from Typesense?
j
Are you able to replicate it on your own machine?
r
No, but we’ve noticed this happening almost exclusively on Windows
j
Ah hmmm… Could there be clients that are behind a corporate firewall that’s blocking non-approved hostnames?
r
I don’t think so, because this I just checked the origin IPs and they look residential. Additionally, requests to other hostnames went through
j
Do you have the browser console logs from the sessions that logged Network error? (In Sentry for eg)
e
this is the full json error trace
heres the breadcrumb stack trace
j
Hmm, I don’t see any other clues there… This is a long shot, but could you try a client configuration like this:
Copy code
{
    nearestNode: {
        host: 'xxx.a1.typesense.net',
        port: 443,
        protocol: 'https',
    },
    nodes: [
        {
            host: 'xxx-1.a1.typesense.net',
            port: 443,
            protocol: 'https',
        },
        {
            host: 'xxx-2.a1.typesense.net',
            port: 443,
            protocol: 'https',
        },
        {
            host: 'xxx-3.a1.typesense.net',
            port: 443,
            protocol: 'https',
        },
    ],
   ....
}
(Update with your actual cluster ID)
e
ah ok - will try. Right now we just have a single node with the nearest node
the Nearest Node should have automatic failover though right? so specifying the other nodes is redundant?
j
Nearest Node should have automatic failover though right
It does, but in this case, my suspicion is that somehow a flood of requests are trying to make it to the same node, so the browser might be throttling these requests… So if that happens, then the client can fallback to one of the other hostnames as a fallback
e
ok deploying new config now
🤞 1
ah ok still getting the errors but is now showing different nodes for subsequent requests
j
Are those 3 screenshots from the same session?
e
yeah all from same session
j
If all nodes fail to respond, then you’ll see a log for nearestNode, node0, node1 and node2… Do you see Network Error for all 4 hostnames in the same session?
e
yeah it tried all 4
j
Hmmm, I’m stumped then. It’s highly unlikely that all 3 nodes, accessed from 4 hostnames are all running into a server-side error
So there’s something happening in the browser environment
Any particular browser / IPs patterns across occurences?
e
looks like all chrome and windows
Chrome 115.0.0, Windows >= 10
j
I’m out of ideas to debug this… Is there any way for you to reach out to one of your users who ran into this issue? (if you have logged in account tracking for eg in sentry) and see if they can get on a call to reproduce this?
e
we added user id tracking an hour ago and actually looks like many are coming from the same IP in india