Daniel-Journey Weekly Dose –2012/1/30
Scalability
但本地缓存最大的问题就是数据同步,如果让集中式存储(cache,queue)来通知只会增加复杂度,因此通常最简单的方式就是根据业务数据的敏感度设置不同长短的本地失效时间。但现在如果要设置一个较短的有效期(例如一秒),对于计算机来说已经大大的减轻了压力(1秒对程序来说太久了),但是整体本地缓存对后端保护的效果不佳(特别是后端如果是并发处理能力较弱的系统),如果遇到并发量大的系统,那么就更为突出了。
OOP
Exceptions versus Return Values
Stateless or Stateful?
Service objects will usually be stateless. Stateless service layers are highly scalable: They pose no replication issues and there is no need to allocate additional resources for every client. (Remember that one of the key motivations of a middle tier is to share resources between multiple clients.) It is also much easier for stateless service layers to support remote clients, if necessary. A stateless service layer is one concession of object orientation that I find not too painful.……
If possible, design applications to use a stateless service layer. Hold state in the web tier, rather than in the business logic tier, if possible.
LINUX
Understand UNIX / Linux Inodes Basics with Examples
An Inode number points to an Inode. An Inode is a data structure that stores the following information about a file :
- Size of file
- Device ID
- User ID of the file
- Group ID of the file
- The file mode information and access privileges for owner, group and others
- File protection flags
- The timestamps for file creation, modification etc
- link counter to determine the number of hard links
- Pointers to the blocks storing file’s contents
JAVA
jvm performance tuning (notes)
Thread state transitions diagram

Optimizing ArrayList.removeAll
Performance techniques used in the Hotspot JVM
Deep dive into assembly code from Java
"java -XX:+PrintOptoAssembly -server -cp . Main". The -XX:+PrintOptoAssembly is the magic option, and with this option I get the following, which shows the code of the "foo" method:
fillInStackTrace每次执行的时候,会清空原来的栈内的trace信息。然后在当前的调用位置处重新建立trace信息, 所以在方法b()中printStackTrace的执行结果跟c()中的是不一样的。 b()方法被c()调用,c()被a()调用,a()被main()调用, 所以在b()中fillInStackTrace时,栈内会包含b(), a(), main()的信息;而在c()中调用fillInStackTrace时,栈内的信息会被刷新为c(), a(), main()。
Java?言默认的 String和 StringBuilder类很难支撑起操纵大量字符串的系统。rope 数据结构可能是更好的替代品。这篇文章介绍 Ropes for Java,这是针对 Java 平台的 rope 实现;本文还将研究性能问题,并提供一些有效使用 rope 库的指导。
在Java中,一个空Object对象的大小是8byte,这个大小只是保存堆中一个没有任何属性的对象的大小。看下面语句:
Object ob = new Object();
这样在程序中完成了一个Java对象的生命,但是它所占的空间为:4byte+8byte。4byte是上面部分所说的Java栈中保存引用的所需要的空间。而那8byte则是Java堆中对象的信息。因为所有的Java非基本类型的对象都需要默认继承Object对象,因此不论什么样的Java对象,其大小都必须是大于8byte。
有了Object对象的大小,我们就可以计算其他对象的大小了。
Class NewObject {
int count;
boolean flag;
Object ob;
}
其大小为:空对象大小(8byte)+int大小(4byte)+Boolean大小(1byte)+空Object引用的大小 (4byte)=17byte。但是因为Java在对对象内存分配时都是以8的整数倍来分,因此大于17byte的最接近8的整数倍的是24,因此此对象的大小为24byte。
这里需要注意一下基本类型的包装类型的大小。因为这种包装类型已经成为对象了,因此需要把他们作为对象来看待。包装类型的大小至少是12byte(声明一个空Object至少需要的空间),而且12byte没有包含任何有效信息,同时,因为Java对象大小是8的整数倍,因此一个基本类型包装类的大小至少是16byte。这个内存占用是很恐怖的,它是使用基本类型的N倍(N>2),有些类型的内存占用更是夸张(随便想下就知道了)。因此,可能的话应尽量少使用包装类。在JDK5.0以后,因为加入了自动类型装换,因此,Java虚拟机会在存储方面进行相应的优化。
在计算存活周期这个阈值时,hotspot会遍历所有age的table,并对其所占用的大小进行累积,当累积的大小超过了survivor space的一半时,则以这个age作为新的存活周期阈值,最后取age和MaxTenuringThreshold中更小的一个值
如希望跟踪每次minor GC后新的存活周期的阈值,可在启动参数上增加:-XX:+PrintTenuringDistribution,输出的信息中的:
Desired survivor size 1048576 bytes, new threshold 7 (max 15)
new threshold 7即标识新的存活周期的阈值为7。
Understanding a Java thread dump
The Top Java Memory Problems – Part 1
The Top Java Memortaiy Problems – Part 2
Hardware
Database
当下列事件发生时,事务就开始了
1、连接到数据库,并执行第一条DML语句
2、前一个事务结束后,又输入了另一条DML语句
