#
文章描述了实现 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