-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Question] - Getting occasional Net::ReadTimeout with #<TCPSocket:(closed) errors #120
Comments
@cjilbert504 this timeout happens only during the indexing? Or does it happen during the search query as well? |
@brunoocasali - Only during the search query. |
Can you please share your stack trace with me? (this could help me to understand the slowness path of your search request). Since we aim to respond to users below the 50ms (https://docs.meilisearch.com/learn/what_is_meilisearch/philosophy.html#simple-and-intuitive) we should definitely understand who are causing the slowdown on your request if it is related to the size of the body, the search engine, the ruby side - trying to deal with that -, or anything else. Meanwhile, I think you had the right approach, by removing some of the data using the |
@brunoocasali This was happening in production, but also if we ran We're thinking it's because some of the ForumThreads we have indexed have 200-300 posts and we are indexing those as an array of strings on the ForumThread. All the other queries seem to be fine generally except those with massive results. On the Ruby side, the stacktrace is pretty simple:
Which is triggered by our controller action that just runs the query:
Since this happens with just a That's why we're leaning towards it being an issue with the way we've indexed the forum threads and posts. Each of the documents here are going to be pretty large considering several forum threads are indexing the content of 200+ forum posts: Should we be looking for anything special in the Meilisearch server logs to better optimize this? |
Hello everyone, I wasn't able to check this yet, but I promise I will! (I just haven't the time to dig into this we are upgrading the integrations to v0.26 😅). I'll come back to this soon! |
I can confirm I'm seeing this on reindexing ~28K records. |
First of all, sorry for this long waiting period! I had a time, and I did a lot of experiments in the rails and the ruby gems. I had internal conversations, and I can answer most of the questions, which maybe raise other questions! TL;DR:
Unfortunately, I could not reproduce the error (without creating flaky tests) to fix it with tests. If anyone has any ideas, let me know. 1st about the array or one string:
Having a large string or an array of strings does not matter for the Meilisearch server, since both ways will be tokenized internally, so, since you already have an array, you can keep it, then you will not need extra work to join it in a big string. 2nd about the But to prevent that behavior, we should improve the search usage with I made some tests locally, and I came up with a huge difference, e.g., 4.366 hits had a response size of 3.5MB including all the attributes, and when I adequately configured the attributesToRetrieve in the search query, I was able to reduce it to 14Kb. I created a small benchmark to help share the timing results with you, and here it is: Benchmark.bm do |x|
x.report("attrs: [id]") { 30.times { Restaurant.ms_search("bra", attributes_to_retrieve: ["id"], limit: 5000) } }
x.report("attrs: [**]") { 30.times { Restaurant.ms_search("bra", limit: 5000) } }
# to prevent some caching I inverted the order and ran again
end Anyway, I give all this context to mention that I will generate an issue about a possible enhancement in the default search behavior of the rails gem. The idea is to use Since I keep you guys waiting for so long, @cjilbert504 and @excid3, did you come up with other solutions than this one? |
By the way, @cjilbert504 the meilisearch instance is located in the same region of your app? Do you know how long it takes (on average) for meilisearch to answer your search requests? |
@schappim about your situation, indexing is indeed something we need to enhance in our core. Still, I'm almost sure that this is not related to Meilisearch Rails directly unless you have some N+1 in your indexing process. |
I'm closing this issue due to inactivity. Feel free to reopen it if needed! Also, I've created this issue #193 that could help improve the perceived performance. Thanks for using Meilisearch! :) |
I am looking for any guidance around improving how we are querying on a model and its association. As it stands we occasionally see the error listed in the title and see a 500 error when it occurs. We believe that the reason for the timeout is the large amount of associated model attribute records that are indexed and being returned. For reference here is how the parent model is setup:
As a temporary fix we have updated our MeiliSearch::Rails.configuration as follows:
This seems to have mostly addressed the issue but I'm curious as to whether you had any thoughts on how we could improve the querying here. One thought we had was to set the
:forum_posts
as a searched but not displayed attribute to see if that would help. The other thought we had is that instead of calling justforum_posts.clean.pluck(:body)
which gives an array back to search through, instead join the bodies into one large string. Not sure if that would have any impact or not though.Thanks for any and all help on this one! It is much appreciated.
The text was updated successfully, but these errors were encountered: