关于应用可扩展性
使用oracle数据库开发应用,对于应用的扩展性,一直以为绑定变量是最重要的。
现在知道,连接方式也是非常重要的。
有2个应用和oracle文档的说明让我认识到这点。2个应用有点类似,号称3层架构,使用了websphere中间件,但是客户端直接连接数据库,没有使用连接池。
每处理一条业务,要连接3次数据库,处理完成就断开。
每秒要处理2条业务,数据库连接7次左右。
结果是:
一个应用发生过2次telnet不上的情况,虽然业务还在跑,当时没有办法连接上去看系统性能,估计是内存耗尽导致。
另外一个应用每秒处理业务逐渐降低,具体原因还不是很清楚,但是在改用连接池后,性能提高了有10倍。
看看oracle官方文档的说明:
Oracle9i Database Performance Planning Release 2 (9.2)
Part Number A96532-01
Good Database Connection Management
Connecting to the database is an expensive operation that is highly unscalable. Therefore, the number of concurrent connections to the database should be minimized as much as possible. A simple system, where a user connects at application initialization, is ideal. However, in a Web-based or multitiered application, where application servers are used to multiplex database connections to users, this can be difficult. With these types of applications, design efforts should ensure that database connections are pooled and are not reestablished for each user request.