Server 在有限的記憶體下,Memstore的控制相當重要
HBase 在大量寫入時,可能會造成 Out Of Memory
盡可能使用批量寫入的方式
參考下列文章
http://blog.linezing.com/2012/03/hbase-performance-optimization
http://www.cnblogs.com/panfeng412/archive/2012/03/08/hbase-performance-tuning-section3.html
Google Code Prettify
2013年5月22日 星期三
HTML5 Canvas Scale Smoothing
Canvas 預設 放大/縮小 會做 Smoothing,但反而造成不必要的模糊
在 Chrome 、 Firefox 提供關閉的方式
ctx.imageSmoothingEnabled = false;
ctx.webkitImageSmoothingEnabled = false;
ctx.mozImageSmoothingEnabled = false;
測試網址如下:
http://jsfiddle.net/saviski/pGs4f/12/
http://jsfiddle.net/P36cS/2/
在 Chrome 、 Firefox 提供關閉的方式
ctx.imageSmoothingEnabled = false;
ctx.webkitImageSmoothingEnabled = false;
ctx.mozImageSmoothingEnabled = false;
測試網址如下:
http://jsfiddle.net/saviski/pGs4f/12/
http://jsfiddle.net/P36cS/2/
C10M 備忘錄
The C10M problem
解決方式: http://c10m.robertgraham.com/p/blog-page.html
相關文章
簡中: http://www.open-open.com/lib/view/open1369096743247.html
原文:http://highscalability.com/blog/2013/5/13/the-secret-to-10-million-concurrent-connections-the-kernel-i.html
C10M Google 論壇
https://groups.google.com/forum/#!topic/mechanical-sympathy/ao44gonVdAY
改善 TCP封包遺失,穩定網路封包的套件
http://www.ntop.org/products/pf_ring/
PF_RING 測試文章
http://www.metaflows.com/technology/pf-ring/
http://codet.net/wordpress/285.html
2012年9月20日 星期四
JMuPdf PDF to Image
MuPdf 實在有夠強大的,解析檔案出現字型問題,還是能夠正常輸出畫面
轉jpg範例
PdfDocument pdfDoc = new PdfDocument(pdf_file);
int count = pdfDoc.getPageCount();
int zoom = 1;
for(int i=0;i < count ;i++){
PageRenderer render = new PageRenderer(pdfDoc.getPage((i+1)), zoom, Page.PAGE_ROTATE_AUTO, ImageType.IMAGE_TYPE_RGB);
render.setAntiAliasLevel(8);//需設為8,不然中文字會變醜
render.render(true);
JPGOptions options = new JPGOptions();
options.setQuality(96);
FileOutputStream out = new FileOutputStream(new File(out_dir+(i+1)+".jpg"));
JimiWriter writer = Jimi.createJimiWriter("image/jpeg", out);
writer.setSource(render.getImage().getSource());
writer.setOptions(options);
writer.putImage(out);
out.flush();out.close();
render.dispose();
}
pdfDoc.dispose();
解決canvas在行動裝置上模糊的問題
在高解析度的行動裝置上畫圖,一直會有模糊的問題
可以參考 http://www.html5rocks.com/en/tutorials/canvas/hidpi/
javascript 如下:
可以參考 http://www.html5rocks.com/en/tutorials/canvas/hidpi/
javascript 如下:
var devicePixelRatio = window.devicePixelRatio || 1, var backingStoreRatio = context.webkitBackingStorePixelRatio || context.mozBackingStorePixelRatio || context.msBackingStorePixelRatio || context.oBackingStorePixelRatio || context.backingStorePixelRatio || 1, var ratio = devicePixelRatio / backingStoreRatio;
if (devicePixelRatio !== backingStoreRatio) {
var oldWidth = canvas.width;
var oldHeight = canvas.height;
canvas.width = oldWidth * ratio;
canvas.height = oldHeight * ratio;
canvas.style.width = oldWidth + 'px';
canvas.style.height = oldHeight + 'px';
}
2012年7月2日 星期一
Apache http Server 2.4 效能解放
Apache 2.4 宣佈已經可以跟 Nginx比拼了
但很多網路文章卻測不出這個效能
一開始我也沒辦法解放它的效能
經過數次的安裝移除的循環
發現一個重要的參數: --with-mpm
必須安裝為 event Multi-Processing Module
這就是解放效能的所在囉
什麼是 event module, 其實就是 linux EPoll,Nginx 也是應用這個模式
Apache 2.4 安裝步驟
#安裝 APR
tar -zxvf apr-1.4.6.tar.gz
cd apr-1.4.6
./configure --prefix=/usr/local/apache-apr --enable-nonportable-atomics=yes
make
sudo make install
#安裝 APR-UTIL apr-util
tar -zxvf apr-util-1.4.1.tar.gz
cd apr-util-1.4.1
./configure --prefix=/usr/local/apache-apr --with-apr=/usr/local/apache-apr
make
sudo make install
unzip -o pcre-8.30.zip
cd pcre-8.30
./configure --prefix=/usr/local/pcre --enable-utf --enable-unicode-properties
make
sudo make install
#安裝 apache server
1. tar -zxvf httpd-2.4.2.tar.gz
2. cd httpd-2.4.2
3. ./configure --prefix=/usr/local/apache2.4 --with-apr=/usr/local/apache-apr --with-apr-util=/usr/local/apache-apr --with-pcre=/usr/local/pcre --with-mpm=event \
--enable-nonportable-atomics=yes \
--enable-mods-shared=all \
--enable-expires=shared \
--enable-headers=shared \
--enable-reqtimeout=shared \
--enable-ssl=shared \
--enable-rewrite=shared \
--enable-speling=shared \
--enable-proxy=shared \
--enable-proxy-connect=shared \
--enable-proxy-ajp=shared \
--enable-proxy-balancer=shared \
--enable-proxy-express=shared \
--enable-info=shared \
--enable-heartbeat=shared \
--enable-heartmonitor=shared \
--enable-ratelimit=shared \
--enable-remoteip=shared \
--enable-allowmethods=shared
4. make
5. sudo make install
6.Check Apache MPM 是 event
/usr/local/apache2.4/bin/httpd -l
/usr/local/apache2.4/bin/httpd -V | grep MPM
#效能調整
#修改 httpd-mpm.conf 下的mpm_event_module
StartServers 2
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild 25
MaxRequestWorkers 150
MaxConnectionsPerChild 0
利用 Ghostscript 重新產生PDF
Ghostscript
http://pages.cs.wisc.edu/~ghost/
完整參數
http://www.ghostscript.com/doc/current/Use.htm
範例指令
轉換為600dpi
gswin32c -dNOPAUSE -dBATCH -q -r600 -sDEVICE=pdfwrite -sOutputFile=out.pdf input.pdf
指定頁數
gswin32c -dNOPAUSE -dBATCH -q -r600 -sDEVICE=pdfwrite -dFirstPage=22 -dLastPage=36 -sOutputFile=out.pdf input.pdf
pdfwrite Additional Options
PDF optimization level selection options
-dPDFSETTINGS=/screen (screen-view-only quality, 72 dpi images)
-dPDFSETTINGS=/ebook (low quality, 150 dpi images)
-dPDFSETTINGS=/printer (high quality, 300 dpi images)
-dPDFSETTINGS=/prepress (high quality, color preserving, 300 dpi imgs)
-dPDFSETTINGS=/default (almost identical to /screen)
Paper size selection options
-sPAPERSIZE=letter
-sPAPERSIZE=a4
-dDEVICEWIDTHPOINTS=w -dDEVICEHEIGHTPOINTS=h (point=1/72 of an inch)
-dFIXEDMEDIA (force paper size over the PostScript defined size)
Other options
-dEmbedAllFonts=true
-dSubsetFonts=false
-dFirstPage=pagenumber
-dLastPage=pagenumber
-dAutoRotatePages=/PageByPage
-dAutoRotatePages=/All
-dAutoRotatePages=/None
-r1200 (resolution for pattern fills and fonts converted to bitmaps)
-sPDFPassword=password
-dConvertCMYKImagesToRGB=true
-dCompatibilityLevel=1.5
更多參數請參考 Ps2pdf.htm
訂閱:
文章 (Atom)