GWT 应用程序的数据存储位置 - GAE 数据存储或 XML 文件
我有一个部署在 GAE 上的 GWT 应用程序。我的应用程序的一部分依赖于静态数据,该数据当前存储在 XML 文件中。应用程序将此数据读取到 POJO 集合中。使用 GWT-RPC 将数据发送到客户端。根据用户所做的选择,它将过滤器应用于集合以获取特定对象(过滤在客户端完成)。
数据最多可包含 3000 条记录,XML 文件总大小约为 1MB。应用程序端不会对这些数据进行更新(它是只读的),但在最初的几个月(随着应用程序的发展),我可能会经常添加新记录或更新/修复现有记录。该数据与应用程序中的任何其他数据没有关系。
我在获取性能方面的主要考虑因素之一。我尝试使用 Apache Digester 来解析 XML,但注意到即使解析 600 条记录并将它们发送到客户端也有点慢。
考虑到这些要求,以下哪一项更好?为什么 - 1. 将数据保留在 XML 文件中,还是 2. 将数据存储在应用程序引擎数据存储中?
谢谢。
I have a GWT app which is deployed on GAE. One part of my application relies on static data, which is currently stored in an XML file. The application reads this data into a collection of POJOs. The data is sent over to the client using GWT-RPC. Based on the selections made by the user, it applies filters to the collection to get specific objects (the filtering is done on the client side).
The data may contain up to 3000 records, and the total XML file size would be around 1MB. There'll be no updates on this data from the application side (it's read-only), but I may be frequently adding new records or updating/fixing existing records during the initial few months (as the application evolves). The data has no relationship with any other data in the application.
One of my main consideration in fetch performance. I tried using Apache Digester to parse the XML, but noticed that even parsing 600 records and sending them to the client was a bit slow.
Given these requirements which of the following would be better and why - 1. Keep the data in the XML file, or 2. Store the data in the app engine data store?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一种替代方法是直接通过 GWT 加载 XML 文件(无需 GWT-RPC 和服务器解析):
使用 RequestBUilder 从服务器获取数据。用法示例: http://www.gwtapps.com/ doc/html/com.google.gwt.http.client.html
然后使用 XMLParser 解析回复。示例:http://code.google.com/webtoolkit/doc/latest /DevGuideCodingBasicsXML.html#parsing
以下是结合两者的示例:http ://www.roseindia.net/tutorials/gwt/retriving-xml-data.shtml
唯一的缺点是您必须通过 DOM 手动解析 XML,而 GWT-RPC 直接生成对象。
更新:
根据我建议的评论:
使用 JAXB 解析 XML 文件以创建对象:http://jaxb.java.net/guide/_XmlRootElement_and_unmarshalling.html
将它们保存到内存缓存:http://code.google.com/appengine/docs/java/memcache/overview.html
在 RPC 请求中,检查 memcache,如果数据不存在,则转到 1。
One alternative would be to load the XML file directly by GWT (without GWT-RPC and server parsing):
Use RequestBUilder to get the data from the server. Example usage: http://www.gwtapps.com/doc/html/com.google.gwt.http.client.html
Then use XMLParser to parse the reply. Example: http://code.google.com/webtoolkit/doc/latest/DevGuideCodingBasicsXML.html#parsing
Here's an example combining both: http://www.roseindia.net/tutorials/gwt/retrieving-xml-data.shtml
The only downside is that you have to manually parse XML via DOM, where GWT-RPC directly produces objects.
Update:
based on the comments I'd recommend this:
Parse XML file with JAXB to create your objects: http://jaxb.java.net/guide/_XmlRootElement_and_unmarshalling.html
Save those to memcache: http://code.google.com/appengine/docs/java/memcache/overview.html
On RPC request, check memcache, if data not there goto 1.
在我看来,存在两个相互关联的瓶颈。一是加载数据(从 XML 读取、解析)。另一种是将其发送给客户。
您可以考虑批量发送,例如分页,而不是发送整堆。
通常我更喜欢将此类文件存储在 WEB-INF 下。
The way I look at things, there are two bottle necks, though interrelated. One is loading the data (reading from XML, parsing). Another is sending it to the client.
Instead of sending the whole bunch, you might consider batch sending, like pagination.
Usually I prefer storing such files under WEB-INF.