Try Cassandra, the efficiency of their bad writing

2010-03-16  来源:本站原创  分类:Database  人气:496 

Cassandra is a distributed database open source contribution Facebook. Their compliance NoSql idea, is a combination of the product of Dynamo and BigTable. Recent Twitter and Digg will move its database from the MySql Cassandra. See the good momentum of development, I downloaded and made a test.

Test environment:

Were deployed in the two machines cassandra. Here that the next key configuration:
Configuration file path is% Cassandra_Home% \ conf \ storage-conf.xml

<Storage>
<!-- The ClusterName two machines must be the same  , As a group identity   -->
    <ClusterName>BurceServers</ClusterName>
  <AutoBootstrap>false</AutoBootstrap>

    <Keyspaces>
    <Keyspace Name="Keyspace1">
            <KeysCachedFraction>0.01</KeysCachedFraction>
            <ColumnFamily CompareWith="BytesType" Name="Standard1"/>
      <ColumnFamily CompareWith="UTF8Type" Name="Standard2"/>
      <ColumnFamily CompareWith="TimeUUIDType" Name="StandardByUUID1"/>
      <ColumnFamily ColumnType="Super"
                    CompareWith="UTF8Type"
                    CompareSubcolumnsWith="UTF8Type"
                    Name="Super1"
                    Comment="A column family with supercolumns, whose column and subcolumn names are UTF8 strings"/>
    </Keyspace>
  </Keyspaces>

    <Partitioner>org.apache.cassandra.dht.RandomPartitioner</Partitioner>

    <InitialToken></InitialToken>

  <EndPointSnitch>org.apache.cassandra.locator.EndPointSnitch</EndPointSnitch>

    <ReplicaPlacementStrategy>org.apache.cassandra.locator.RackUnawareStrategy</ReplicaPlacementStrategy>

    <ReplicationFactor>1</ReplicationFactor>

  <CommitLogDirectory>c:/cassandra/lib/cassandra/commitlog</CommitLogDirectory>
  <DataFileDirectories>
      <DataFileDirectory>c:/cassandra/lib/cassandra/data</DataFileDirectory>
  </DataFileDirectories>
  <CalloutLocation>c:/cassandra/lib/cassandra/callouts</CalloutLocation>
  <StagingFileDirectory>c:/cassandra/lib/cassandra/staging</StagingFileDirectory>

<!-- Here you can add multiple cassandra Server  -->
    <Seeds>
      <Seed>10.219.101.101</Seed>
<Seed>10.219.101.121</Seed>
  </Seeds>

    <RpcTimeoutInMillis>5000</RpcTimeoutInMillis>
    <CommitLogRotationThresholdInMB>128</CommitLogRotationThresholdInMB>

<!-- Listening address must be native  IP-->
    <ListenAddress>10.219.101.101</ListenAddress>
   <StoragePort>7000</StoragePort>
    <ControlPort>7001</ControlPort>
<!-- Based on the Thrift  cassandra Clients listen address  -->
    <ThriftAddress>10.219.101.101</ThriftAddress>
    <ThriftPort>9160</ThriftPort>
    <ThriftFramedTransport>false</ThriftFramedTransport>

    <SlicedBufferSizeInKB>64</SlicedBufferSizeInKB>

   <ColumnIndexSizeInKB>64</ColumnIndexSizeInKB>

    <MemtableSizeInMB>64</MemtableSizeInMB>

  <MemtableObjectCountInMillions>0.1</MemtableObjectCountInMillions>
    <MemtableFlushAfterMinutes>60</MemtableFlushAfterMinutes>

    <ConcurrentReads>8</ConcurrentReads>
  <ConcurrentWrites>32</ConcurrentWrites>

    <CommitLogSync>periodic</CommitLogSync>
    <CommitLogSyncPeriodInMS>10000</CommitLogSyncPeriodInMS>
  <GCGraceSeconds>864000</GCGraceSeconds>
  <BinaryMemtableSizeInMB>256</BinaryMemtableSizeInMB>

