简体   繁体   English

处理非常大的JSON数据集?

[英]Handling Very Large JSON Dataset?

I have a scenario wherein frontend app makes a call to backend DB (APP -> API Gateway -> SpringBoot -> DB) with a JSON request. 我有一个场景,其中前端应用程序通过JSON请求调用后端数据库(APP-> API网关-> SpringBoot-> DB)。 Backend returns a very large dataset (>50000 rows) in response sizing ~10 MB. 后端返回一个非常大的数据集(> 50000行),响应大小约为10 MB。

My frontend app is highly responsive and mission critical, we are seeing performance issues; 我的前端应用程序具有高响应性和关键任务,我们正在看到性能问题; frontend where app is not responding or timing-out. 应用程序没有响应或超时的前端。 What can be best design to resolve this issue condering 什么是解决这个问题的最佳设计

  1. DB query cant be normalized any further. 数据库查询无法进一步规范化。
  2. SpringBoot code has has cache builtin. SpringBoot代码具有内置缓存。
  3. No data can be left behind due to intrinsic nature 由于内在性质,不会留下任何数据
  4. No multiple calls can be made as data is needed is first call itself 不能进行多次通话,因为需要数据是第一次通话本身
  5. Can any cache be built in-between frontend and backend? 可以在前端和后端之间建立任何缓存吗?

Thanks. 谢谢。

10mb is huge and can be inconsiderate to your users especially if there's a high probability of mobile use. 10mb是巨大的,可能会对您的用户不屑一顾,特别是如果移动使用的可能性很高。

If possible, it would be best to collect this data on the backend, probably put it onto disk, and then provide only the necessary data to the frontend as it's needed. 如果可能的话,最好是在后端收集此数据,可能将其放到磁盘上,然后根据需要仅将必要的数据提供给前端。 As the map needs more data, you would make further calls to the backend. 当地图需要更多数据时,您将进一步调用后端。

If this isn't possible, you could load this data with the client-side bundle. 如果无法做到这一点,则可以通过客户端捆绑程序加载此数据。 If the data doesn't update too frequently, you can even cache it on the frontend. 如果数据更新不是太频繁,您甚至可以将其缓存在前端。 This would at least prevent the user from needing to fetch it repeatedly. 这至少将防止用户需要重复获取它。

Sounds like this is a generated report from a search. 听起来这是来自搜索的生成报告。 If this data needs to be associated with each other, I'd assign the search an id and restore the results on the server. 如果此数据需要相互关联,我将为搜索分配一个ID,然后在服务器上恢复结果。 Then pull the data for this id as needed on the frontend. 然后根据需要在前端拉取此ID的数据。 You should never have to send 50,000 rows to the client in one go... Paginate the data and pull as needed if you have to. 您永远不必一次向客户端发送50,000行...如果必须,可以根据需要对数据进行分页。 If you don't want to paginate, how much data can they display on a single screen? 如果您不想分页,它们可以在一个屏幕上显示多少数据? You can pull more data from the server based on where they scroll on the page. 您可以根据服务器在页面上的滚动位置从服务器中提取更多数据。 You should only need to return the count of the rows to the frontend, and maybe 100 rows of data. 您应该只需要将行的计数返回到前端,也可能需要返回100行数据。 This would allow you to show a scrollbar with the right height. 这将允许您显示具有正确高度的滚动条。 When they scroll to a certain position within the data, you can pull the corresponding offset from the server for that particular search id. 当它们滚动到数据中的某个位置时,您可以从服务器拉出该特定搜索ID的相应偏移量。 Even if you could return all 50,000+ rows in one go, it doesn't sound very friendly to the end user's device to have to load that kind of memory for a functional page. 即使您可以一次性返回所有50,000+行,对于最终用户的设备来说,为功能页加载此类内存听起来也不是很友好。 This is a sign of a flawed frontend that should be redone. 这表明应该重做一个有缺陷的前端。

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

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