I had the same issue using a single thread but now I multi-thread the batch_insert calls using a java.util.concurrent.ThreadPoolExecutor (wrapped in some Scala syntactic sugar) and get good write performance.
-Tim On Thu, Nov 19, 2009 at 5:34 AM, Jonathan Ellis <[email protected]> wrote: > your biggest problem is you are only using one client thread. > > you should also set log level to INFO. > > On Thu, Nov 19, 2009 at 6:01 AM, ROGER PUIG GANZA <[email protected]> wrote: > > Hello, I’ doing some tests with Cassandra, but I get a very slow > > performance, it does 100.000 inserts in 215 seconds while mysql takes 79 > > secs > > > > The code below is the one I’m using, is there anything wrong with my > > Cassandra or java understanding? > > > > The configuration-file params are the default ones. > > > > Thank you! > > > > > > > > cassandraInserter(){ > > > > long ini = System.currentTimeMillis(); > > > > TTransport tr = new TSocket(ip, port); > > > > TBinaryProtocol proto = new TBinaryProtocol(tr); > > > > Client client = new Client(proto); > > > > > > > > try { > > > > tr.open(); > > > > } catch (TTransportException e1) { > > > > e1.printStackTrace(); > > > > } > > > > > > > > for (int i = 0; i < N; i++) { > > > > try { > > > > long timestamp = System.currentTimeMillis(); > > > > List<ColumnOrSuperColumn> columns = new > > ArrayList<ColumnOrSuperColumn>(); > > > > Map<String, List<ColumnOrSuperColumn>> map = new > > HashMap<String, List<ColumnOrSuperColumn>>(); > > > > > > > > columns.add(new ColumnOrSuperColumn(new > Column(col1, > > data, timestamp), null)); > > > > columns.add(new ColumnOrSuperColumn(new > Column(col2, > > data, timestamp), null)); > > > > columns.add(new ColumnOrSuperColumn(new > Column(col3, > > data, timestamp), null)); > > > > columns.add(new ColumnOrSuperColumn(new > Column(col4, > > data, timestamp), null)); > > > > columns.add(new ColumnOrSuperColumn(new > Column(col4, > > data, timestamp), null)); > > > > columns.add(new ColumnOrSuperColumn(new > Column(col5, > > data, timestamp), null)); > > > > columns.add(new ColumnOrSuperColumn(new > Column(col6, > > data, timestamp), null)); > > > > columns.add(new ColumnOrSuperColumn(new > Column(col7, > > data, timestamp), null)); > > > > columns.add(new ColumnOrSuperColumn(new > Column(col8, > > data, timestamp), null)); > > > > acl.put(colfamily, columns); > > > > client.batch_insert(keyspace, key, map, > > ConsistencyLevel.ONE); > > > > } catch (TTransportException e) { > > > > e.printStackTrace(); > > > > } catch (UnsupportedEncodingException e) { > > > > e.printStackTrace(); > > > > } catch (InvalidRequestException e) { > > > > e.printStackTrace(); > > > > } catch (UnavailableException e) { > > > > e.printStackTrace(); > > > > } catch (TException e) { > > > > e.printStackTrace(); > > > > } > > > > } > > > > tr.close(); > > > > } > > > > > > > > Roger Puig Ganza > > > > >
