Dec 15, 2011

[Java Performance]Chapter 1:Strategies, Approaches, and Methodologies

在軟體開發流程中該在何時評估效能?
傳統上瀑布式開發(Analysis > Design > Code > Test)會在測試階段進行效能測式,當效能結果不符合要求,調整代價可能很高,因此在擬定需求時就需要將效能指標定義出來,由需求驅動開發過程中各階段的效能測試
  • 期望的throughput為多少?
  • 期望latency為多少?
  • 要能負載多少的 concurrent users 或者 concurrent tasks?
  • 在最大數量的 concurrent users 或者 concurrent tasks負載下,可接受的latency 或者throughput為多少?
  • 最糟糕狀況下可接受的latency為多少?
  • garbage collection 引入的延遲否容許?
假設某些use case可能造成高度的效能風險,那應該在Analysis階段之前製作prototype驗證效能的可行性

Dec 6, 2011

Java時間解析度

Inside the Hotspot VM: Clocks, Timers and Scheduling Events - Part I - Windows 說明作業系統在讀取時間與時間event(schedule/trigger)的限制,因此從java api取得的 nanosecond 的數值並不精確,越高的解析度(nanoseconds > microseconds > milliseconds)精確度越低,文中也提供了些使用上的建議。
  • 需要讀取精確的時間使用 System.currentTimeMillis()
  • 需要比較時間差異使用 System.nanoTime()
  • 需要等待系統回應(e.g. wait/sleep),設定時間別小於10 milliseconds

Nov 21, 2011

Memcached vs Redis vs MongoDB vs MySQL 效能比較

"記憶體是新一代的硬碟"在高流量網站內已是稀鬆平常的事情,像是採用 Memcached 做分散式快取服務即是典型的應用模式,Memcached 使用概念簡單且相關應用情境、文件、工具、演算法都已相當成熟,許多知名網站都運用 Memcached 提升scalability,像是GAE、Heroku 等PaaS 環境也有提供 Memcached 的收費服務,這些市場訊息已說明大規模的使用記憶體是可以合乎成本效益的。

Redis 是近年隨著 NoSQL 熱潮出現的 Key-Value store,其功能涵蓋了 Memcached 並且提供許多高階功能,在許多應用情境下相較 Memcached,能降低開發與營運複雜度,比如:
  • 豐富的資料結構(strings, hashes, lists, sets and sorted sets) 更易於設計適當的資料粒度增進資料重用的機會,且可依不同的資料結構特性在redis server上做組合與計算,降低開發上的複雜度與資料傳輸
  • 永續保存功能可充當簡易的資料庫降低重覆資料的一致性問題或一些特殊應用,像是當系統當機後能快速回復快取資料,避免大量重建的衝擊
  • 資料覆寫功能 提升讀取效能,提升 availability
  • 2.6可以寫script (lua)
  • 3.0版本預期還會加上Cluster做HA與Balancing有些data grid的樣子

但效能是否能與 Memcached 匹敵呢?以下透過大量的 get/set 操作做簡單的比較,並且加入MySQL與MonogoDB 做為參考

Feb 17, 2009

Subscription TV programs from Yahoo Pipe

Are you always missing TV programs or checking menu each day, so I create a pipe using Yahoo Pipe that can help you comfortable get TV programs timetable by RSS.
Limitation:
The pipe just support 200 item maximal.
The date range within five day.
1.Open Browser and jump to the pipe.
image
2.Enter keyword of TV program in the textbox after them click Run Pipe.
image image
3. Right click Get as RSS , select Copy Link Location.
image
4.Jump to xFruits and then sign up a account by yourself.
image image
5. I would like to get notifications by Mail so that click RSS to Mail and then fill the form.
image
image
6.Well, You will get mail very soon.
image
Resources:
Pipes: Rewire the web
http://pipes.yahoo.com/pipes/
xFruits - Compose your information system
http://www.xfruits.com/
Yahoo! Pipes Tutorial - An example using the Fetch Page module to make a web scraper
http://www.daybarr.com/blog/2007/12/11/yahoo-pipes-tutorial-an-example-using-the-fetch-page-module-to-make-a-web-scraper
電視時刻 - Yahoo!奇摩電影
http://tw.movie.yahoo.com/tv_index.html
The Regex Coach - interactive regular expressions
http://weitz.de/regex-coach/index.html
Java Regular Expression的學習筆記
http://www.javaworld.com.tw/jute/post/view?bid=20&id=130126&sty=1&tpg=2&age=0

