Thursday, October 01, 2009

A simple load test in Terracotta...

This is a response to the following blog in which the author wrote a micro-benchmark and got some pretty bad results using Terracotta http://zion-city.blogspot.com/2009/10/terracotta-as-distributed-dbms-bad-idea.html.

Since the commenting system on blogger doesn't allow code, I am posting the response on my blog with code attached for reference.

So my approach was to try replicate the author's implementation, to see what kind of performance a straightforward micro-benchmark might achieve.

Reader beware - micro-benchmarks are never a good idea, and not usually indicative of real-world performance. In this case, based on real-world results I have seen, my results appear to be a lower bound for the kind of performance one should expect since the test isn't concurrent and is running on a single machine - hardly the kind of environment a real world clustered app would exist in)

So, with that said, I wrote a simple load test against a ConcurrentHashMap, and put 100,000 objects into it.

My results show:
Avg TPS: ~3,000
Instantaneous TPS as high as: ~7,000

Here's the code:

import java.util.Date;
import java.util.Map;
import java.util.concurrent.*;

public class Main
{
static Map<Integer, Foo> map =
new ConcurrentHashMap<Integer, Foo>();

public static class Foo
{
public String name;
public String name2;
public String name3;

public Foo(String name)
{
this.name = name;
this.name2 = name + " 2";
this.name3 = name + " 3";
}
}

public static void main(String[] args)
{
long start = System.currentTimeMillis();

for (int i = 0; i < 100000; i++) {
map.put(i, new Foo(new Date().toString()));
}
System.out.println("elapsed: " + (System.currentTimeMillis() - start));
}
}


And here's the tc-config.xml:
<?xml version="1.0" encoding="UTF-8"?>
<tc:tc-config xmlns:tc="http://www.terracotta.org/config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.terracotta.org/schema/terracotta-5.xsd">
<application>
<dso>
<instrumented-classes>
<include>
<class-expression>Main$Foo</class-expression>
</include>
</instrumented-classes>
<roots>
<root>
<field-name>Main.map</field-name>
</root>
</roots>
</dso>
</application>
</tc:tc-config>


I took a screenshot of the dev console running during the test, to give you an idea of the instantaneous TPS achieved:

5 comments:

cool said...

租辦公室租店面買辦公室店面租賃店面出租店面出售花茶花草茶養生茶招牌led招牌招牌製作美國月子中心保養美國月子中心OBU投審會會計師事務所會計師工商登記公司登記包子肉粽宅配美食四神湯搬家公司訂房訂房網花東旅遊桃園土地桃園房屋仲介桃園房屋桃園房屋網桃園房屋買賣漆彈搬家公司會場設計展場設計會場設計展場設計展覽設計消防設備消防設備機電崴立機電消防公司地板施工超耐磨地板店面出租乳癌全身健康檢查肝癌健康檢查身體檢查飛梭雷射雷射溶脂直航機票自由行三久太陽能三久太陽能太陽能熱水器別墅外觀設計環保袋別墅外觀設計室內裝修電波拉皮hand dryer電波拉皮雷射溶脂肉毒桿菌系統家具台中漆彈場漆彈團體服美國月子中心團體服

cool said...

團體服團體服T恤圍裙POLO衫班服團體服創意熱轉印團體服訂做宜蘭民宿關鍵字廣告seo網路廣告網路行銷seo網站設計seo線上客服seo網頁設計seo網頁設計公司網路行銷網路行銷桃園室內設計室內設計作品室內裝潢裝潢室內設計室內設計公司裝潢設計豪宅空間設計店面設計豪宅設計桃園室內設計公司別墅外觀設計室內裝潢設計台北室內設計新竹室內設計法拍屋中古車二手車環保袋環保袋肉毒桿菌健檢醫學美容淨膚雷射汽車美容法拍屋水餃清潔公司實驗動物到府坐月子坐月子坐月子中心坐月子餐孕婦月子餐到府坐月子坐月子坐月子中心坐月子中心台中坐月子中心台北月子餐月子中心坐月子餐月子餐外送

cool said...

月子餐食譜找工作統一發票7 8月求職1111求職人力銀行104求職人力銀行104人力銀行統一發票5 6月104人力銀行104求職人力銀行塑膠袋統一發票1 2月塑膠袋批發塑膠袋工廠金價黃金價格統一發票3 4月1111人力銀行1111人力銀行求職黃金價格查詢中古車買賣塑膠袋統一發票3 4月塑膠袋批發中古車中古車買賣台北人力銀行金價查詢sum中古車中古車貸款信用貸款房屋貸款剖腹生產 命理網 姓名學 姓名配對 星座 星座運勢 算命 開運印章 風水 外遇 徵信 徵信社 外遇 徵信 徵信社 外遇 徵信 徵信社 外遇 徵信 徵信社 外遇 徵信 徵信社 外遇 徵信 徵信社 搬家公司 搬家公司 台北搬家公司 新竹搬家公司

haha said...

Nice BLOG.................................................

pbsl said...

you have a nice site.thanks for sharing this site. various kinds of ebooks are available here

http://feboook.blogspot.com