</Storage>

Apart from the addition of a cassandra the server, the basic use of the default configuration.

Test code:

/**
 *
 */
package com.tpri.sis.test;

import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;

import me.prettyprint.cassandra.service.CassandraClient;

import org.apache.cassandra.service.Cassandra;
import org.apache.cassandra.service.ColumnPath;
import org.apache.cassandra.service.ConsistencyLevel;
import org.apache.cassandra.service.InvalidRequestException;
import org.apache.cassandra.service.TimedOutException;
import org.apache.cassandra.service.UnavailableException;
import org.apache.commons.lang.RandomStringUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.thrift.TException;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.transport.TSocket;
import org.apache.thrift.transport.TTransport;
import org.apache.thrift.transport.TTransportException;

/**
 * @author brucepang
 *
 */
public class CassandraClientDemo {

        /**
         *
         */
        public CassandraClientDemo() {

        }

        /**
         * @param args
         */
        public static void main(String[] args) {

                try {
                        TTransport tr = new TSocket("10.219.101.101", 9160);

                        TProtocol pro = new TBinaryProtocol(tr);
                        Cassandra.Client cli = new Cassandra.Client(pro);
                        tr.open();

                        String key = null;
                        String name, age;
                        ColumnPath namePath = new ColumnPath("Standard1", null, "name"
                                        .getBytes("UTF-8"));
                        ColumnPath agePath = new ColumnPath("Standard1", null, "age"
                                        .getBytes("UTF-8"));

                        String keySpace = "Keyspace1";
                        long time = 0;
                        long l1 = System.currentTimeMillis();
                        for (int i = 0; i < 100; i++) {
                                key = String.valueOf(i);
                                name = RandomStringUtils.random(5,"abcdefghefsdf");
                                time = System.currentTimeMillis();
                                cli.insert(keySpace, key, namePath, name.getBytes("UTF-8"),
                                                time, ConsistencyLevel.ONE);
                                cli.insert(keySpace, key, agePath, key.getBytes("UTF-8"), time,
                                                ConsistencyLevel.ONE);
                        }
                        long l2 = System.currentTimeMillis();
                        long ch = l2 - l1;
                        System.out.println(ch);

                } catch (TTransportException e) {
                        e.printStackTrace();
                } catch (UnsupportedEncodingException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                } catch (InvalidRequestException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                } catch (UnavailableException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                } catch (TimedOutException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                } catch (TException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }

        }
}

Test results: 1 write data 100, time-consuming 59 922 milliseconds, nearly 1 minute;