Feb 4, 2009

How to create kmz with picture icon

1. Take pictures and star GPS logger
2. Write geo-information to pictures(To reference posted article:GPS 記錄器、相簿、工具、節點編輯...)
3. Launch Friendly Flicker
4.open a text file and put into below text and save to doc.kml(UTF8 format)
doc.kml

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.1">
<Document>
<name>Recent Uploads with geodata</name>
<open>1</open>

</Document>
</kml>

clip_image002
image
5. click tab “選項”then select all options.
image
6.Select “清單顯示”that faster than icon mode.
image
7. Input search conditions then click “搜尋相片.
image
8.While all of picture information loaded. right click on list and select "選擇全部相片”
image
9.Copy below text then put into firendly flickr.

<style id="normal/photo/{url}"><br />       <labelstyle><br />           <color>00ffffff</color><br />           <scale>1</scale><br />       </labelstyle><br />       <iconstyle><br />           <scale>2</scale><br />           <hotspot x="0.5" y="0.5" xunits="fraction" yunits="fraction"><br />           <icon><br />               <href>{image_st}</href><br />           </icon><br />       </iconstyle><br />   </style>
<style id="highlight/photo/{url}"><br />       <labelstyle><br />           <color>ffffffff</color><br />           <scale>1</scale><br />       </labelstyle><br />       <iconstyle><br />           <scale>2</scale><br />           <hotspot x="0.5" y="0.5" xunits="fraction" yunits="fraction"><br />           <icon><br />               <href>{image_st}</href><br />           </icon><br />       </iconstyle><br />   </style>
<stylemap id="styleMap/photo/{url}">
   <pair>
     <key>normal</key>
     <styleurl>#normal/photo/{url}</styleurl>
   </pair>
   <pair>
     <key>highlight</key>
     <styleurl>#highlight/photo/{url}</styleurl>
   </pair>
 </stylemap>
<placemark>
   <styleurl>#styleMap/photo/{url}</styleurl>
   <name>{title}</name>
   <snippet maxlines="4">
  
   </snippet>
       <description>
       <!--[CDATA[                <a href="{url}"><img src="{image_s}" /></a><br /><br />               <b>Title:</b>{title}<br /><br />               <b>Descript:</b><br />{descript}<br /><br />               <b>Date time:</b>{date_time}<br /><br />               <b>Model:</b>{model}<br /><br />               <b>Tags:</b>{tag1},{tag2},{tag3} ...<br /><br />               <a href="{url}">Open photo page</a><br />               <br /><br />               ]]-->
       </description>
   <point>
       <coordinates>{longitude},{latitude}</coordinates>
   </point>
</placemark>

10.Click tab 進階模版 and 啟動
clip_image006
11.Click “複製到剪貼簿”(the friendly fickr will get picture information form web site and apply the template before put inside.)
※Because the FF do not supprt photo id parameter , so that use url to generate id. after step replace surplus urls.
clip_image008
image
clip_image010
12.Replace the picture id. copy below option to replace dialog. and select Regular Expressions and select option Perl
photo/http://www.flickr.com/photos/(.*?)/(.*?)/
photo/\2

clip_image012
clip_image014
14.compress to zip file and rename the extension to *.kmz
clip_image016
15.After that you can place in internet such as google page to share anyone.
16.This site can validator your kmz.
clip_image018
Demo … Google Map
clip_image020
Save the kmz link to My Map that will show pictures by postition when you move .
image
Double click *.kmz … Google Earth
image