Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Using TBinaryProtocolAccelerated (with additional requirements) at initialization of instead of TBinaryProtocol greatly speeds up I/O on Cassandra #12

redsolar opened this Issue · 1 comment

2 participants


For production needs, and on properly configured thrift clients (described below) it would be best to use TBinaryProtocolAccelerated which uses binary serialization, which in turn significantly speeds up I/O from a thrift/php client to/from cassandra cluster.

in Pandra.class.php replace
'client' => new CassandraClient(new TBinaryProtocol($transport))
'client' => new CassandraClient((function_exists("thrift_protocol_write_binary") ? new TBinaryProtocolAccelerated($transport) : new TBinaryProtocol($transport)))

There are a few things that need to happen for this to work (i.e. "properly configured thrift clients")
1. PECL APC must be compiled and added to php.ini (or /etc/php.d/apc.ini)
2. [which provides thrift_protocol_write_binary()] must be compiled and added to php.ini (or /etc/php.d/thrift.ini)

APC is well documented, to compile in thrift-php/ext/thrift_protocol:
make install
cp /usr/lib64/extensions/no-debug-non-zts-XXXXXXXX/ /usr/lib64/php/modules

(XXXXXXXX will vary depending on your php version)

edit php.ini or (preferred) /etc/php.d/thrift.ini to include ""

After that, phpinfo() will contain a thrift protocol section (Version 1.0) and function_exists("thrift_protocol_write_binary") will return true.

In my testing, the benefit of using thrift+apc binary was approximately 400% on very heavy writes (~80,000 per second vs ~20,000 using fallback mechanism)


Thanks for the great help, tested and committed pandra.class.php fix. Documentation on the way.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.