ajax 化自动建议

发布于 2024-07-13 10:27:58 字数 578 浏览 11 评论 0原文

我有一个带有自动建议功能的搜索模块可以在 ASP.Net 中构建 搜索条件是培训名称,数据库中有一个存储培训的表。 表中的大小将达到 30,000 次训练,因此我必须非常小心地选择方法,同时牢记性能。

大约有3000个用户同时登录系统。 当用户开始输入训练名称时,系统应该自动建议。

我想到的方法是在

  1. 缓存对象下 - 用户输入 3 个(例如 saf)字符后会出现数据库命中,系统将在活动表中搜索以 saf 开头的所有训练并缓存它们。 其他请求将通过此缓存。 但这种方法的问题是,如果有 3000 个并发用户使用该系统,并且如果他们都搜索 3 个不同字母的不同组合,则缓存就会崩溃。

  2. 客户端缓存 - 对此没有考虑太多。 我在这里看到的唯一缺点是我们可能必须定期清除临时 Internet 文件夹。

  3. 使用会话 - 我认为完全排除这种情况,因为我认为它会影响性能。

    使用

您能否建议我在这里可以采取的最佳方法或任何其他不同的方法。 我正在寻找您对此的所有信息/想法。

非常感谢迪帕

I have a search module with Auto Suggest feature to build in ASP.Net
The search criteria is Training Name and there is a table in database that stores trainings. The size would be as large as 30,000 trainings in the table so I have to be very careful in selecting the approach keeping in mind the performance.

There could be about 3000 users logging in the system simultaneously. When the user starts typing a training name the system should autosuggest.

The approaches that came in my mind were as under

  1. Cache object - There would be a database hit after the user types 3 (e.g. saf) characters and the system would search the activity table for all trainings starting with saf and would cache them. The other requests would go thro this cache.
    But the problem with this approach would be if there are 3000 concurrent users using the system and if they all search for different combinations of 3 different letters the cache would just blow.

  2. Client side caching - Did not think much on this. The only drawback I see here is we might have to purge the temporary internet folder periodically.

  3. Using Session - I thought to rule this out completely as I thought it would hit performance.

Can you please suggest the best or any other different approach I can take here. I am looking for all information/ideas that you have on this.

Thank you so much

Deepa.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

何以心动 2024-07-20 10:27:58

我最喜欢的 jQuery 插件(如果您打算使用 jQuery)是 Flexbox

它有一个非常令人印象深刻的功能列表。

My favourite jQuery plug-in to do that (if you're in intent to use jQuery) is the Flexbox.

It has a really impressive list of features.

挽清梦 2024-07-20 10:27:58

您可以使用 jQuery Auto Complete 插件,它内置了缓存功能。

$(document).ready(function()
{
        $(".landingpage").autocomplete('/AutoSuggestHandler.ashx',
        {
            minChars: 1,
            matchSubset: 1,
            autoFill: false,
            delay: 10,
            scroll: false
        }).result(OnResultSelected);
}

此外,您可以在通用处理程序上指定输出缓存,以满足跨用户缓存的需要。

You could use the jQuery Auto Complete plugin, which has caching features built in.

$(document).ready(function()
{
        $(".landingpage").autocomplete('/AutoSuggestHandler.ashx',
        {
            minChars: 1,
            matchSubset: 1,
            autoFill: false,
            delay: 10,
            scroll: false
        }).result(OnResultSelected);
}

Furthermore, you could specify outpu caching on the generic handler, to accommodate the need of caching across users.

冰魂雪魄 2024-07-20 10:27:58

我认为你的第一种方法会起作用。

确保该字段有索引 - 您可能不需要为整个字段建立索引。 这应该会给数据库带来相当大的提升。 您可能需要根据搜索的工作方式查看全文索引,或者甚至使用 lucene 等外部库来索引,因为性能是一个问题。

缓存对象,甚至查询生成的 xml/json 以提高性能。

您还应该设置 http 标头,以便浏览器也缓存 xml/json。

I think your first approach will work.

Make sure there is an index on the field - you probably won't need to index the whole field. This should give the database a decent boost. You may need to look at full text indexing depending on how your search works, or even use an external library like lucene for the index is performance is an issue.

Cache the object, or even the resulting xml/json from the queries to improve performance.

You should also set the http headers so that browsers cache the xml/json as well.

硪扪都還晓 2024-07-20 10:27:58

您的帖子实际上包含两个问题:

  1. 如何在我的网页上获得自动完成功能?
  2. 由于大量查询同时访问我的数据库,我担心性能。

我的答案...

1:我们找到了 ASP.NET AJAX AutoComplete Extender 适用于所有现代浏览器,提供流畅的用户体验并且非常容易实现。

在您的 Web 应用程序中,您需要创建一个 Web 服务,该服务具有带有特定签名的方法(在上面链接的文档中介绍)。

2:您是否证明您的项目的这一部分确实存在性能瓶颈? 我建议设置一个测试工具,并使用大量自动完成查询来访问您的数据库,看看它可以花费多少时间。 警惕过早优化

Your posting really contains two questions:

  1. How can I get autocomplete on my webpage?
  2. I am concerned about performance due to a large number of queries hitting my database at the same time.

My answers...

1: We've found the ASP.NET AJAX AutoComplete Extender works well on all modern browsers, provides a slick user experience and is pretty easy to implement.

In your web application you need to create a web service that has a method with a specific signature (covered in the documentation linked to above).

2: Have you proven that you actually have a performance bottleneck with this part of your project? I'd recommend setting up a test harness and hitting your database with a large number of autocomplete queries to see how much it can take. Be wary of premature optimization.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文