简体   繁体   English

将大型数据集存储在内存或客户端

[英]Storing large dataset in memory or client-side

I am looking to create intellisense for a series of fields in a .net web form that will enable a user to click one of the options, which will in turn fill out a series of fields (name, address etc). 我希望在.net Web表单中为一系列字段创建智能感知,这将使用户能够单击其中一个选项,从而依次填写一系列字段(名称,地址等)。 This was pretty trivial to implement using c#.net and ajax. 使用c#.net和ajax实现起来非常简单。 However, recently I was forced to encrypt some of the key fields that is being searched on against the database, so the feature is now broken. 但是,最近我被迫对正在数据库中搜索的某些关键字段进行加密,因此该功能现在已失效。 Our only method of decrypting these searchable fields is currently in the C#.net. 当前,解密这些可搜索字段的唯一方法是C#.net。

To fix the feature, I was thinking of either: a) when the page loads, grab all of the records and store in an array in memory (unencrypted) and as the user keys in the search field use linq or lambda to grab the record(s) of interest. 要修复此功能,我在考虑以下两种方法之一:a)在页面加载时,抓取所有记录并存储在内存中的数组中(未加密),并且当搜索字段中的用户键使用linq或lambda抓取记录时(s)感兴趣。 b) when the page loads, store all of the records in a js array (unencrypted) and perform the search client side. b)页面加载时,将所有记录存储在js数组中(未加密)并执行搜索客户端。

Which would be the best route to go with performance considerations for both my web server vs the client's browsing experience? 对于我的Web服务器和客户端的浏览体验,考虑性能方面的最佳选择是哪一条?

I'm thinking this would be < 100k records. 我认为这将是<10万条记录。

Why not store the records in the server cache and make an ajax request. 为什么不将记录存储在服务器缓存中并发出ajax请求。 Doing this will make the record set available to all the users. 这样做将使记录集对所有用户可用。

Wow so this is encrypted dynamic data. 哇,所以这是加密的动态数据。

Sending a lot of records to the client on each page load would be slow. 在每次页面加载时向客户端发送大量记录会很慢。

You might go with a dynamic cache where you load the data every few seconds. 您可能会使用动态缓存,每隔几秒钟就会在其中加载数据。

How large is each row? 每行有多大? ~100k rows can be a lot of data. 约10万行可以包含大量数据。

On the Client 在客户端上

100k on the client is a lot of data, even if it's a couple columns of data. 即使是几列数据,客户端上的100k还是很多数据。 That's just the data, then there is the matter of searching it. 仅仅是数据,然后就有搜索的问题。 It's an issue on a desktop browser. 这是桌面浏览器上的问题。 It will kill a mobile browser. 它将杀死移动浏览器。

On the Server 在服务器上

This is more plausible. 这更合理。

Things to consider: 注意事项:

  • How much memory will loading all the results into memory consume? 将所有结果加载到内存中会消耗多少内存?
  • What's the latency(network, database) to load all the records into memory? 将所有记录加载到内存的延迟时间(网络,数据库)是多少? Maybe it can be done async to lessen the impact to the user. 也许可以异步完成以减轻对用户的影响。
  • Searching in C# can be fast especially when using dictionaries, it is not as fast as a database. 使用C#进行搜索可以很快,尤其是在使用字典时,它不如数据库快。 Have you considered only storing the data that needs decrypting in memory and leave the rest in the database. 您是否考虑过仅将需要解密的数据存储在内存中,而其余的保留在数据库中。 Fetch the rest of the data from the DB when needed? 需要时从数据库中获取其余数据吗?

Ajax is still possible (assuming the data is stored on the server). Ajax仍然可以(假设数据存储在服务器上)。 You'll have to route the search requests to the proper store (in memory, database or a mixture of both). 您必须将搜索请求路由到适当的存储(在内存,数据库或两者的混合中)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM