简体   繁体   English

为外部站点创建可扩展的动态 xml 以读取的最佳方法是什么?

[英]What is the best way to create scalable dynamic xml for external sites to read?

Currently we create huge xml files for several hundreds of users and each of the xml file contains thousands of lines and requires a lot of ram to create/read them.目前,我们为数百个用户创建了巨大的 xml 文件,每个 xml 文件都包含数千行,并且需要大量 ram 来创建/读取它们。

We wanted to create a way of providing dynamic xml files for other sites to read but it would normally kill our servers because they would constantly request the xml files and our server wasn't capable of delivering so much data in a short amount of time.我们想创建一种提供动态 xml 文件供其他站点读取的方法,但它通常会杀死我们的服务器,因为它们会不断请求 xml 文件,而我们的服务器无法在短时间内提供如此多的数据。 After seeing this, we opted to create static xml files and store them on a s3 bucket for the sites to read whenever they wanted to and our servers wouldn't need to take the huge blow of the requests.看到这一点后,我们选择创建静态 xml 文件并将它们存储在 s3 存储桶中,以便站点可以随时读取,并且我们的服务器不需要承受请求的巨大打击。 This works, however we're also seeing the limits of our solution.这行得通,但是我们也看到了我们解决方案的局限性。 We're storing thousands of xml with exactly the same fields except for a few of them that changes based on the user data.我们存储了数千个具有完全相同字段的 xml,除了其中一些会根据用户数据而更改。

Is there a way of creating a skeleton xml that allows us to have dynamic values, not make us unnecessarily store the xmls, and does not hugely burden our servers?有没有一种方法可以创建一个框架 xml,它允许我们拥有动态值,而不是让我们不必要地存储 xml,并且不会给我们的服务器带来巨大的负担? What would be the best/most scalable way of approaching this problem?解决此问题的最佳/最具可扩展性的方法是什么? Open to trying new architectures or frameworks to test out solutions.愿意尝试新的架构或框架来测试解决方案。

How about using XML entities?使用 XML 实体怎么样?

You can define your XML to use entity references for the variable parts您可以定义 XML 以使用可变部分的实体引用

<user>&username;</user>

and define the values of the entities in an external DTD.并在外部 DTD 中定义实体的值。 Your XML parser will expand the entity references while parsing.您的 XML 解析器将在解析时扩展实体引用。 Most XML parsers have some way of allowing the application to redirect the DTD filename that's hard-coded in the XML to a file that's dynamically supplied by the application.大多数 XML 解析器都有某种方式允许应用程序将在 XML 中硬编码的 DTD 文件名重定向到由应用程序动态提供的文件。

DTDs and entities are a bit out of fashion, to the extent that some XML parsers don't support them, but they meet this requirement pretty well. DTD 和实体有点过时了,以至于某些 XML 解析器不支持它们,但它们很好地满足了这个要求。

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

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