Pb (stands for Perspective broker), a built-in rpc lib of twisted has been used widely.
Pb supports py built-in types directly like: int, list, dict ...
complex object need extra effort to be transferred on wire.
Pb serialization sucks...if arugments are complex...like following:
val = {"hello":"hello","foo":"bar","baz":100,u"these are bytes":(1,2,3)}
it takes very long time to process... in my machine (IBM T400)
only 1100 req/second...it is too slow...
how to speed up? a simple answer is : use another serialization method..
I use bson. you may freely choose cPicke, marshal or protobuf.
we send string directly and then deserialize manually.
Is it better??
it is three times faster... the machine can process 3300 req/second...
the second way is to use pypy....
本文讨论了Twisted内置RPC库PB在处理复杂数据类型时的性能问题,并提出了两种解决方案:一是采用更高效的序列化方法如BSON;二是使用PyPy替代CPython来提高处理速度。

被折叠的 条评论
为什么被折叠?



