PHP connection Cassandra slow problem solution (using Cassandra with PHP)

Source: Internet
Author: User
Tags cassandra

Https://wiki.fourkitchens.com/display/PF/Using+Cassandra+with+PHP

1. Down the thrift code.

 
Http://incubator.apache.org/thrift/download/

2. Building the PHP Client
2.1 configure and build thrift.

 
./Configuremake

2.2 build the PHP thrift interface for Cassandra:

 
./Compiler/CPP/thrift-gen PHP ../path-to-Cassandra/interface/Cassandra. Thrift


2.3 copy the include files to a useful place (per the Cassandra "Getting started" Guide ):

 
Mkdir-P/usr/share/PHP/thriftcp-r gen-PHP // usr/share/PHP/thrift/packages/CP-r lib/PHP/src/*/usr /share/PHP/thrift/

3. Building and installing the native PHP Extension

 
Installing and using the native PHP extension provides approximately a ten-fold performance boost on writing data.

3.1 change to path-to-Thrift/lib/PHP/src/EXT/thrift_protocol.
3.2 install support for building PHP extensions:

/Usr/local/webserver/PHP/bin/phpize./configure -- enable-thrift_protocol -- With-PHP-Config =/usr/local/webserver/PHP/bin/PHP-configmake

3.3 copy the extension's. So to the extensions directory.

 
CP modules/thrift_protocol.so/usr/local/webserver/PHP/lib/PHP/extensions/no-debug-non-zts-20060613/

3.4 enable the module.

Edit PHP. ini and add: Extension = thrift_protocol.so

3.5 then restart PHP-FPM
4. Checking the connection
4.1 copy in the PHP from the Cassandra client examples page to/var/www/cassandra-test.php.
4.2 visit http: // localhost/cassandra-test.php in the browser.
4.3 On the first load, the array output shocould be empty. On the second, there shocould be content.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.