rti/FastXml 或类似的东西可以与 Rails 3 配合使用来加速 xml 渲染吗?
我们在 rails 3 中实现了一个 REST API,它使用 yajl
后端来处理 json
。目前,当序列化超过 20 行时,它生成 json
响应的速度明显快于 xml
。
我的下一个想法是,rail 3 必须有一个类似的 C 库,它将使用 libxml
或类似的 to_xml
,就像我们已经在使用的那样libyajl
为 to_json
。
迄今为止,我只找到了 rti/FastXml 项目:https://github。 com/rti/FastXml
它声称是我想要的,但自 2010 年初以来就没有更新过,并且没有可见的分叉。
有谁知道FasterXml是否适用于rails 3?
更重要的是,有谁知道任何其他方法可以让 Rails 3 进行更快的渲染:xml => @搜索结果?
非常感谢您的帮助。
We have a REST api implemented in rails 3, which is using the yajl
back-end for json
. It is currently generating json
responses significantly faster than xml
when serializing more than about 20 rows.
My next thought was that there must be a similar C-library drop-in for rail 3, which would use libxml
or similar for to_xml
, just as we're already using libyajl
for to_json
.
To date, I've found only the rti/FastXml project: https://github.com/rti/FastXml
It claims to be what I want, but hasn't been updated since early 2010, and has no visible forks.
Does anyone know if FasterXml works (or not) with rails 3?
More importantly, does anyone know any other ways to get rails 3 to do a faster render :xml => @search_results
?
Many thanks for any help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通过
ab
测试一些 Rails 3 配置选项:XmlMini_LibXML
、XmlMini_Nokogiri
、fast_xs
。以下请求以嵌套 ruby 哈希的形式返回大约 50k 的搜索结果,数据来自 memcached,因此这里的时间差异在于将结果编码为 xml 或 json。
摘要:
添加 gem
fast_xs
似乎可以将 XML 时间减少一半,其他则没有效果。JSON(yajl)
XML(rails 3.0.3 默认值)
XML (XmlMini_LibXML)
XML (XmlMini_Nokogiri)
XML(默认值 + fast_xs)
XML(XmlMini_LibXML + fast_xs)
XML(XmlMini_Nokogiri + fast_xs)
JSON(yajl + fast_xs)
Tests of a few rails 3 config options, via
ab
:XmlMini_LibXML
,XmlMini_Nokogiri
,fast_xs
.The following request returns about 50k of search results in the form of nested ruby hashes, with the data coming from memcached, so that the time differences here are in encoding the results into xml or json.
SUMMARY:
Adding gem
fast_xs
appears to cut XML time in half, others have no effect.JSON (yajl)
XML (rails 3.0.3 defaults)
XML (XmlMini_LibXML)
XML (XmlMini_Nokogiri)
XML (defaults + fast_xs)
XML (XmlMini_LibXML + fast_xs)
XML (XmlMini_Nokogiri + fast_xs)
JSON (yajl + fast_xs)