#
文章描述了實現 Multithreaded Servers的3種方法:
1)單線程,性能性差,請求等待時間長
2)多線程,把接受請求和處理請求的線程分開,接受后交給 worker處理
3)線程池,性能最佳,有效地防止負載過重,重復利用線程,請求多時,讓請求排隊接收處理
4)主要用socket來通信, ServerSocket 和 Socket
具體文章請看:http://tutorials.jenkov.com/java-multithreaded-servers/index.html
摘要: 軟件模塊之間總是存在著一定的接口,從調用方式上,可以把他們分為三類:同步調用、回調和異步調用。
同步調用是一種阻塞式調用,調用方要等待對方執行完畢才返回,它是一種單向調用,如HTTP;
回調是一種雙向調用模式,也就是說,被調用方在接口被調用時也會調用對方的接口;
異步調用是一種類似消息或事件的機制,不過它的調用方向剛好相反,接口的服務在收到某種訊息或發生某種事件時,會主動通知客戶方(即調用客戶方的接口),如JMS;
閱讀全文
摘要: 雖然很少有 Java? 開發人員能夠忽視多線程編程和支持它的 Java 平臺庫,更少有人有時間深入研究線程。相反地,我們臨時學習線程,在需要時向我們的工具箱添加新的技巧和技術。以這種方式構建和運行適當的應用程序是可行的,但是您可以做的不止這些。理解 Java 編譯器的線程處理特性和 JVM 將有助于您編寫更高效、性能更好的 Java 代碼
閱讀全文
The Zen of Python, by Tim Peters
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
摘要: This is the text of the Commencement address by Steve Jobs, CEO of Apple Computer and of Pixar Animation Studios, delivered on June 12, 2005.
I am honored to be with you today at your commencement from one of the finest universities in the world. I never graduated from college. Truth be told, this is the closest I’ve ever gotten to a college graduation. Today I want to tell you three stories from my life. That’s it. No big deal. Just three stories.
The first story is about conn
閱讀全文
摘要: 1. 軟件架構概述
1.1 什么是軟件架構
◎ 軟件架構的概念很混亂。如果你問五個不同的人,可能會得到五種不同的答案。
◎ 軟件架構概念主要分為兩大流派:
組成派:軟件架構 = 組件 + 交互。
決策派:軟件架構 = 重要決策集。
◎ 組成派和決策派的概念相輔相成。
閱讀全文
摘要: 所謂第一范式(1NF)是指數據庫表的每一列都是不可分割的基本數據項,同一列中不能有多個值,即實體中的某個屬性不能有多個值或者不能有重復的屬性。如果出現重復的屬性,就可能需要定義一個新的實體,新的實體由重復的屬性構成,新實體與原實體之間為一對多關系。在第一范式(1NF)中表的每一行只包含一個實例的信息。簡而言之,第一范式就是無重復的列。
閱讀全文
OS實時監控工具dstat,整合了vmstat, iostat, ifstat, netstat等常見os監控工具的優點,輸出的結果簡單直觀,并且結果可以保存到csv文件。
dokie@ubuntu:~$ dstat
----total-cpu-usage---- -dsk/total- -net/total- ---paging-- ---system--
usr sys idl wai hiq siq| read writ| recv send| in out | int csw
14 5 78 3 0 0| 553k 109k| 0 0 | 83B 989B| 983 2190
8 2 90 0 0 0| 0 0 |2076B 1383B| 0 0 |1076 1407
9 3 89 0 0 0| 0 72k|7530B 420B| 0 0 | 721 1501
9 4 87 0 0 0| 0 0 |9547B 564B| 0 0 | 750 1474
8 2 89 0 0 0| 0 0 | 12k 672B| 0 0 | 772 1681
9 2 89 0 0 0| 0 0 | 13k 792B| 0 0 | 677 1396
dokie@ubuntu:~$ dstat -h
Usage: dstat [-afv] [options..] [delay [count]]
Versatile tool for generating system resource statistics
Dstat options:
-c, --cpu enable cpu stats
-C 0,3,total include cpu0, cpu3 and total
-d, --disk enable disk stats
-D total,hda include hda and total
-g, --page enable page stats
-i, --int enable interrupt stats
-I 5,eth2 include int5 and interrupt used by eth2
-l, --load enable load stats
-m, --mem enable memory stats
-n, --net enable network stats
-N eth1,total include eth1 and total
-p, --proc enable process stats
-r, --io enable io stats (I/O requests completed)
-s, --swap enable swap stats
-S swap1,total include swap1 and total
-t, --time enable time/date output
-T, --epoch enable time counter (seconds since epoch)
-y, --sys enable system stats
--aio enable aio stats
--fs enable fs stats
--ipc enable ipc stats
--lock enable lock stats
--raw enable raw stats
--socket enable socket stats
--tcp enable tcp stats
--udp enable udp stats
--unix enable unix stats
--vm enable vm stats
-M stat1,stat2 enable external plugins
--mods stat1,stat2
--list list all internal and external plugins
-a, --all equals -cdngy (default)
-f, --full expand -C, -D, -I, -N and -S discovery lists
-v, --vmstat equals -pmgdsc -D total
--integer show integer values
--nocolor disable colors (implies --noupdate)
--noheaders disable repetitive headers
--noupdate disable intermediate updates
--output file write CSV output to file
delay is the delay in seconds between each update
count is the number of updates to display before exiting
The default delay is 1 and count is unspecified (unlimited)
常用的命令:dstat -cdlmnpsy
導出為CVS:
dstat -ta --output osstat.csv
1. 安裝JDK
http://wiki.ubuntu.org.cn/Java%E5%AE%89%E8%A3%85%E9%85%8D%E7%BD%AE
2. 安裝Python
1). apt-get install python
2). PyDev for eclipse:
Name:PyDev,Location:http://pydev.org/updates
Ref:http://www.cnblogs.com/Realh/archive/2010/10/10/1847251.html
3. 安裝dstat--性能監測工具
apt-get install dstat