When deploying to our production environment we noticed a significant performance decrease in searching for articles in commerce manager. From time to time (seems like first time, and then after 1 or so minutes) searching for articles takes 90 seconds.
After decompiling and adding stopwatches here and there, we have noticed that it is this line that takes 90 seconds.
ISearchResults searchResults = new SearchManager(Mediachase.Commerce.Core.AppContext.Current.ApplicationName).Search((ISearchCriteria)entrySearchCriteria);
It is located in the CatalogEntrySearchDialog.cs. Any ideas on why it takes so long time in production?
Which search provider are you using? On which version?
How many rows are you getting back? If the page size is too big, then the search time can be that slow.
Lucene search provider.
commerce version: 9.19.0
~100k products, 700k variants
But when we connect to the prod-db from our localmachine and rebuild the index locally on disc the search i fast all the time?
No I meant this page size
Having it to be 1000 or All will certainly make it slow.
And 800k entries in total is on the "heavy" side for LuceneSearchProvider
It is set to 50.
But as i said, when we connect to the prod database locally and copy the entire index from the production machine it goes fast all the time.
In production, 90 seconds for the first search and if you do the exact same search directly after it is fast. But if we wait for ca 1 minute it is slow as hell again.
In prod where those index files are located?
If it's on a file server, involvo your infrastructure team. Do a test on prod by keeping them locally.
The server is a virual machine which has two hard drives and we have tried to put the lucene files on both, but get the same problem. Ie. it's not a shared network drive.
We have no problems with either of the hard drives in any other application. The site and commerce manager is hosted on one of the drives.
As I said, I would suggest to use a profiler like dotTrace or prefix to see what is taking most of the time.
I have profiled the application remote with dottrace now. And you can clearly see what is taking extremely long time. This is 2 searches.
But the weird thing is that it works just fine locally, with 800k entries.
Using find is not an option, since commerce manager adds a own/new index that we have to pay for.
When you run it locally, only your Commerce Manager AppPool accesses the folder, so no lock at all.
I've heard of issues with LuceneSearchProvider (in fact, Lucene) regarding big index/ high load site - locking is a problem. Lucene works well in small to medium index size/load, but it has its limits.
I'm just saying you have other options. It's up to you to investigate and invest. Find is a great alternative even it's not free - the investment will pay off in long term.