相关文章
  • Try Cassandra, the efficiency of their bad writing 2010-03-16

    Cassandra is a distributed database open source contribution Facebook. Their compliance NoSql idea, is a combination of the product of Dynamo and BigTable. Recent Twitter and Digg will move its database from the MySql Cassandra. See the good momentum

  • UI Automation scripting efficiency 2011-08-29

    Share automation project page (c) - Scripting efficiency In the script writing process, we will one by one letter in a text editor on the coding, once the idea of ​​running the complete script, you will find here the statement block of more than one

  • basic tutorial python 2010-04-21

    Python is an interpreted programming language. The same as Java source code must first be converted into bytes by the compiler Sudden (Byte code), then the interpreter to execute the bytecode. And Java is not the same, Python compiler and interpreter

  • Fitnesse for designer 2011-03-23

    For the design, our current existence of such problems: test code imperfect enough, that there is a bad bug, found a good position to change over may lead to other problems and test code that ran. Think about this previously defined "root cause"

  • The most complete oracle notes 2010-12-08

    Oracle SQL day1 Oracle SQL (Oracle 9i 9.2.0.1.0) A, DataBase Save data to the table in the form of performance data Second, SQL SQL (structure query language Structured Query Language), is operating in an object relational database DDL (data definiti

  • Possible reasons for slow database query 2011-08-08

    Query slow for many reasons, it is common the following categories: 1, there is no index or index is not used (this is the most common query slow problem is programming defects) 2, I / O throughput is small, the formation of a bottleneck effect. 3, d

  • Writing Efficient CSS - CSS rendering efficiency Talk 2010-04-23

    Summarizes some of the school, hear, see, by asking some of the CSS writing experience, writing efficient CSS - Talk CSS rendering efficiency, they are occupied with rendering efficiency and resource consumption associated with a certain. Written by

  • Turn: Cassandra Description 2010-07-15

    Cassandra: Details, see: http://www.cnblogs.com/gpcuster/tag/Cassandra/ Cassandra is a mixed-type non-relational database, similar to Google's BigTable. Its main function than Dynomite (Distributed Key-Value storage system) even richer. Cassandra was

  • facebook database Cassandra (1): Introduction and Tutorial windows install Cassandra Photo 2010-11-29

    Cassandra Introduction (Note: This section describes baidu from Wikipedia) Cassandra is a mixed type of non-relational database, similar to Google's BigTable. Its main function than Dynomite (Distributed Key-Value storage system) is more abundant, bu

  • cassandra entry summary 2011-10-19

    Contents I., Cassandra frame two, Cassandra data model Colum / Colum Family, SuperColum / SuperColum Family Colum sorting Third, the partitioning strategy Token, Partitioner bloom-filter, HASH Fourth, the copy of the storage 5, the network sniffer si

  • Brief MyEclipse of some common concepts and operations to improve the efficiency of the development of 2010-03-29

    (Today the Internet is a bit shortcuts to share) a brief MyEclipse some of the commonly used concepts and operations to improve the efficiency of the development of Software Engineer: Back Qinbo 2010-02-10 17:43 Project (Project) Eclipse all the reso

  • To improve the efficiency of the method run 2010-04-04

    The browser sends a request, the background will go through three steps: database, data is loaded - "business logic processing of data -" data page display. Are likely to experience a step in any performance bottlenecks, and some bottlenecks hav

  • Cassandra 4 data consistency easily comprehensible overview of issues 2010-03-20

    / ** * author: ahuaxuan (Rong-Hua Zhang) * date: 2010-2-28 * / In the last article, ahuaxuan and everyone familiar with the simple deployment of cassandra cluster environment, the next to do is to engage in such a deployment model of clear theoretica

  • Installation cassandra 2010-03-16

    cassandra is now very fire ah, twitter, and digg are using it, including of course Facebook has. Promising a thing. One aspect is technical. For the post-web 2.0 era to find a new technological breakthrough (of course the first thing bigtable, and un

  • Writing and computer technology 2010-04-11

    Computer is an epoch-making invention. It profoundly affected every aspect of society, including the writing. Papermaking and printing are listed as four great inventions of ancient China, because of the convenience of providing the writing has great

  • Multi-threaded + socket + file reading and writing (surface) 2010-04-11

    Note: This document, just before the multi-threading, socket, file read and write the basis of three documents, as a key part of integration. Because the socket will be used in multi-threaded, and documents to read and write to facilitate the overall

  • oracle how to improve the efficiency 2010-05-04

    At the outset, I turn to others this is the article, I copy over from that link is transferred, so do not know where the original is, if offended please forgive! Minimize the use of IN operator, essentially all of the IN operator can be replaced with

  • 75 Effective writing software recommendation 2010-06-02

    1. Your team to use source code management tool Why? Should be used. VSS, CVS, PVCS, ClearCase, CCC / Harvest, FireFly can. My choice is VSS. 2. Your team using the defect management system put into effect? Should be used. ClearQuest is too complicat

  • Js efficiency on a small trick 2010-07-05

    Bo opened the matter, to write about this a few days work a little experience it! After more than a point here, summing up his gains, if lucky enough to be seen, also please let us know. As we all know, js in ie browsers efficiency is not good, so wh

  • Cassandra impact on performance in rowcached 2010-07-08

    Cassandra has been doing testing, but test results are provided with the official write fast, slow reading opposite of the situation. Have not found the answer. Recent data in the big test when reminded of conf / storage-conf.xml in this field rowcac