Hunter的大杂烩 技术学习笔记

January 17, 2009

Performance Anti-Patterns in Database-Driven Applications

Filed under: 技术话题 — hunter @ 11:07 pm


Alois Reitbauer介绍了几个使用DB方面的反模式:

1. Misuse of O/R Mappers

      O/R mapper框架可以大幅提高开发效率,开发者 不理解实际表结构的话,在使用O/R mapper框架时,常常会进入误区:

     a. 对O/R Mapper的loading behavior 不了解,往往无意中访问一个对象的属性,就导致了一个复杂的SQL语句被生成并被执行,有时这种情况会导致非常大量的数据库访问;

     b. O/R Mapper通常被配置为lazy load模式,导致开发者不知道关联对象实际被访问的时间,可能会导致性能上的一些问题;而O/R Mapper框架为了保持lazy load模式,往往还会持有相关db connection相当长的时间,这又导致对DB服务器的压力;

2.Load More Data Then Needed

    — hunter: 感觉并不是一个很严重的问题,remote 调用一般比较昂贵,我们应该尽量返回粗颗粒度的对象 

3.Inadequate Usage of Resources

   1.b load time的问题导致的 

4. One Bunch of Everything

   Using different connection pools for different query types results in much more predicable end user performance

   — 这个说的极是,也是历史经验的总结,差点翻了大错误;

5.Bad Testing

   — 没看明白 


Database access is one of the most critical areas impacting performance and scalability in modern applications. While frameworks support in building data access logic, a serious amount of thought still has to be put into the design of data access logic to avoid pitfalls and problems. The key is to understand the details of the dynamics and characteristics of an application’s data-access layer.

No Comments

No comments yet.

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

Powered by WordPress