Zend AMF 优化;提示和技巧?

发布于 2024-10-04 13:26:36 字数 247 浏览 3 评论 0原文

我正在开发一个项目,该项目使用 PHP 创建一个“复杂”对象,其中包含对链接回其父对象等的其他对象的大量引用...

然后,对象结构由 序列化>Zend AMF 模块并发送到 Flex 应用程序。

问题是序列化需要大量时间(+10秒)。

因此,我的问题是:任何人都可以给我有关序列化如何工作以及如何优化对象结构以使序列化运行得更快的提示吗?

I am working on a project that uses PHP to create an 'complex' object with lots of references to other objects linking back to their parent objects etc...

The object structure is then serialized by the Zend AMF module and sent over to the flex application.

The problem is that serialization takes a lot of time (+10sec).

My question is thus: can anybody give me tips on how the serialization works and in what way I may be able to optimize the object structure in order to make serialization run faster?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

飘然心甜 2024-10-11 13:26:36

切换到 JSON 将有助于解决这个问题,因为它可以更轻松地进行缓存。

APC 也将提供帮助,只是用于操作码缓存部分,而不是用于在内存中存储对象。

这个物体到底有多大?不发送全部内容值得吗?如果您只是处理记录集,则可以通过仅下载用户可以看到或在不久的将来会看到的内容来在前端修复它。

Switching to JSON will help a great deal with this, as it allows easier caching.

APC will also help, just for the opcode-cache part, not for storing objects in memory.

How big is this object exactly? Could it be worth it not sending the entire thing? If you're just dealing with recordsets, you might be able to fix it in the frontend by only downloading only what the user can see, or will see in the near future.

屋顶上的小猫咪 2024-10-11 13:26:36

默认序列化器将迭代每个属性,如果属性是一个对象,它将迭代每个对象及其属性,直到完成。

由于您的对象很复杂,因此需要进行大量处理并且要序列化多个级别的对象。

作为优化的一个点,您可能希望考虑在对象上实现可序列化接口,并序列化您需要序列化并通过线路发送到 Flex 应用程序的最少量信息。

The default serializer will iterate through every property, if a property is an object it will then iterate through each of those objects and their properties until it's done.

Since your object is complex, there's lots of crunching going on and many levels of objects that are being serialized.

As a point of optimization you may wish to look into implementing the serializable interface on your objects and serializing the minimal amount of information you require to be serialized and sent over the wire to your Flex app.

http://php.net/manual/en/class.serializable.php

守护在此方 2024-10-11 13:26:36

在进行 AMF 序列化或任何与此相关的序列化时,如果考虑性能,通常最好使用较小的数据片段。通过这样做,您可以将单个对象作为真正的 ActionScript 对象来使用,而不仅仅是数据占位符。执行任何类型的 RPC 时,数据越小通常效果越好。您可以使用 JSON 来代替,但是这样您就会失去使用 AMF 获得的紧密数据绑定。因此,请尝试使用多个 HTTP 请求来处理较小的数据包。

When doing AMF serialization, or any serialization for that matter, it is usually better to work with smaller pieces of data if performance is a concern. By doing that you can work with individual objects as true ActionScript objects instead of just data placeholders. Smaller data when doing any type of RPC is usually better. You could use JSON instead, but then you'd loose the tight data binding that you get from using AMF. So try working with smaller packets of data using multiple HTTP requests.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文